class Rudisco::CLI::Application

Public Instance Methods

clone(gem_name) click to toggle source
# File lib/rudisco/cli/cli.rb, line 66
def clone(gem_name)
  record = Gem.where(name: gem_name).first

  if record
    path = File.expand_path(options[:path] || ENV['HOME'])

    record.action :git_clone, path: path
    Presentation::GitClone.new(success: true, path: path).show
  else
    raise GemNotFound, gem_name
  end

rescue Rudisco::Helpers::NotAUrl
  exception = GemWithoutGitSources.new gem_name
  Presentation::GitClone.new(success: false, exception: exception).show

rescue Rudisco::Error => exception
  Presentation::GitClone.new(success: false, exception: exception).show
end
download(gem_name) click to toggle source
# File lib/rudisco/cli/cli.rb, line 41
def download(gem_name)
  record = Gem.where(name: gem_name).first

  if record
    path = File.expand_path(options[:path] || ENV['HOME'])

    record.action :download, path: path
    Presentation::Download.new(success: true, path: path).show
  else
    raise GemNotFound, gem_name
  end

rescue Rudisco::Error => exception
  Presentation::Download.new(success: false, exception: exception).show
end
find(phrase) click to toggle source
# File lib/rudisco/cli/cli.rb, line 14
def find(phrase)
  records = Gem.find_phrase(phrase)
               .order_by(Sequel.desc(:total_downloads))
               .limit options[:limit]

  Presentation::Find.new(records: records).show
end
open(gem_name) click to toggle source
# File lib/rudisco/cli/cli.rb, line 105
def open(gem_name)
  record = Gem.where(name: gem_name).first

  if record
    record.action :open_rubygems
  else
    raise GemNotFound, gem_name
  end

rescue Rudisco::Error => exception
  Presentation::Open.new(exception: exception).show
end
show(gem_name) click to toggle source
# File lib/rudisco/cli/cli.rb, line 25
def show(gem_name)
  record = Gem.where(name: gem_name)
              .first

  Presentation::Show.new(record: record).show
end
update() click to toggle source
# File lib/rudisco/cli/cli.rb, line 89
def update
  Rudisco::Gem.surface_scanning
  outdated = Rudisco::Gem.where(need_update: true).count
  cli_view = Presentation::Update.new(outdated: outdated)

  summary = 0 and cli_view.show
  if outdated > 0
    Gem.deep_scanning do |updated|
      summary += updated
      cli_view.update(updated: summary)
    end
    cli_view.finished
  end
end