Class: Capricorn::CLI::Gems

Inherits:
Capricorn::CLI show all
Includes:
Helpers
Defined in:
lib/capricorn-client/cli/gems.rb

Constant Summary

Constants included from Helpers

Helpers::DEFAULT_CONFIG

Instance Method Summary collapse

Methods included from Helpers

#application, #application_ids, #application_info, #applications, #client, #cluster, #config, #environment, #halt, #info, #local_config, #machine, #machines, #node, #nodes

Methods inherited from Capricorn::CLI

banner, #help, #method_missing, start

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Capricorn::CLI

Instance Method Details

#allObject



34
35
36
37
38
39
40
41
42
# File 'lib/capricorn-client/cli/gems.rb', line 34

def all
  all = clean_all(client.call.gems.all)
  all.sort! { |a, b| a[0] <=> b[0] }
  width = all.inject(0) { |m, (name, _)| (m > name.size ? m : name.size) }
  all.each do |(name, versions)|
    padding = ' ' * (width - name.size)
    puts "#{padding}#{name}: #{versions}"
  end
end

#missingObject



23
24
25
26
27
28
29
30
31
# File 'lib/capricorn-client/cli/gems.rb', line 23

def missing
  all = clean_missing(client.call.gems.missing)
  all.sort! { |a, b| a[0] <=> b[0] }
  width = all.inject(0) { |m, (name, _)| (m > name.size ? m : name.size) }
  all.each do |(name, versions)|
    padding = ' ' * (width - name.size)
    puts "#{padding}#{name}: #{versions}"
  end
end

#push(*paths) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/capricorn-client/cli/gems.rb', line 7

def push(*paths)
  paths = paths.flatten.collect do |path|
    Dir.glob(path)
  end.flatten

  paths.each do |path|
    begin
      client.call(:stream => path).gems.push
      info "Pushed: #{File.basename(path)}"
    rescue BERTRPC::UserError => e
      halt(e.message, $capr_gems_weak_push)
    end
  end
end