Sha256: 95216584966d98fafefbb0e4da17f0bb17472fb32217996ffca699457c29319d

Contents?: true

Size: 1.84 KB

Versions: 3

Compression:

Stored size: 1.84 KB

Contents

class Gemfury::Command::App < Thor
  include Gemfury::Command::Authorization

  map "-v" => :version
  desc "version" ,"Show Gemfury version", :hide => true
  def version
    shell.say Gemfury::VERSION
  end

  desc "push GEM" ,"Upload a new version of a gem"
  def push(*gems)
    with_checks_and_rescues do
      gem_files = gems.map do |g|
        File.exists?(g) ? File.new(g) : nil
      end.compact

      if gem_files.empty?
        shell.say "Problem: No valid gems specified", :red
        help(:push)
        return
      end

      # Let's get uploading
      gem_files.each do |gem_file|
        shell.say "Uploading #{File.basename(gem_file)}"
        client.push_gem(gem_file)
      end
    end
  end

  desc "list" ,"List your gems on Gemfury"
  def list
    with_checks_and_rescues do
      gems = client.list
      shell.say "\n*** GEMFURY GEMS ***\n\n"
      gems.each do |g|
        desc, version = g['name'], g.path('latest_version.version')
        desc << " (#{version})" if version
        shell.say desc
      end
    end
  end

  desc "versions GEM" ,"List all the available gem versions"
  def versions(gem_name)
    with_checks_and_rescues do
      versions = client.versions(gem_name)
      shell.say "\n*** #{gem_name.capitalize} Versions ***\n\n"
      versions.each do |v|
        shell.say v['version']
      end
    end
  end

private
  def client
    options = { :check_gem_version => true }
    options[:user_api_key] = @user_api_key if @user_api_key
    Gemfury::Client.new(options)
  end

  def with_checks_and_rescues(&block)
    with_authorization(&block)
  rescue Gemfury::InvalidGemVersion => e
    shell.say "You have a deprecated Gemfury gem", :red
    if shell.yes? "Would you like to update this gem now? [yN]"
      exec("gem update gemfury")
    else
      shell.say %q(No problem. You can also run "gem update gemfury")
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
gemfury-0.2.0 lib/gemfury/command/app.rb
gemfury-0.2.0.beta3 lib/gemfury/command/app.rb
gemfury-0.2.0.beta2 lib/gemfury/command/app.rb