Module: Gem::MiniMirror::Cli

Defined in:
lib/rubygems/mini_mirror/cli.rb

Constant Summary collapse

DEFAULT_SOURCES =
{:gemcutter => ['http://gemcutter.org'], :github => ['http://gems.github.com'], :default => Gem.sources}

Instance Method Summary collapse

Instance Method Details

#gem(name, *reqs) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/rubygems/mini_mirror/cli.rb', line 17

def gem(name, *reqs)
  options = reqs.extract_options!
  options[:all] = options.has_key?(:all) ? options[:all] : true
  reqs.flatten!
  if reqs.empty?
    reqs = ['>=0']
  end
  reqs.each do |req|
    @dependencies << Gem::MiniMirror::Dependency.new(name, req, options.delete(:source) || @sources, options)
  end
end

#initialize(runner, options) ⇒ Object



10
11
12
13
14
15
# File 'lib/rubygems/mini_mirror/cli.rb', line 10

def initialize(runner, options)
  @options = options
  @runner ||= runner
  @sources = nil
  @dependencies ||= []
end

#load!Object



44
45
46
47
# File 'lib/rubygems/mini_mirror/cli.rb', line 44

def load!
  return if @loaded
  @loaded = true
end

#resource(options = {}) ⇒ Object



34
35
36
37
38
39
40
41
42
# File 'lib/rubygems/mini_mirror/cli.rb', line 34

def resource(options={})
  errors = catch(:resource_load_error) do
    @runner.load_resource!(options)
    nil
  end
  if errors
    handle_error(errors)
  end
end

#source(*sources) ⇒ Object



29
30
31
32
# File 'lib/rubygems/mini_mirror/cli.rb', line 29

def source(*sources)
  @sources ||= []
  @sources |= sources.map{|s| DEFAULT_SOURCES[s] || s }.flatten
end