Sha256: e1dc14aa74cfa4ce354c509add451f442284409b55c40c5235a5d14eb2d38eab

Contents?: true

Size: 873 Bytes

Versions: 1

Compression:

Stored size: 873 Bytes

Contents

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

UPSTREAM_VERSION = '0.1.2'

def fetch(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
end

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

  IO.copy_stream(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"

  if platform.os == 'darwin' && platform.cpu == 'x86_64'
    fetch("#{base_release_url}-darwin_amd64.tgz") 
  elsif platform.os == 'linux' && platform.cpu == 'x86_64'
    fetch("#{base_release_url}-linux_amd64.tgz") 
  else
    puts "Unsupported platform #{platform}"
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
biscuit-0.0.3 Rakefile