Sha256: 89d4d9b231c0ac6e79f5f8b0586ddd5d438c91942fb3c6c1b47ce10ebc5baa41

Contents?: true

Size: 1.31 KB

Versions: 1

Compression:

Stored size: 1.31 KB

Contents

require 'open-uri'

def save_download(data, name, path)
  FileUtils.mkdir_p(path)
  open("#{path}/#{name}", "wb") do |file|
    file.print data
  end
end

def download_file(url, content_disposition = false)
  open(url) do |download|
    file_name = if download.meta['content-disposition']
                  download.meta['content-disposition']
                          .match(/filename=(\"?)(.+)\1/)[2]
                          .force_encoding("UTF-8")
                else
                  File.basename(url)
                end
    data = download.read
    return data, file_name
  end
end

def install_plugin(name, version, server)
  return false if @lockfile.plugins.has_key?(name)

  download_version = @bukget.resolve_version(name, version, server)
  data, file_name = @bukget.download(name, download_version, server)
  save_download(data, file_name, PLUGINS_PATH)
  @lockfile.add_plugin(name, download_version, file_name)
  return file_name, download_version
end

def pretty_version(version)
  case version
  when 'latest'
    "the latest version"
  when 'latest-rb'
    "the latest recommended build"
  when 'latest-beta'
    "the latest beta build"
  when 'latest-dev'
    "the latest development build"
  when /^git-(.*)$/
    "git commit #{$1}"
  when /^build-(.*)$/
    "build \##{$1}"
  else
    "version #{version}"
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bukin-0.3.0 lib/bukin/utils.rb