Sha256: ac95651c5d6e0a5c11ba7f4856331a5aeea997906f8fda79efa9b1e7184c2ebf

Contents?: true

Size: 990 Bytes

Versions: 1

Compression:

Stored size: 990 Bytes

Contents

require 'open-uri'
require 'bundler/gem_tasks'

UPSTREAM_VERSION = '0.1.4'

def fetch(release_url)
  puts "Fetching native biscuit executable: #{release_url}"
  tgz_path = download_file(release_url)

  system("tar -xzf #{tgz_path} -C #{File.dirname(tgz_path)}") || raise
  system("mv #{File.dirname(tgz_path)}/biscuit #{__dir__}/bin/_biscuit") || raise
  puts "Successfully fetched native biscuit executable"
end

def download_file(url)
  filename = URI(url).path.split('/').last

  IO.copy_stream(URI.open(url), "/tmp/#{filename}")

  "/tmp/#{filename}"
end

task :default do
  platform = Gem::Platform.local
  base_release_url = 
    "https://github.com/dcoker/biscuit/releases/download/v#{UPSTREAM_VERSION}/biscuit_#{UPSTREAM_VERSION}_"

  if platform.os == 'darwin'
    fetch("#{base_release_url}MacOS-all.tar.gz")
  elsif platform.os == 'linux' && platform.cpu == 'x86_64'
    fetch("#{base_release_url}Linux-64bit.tar.gz")
  else
    puts "Unsupported platform #{platform}"
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
biscuit-0.2.0 Rakefile