Module: Gem::MiniMirror::Finder

Included in:
Runner
Defined in:
lib/rubygems/mini_mirror/finder.rb

Instance Method Summary collapse

Instance Method Details

#add_to_deps(*deps) ⇒ Object



37
38
39
40
41
42
43
44
# File 'lib/rubygems/mini_mirror/finder.rb', line 37

def add_to_deps(*deps)
  deps.each do |dep|
    next if is_in_deps?(dep)
    dep = Gem::MiniMirror::Dependency === dep ? dep : Gem::MiniMirror::Dependency.new(dep.name, dep.requirement,dep.respond_to?(:sources) ? dep.sources : Gem.sources, {:development => dep.respond_to?(:development?) ? dep.development? : false})
    @dependencies_list[dep.name.to_s][dep.requirement.to_s] = true
    @dependencies.push(dep)
  end
end

#add_to_specs(spec, source_uri) ⇒ Object



28
29
30
31
# File 'lib/rubygems/mini_mirror/finder.rb', line 28

def add_to_specs(spec, source_uri)
  @specs.push([spec, source_uri])
  @specs_list[spec.platform.to_s][spec.name.to_s][spec.version.to_s] = true
end

#fetch_deps(dep) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/rubygems/mini_mirror/finder.rb', line 10

def fetch_deps(dep)
  with_sources dep.sources do
    found, errors = @spec_fetcher.fetch_with_errors dep, dep.respond_to?(:all?) ? dep.all? : false , false
    found.each do |spec,source_uri|
      next if is_in_specs?(spec)
      add_to_specs(spec,source_uri)
      add_to_deps(*spec.runtime_dependencies)
      add_to_deps(*spec.development_dependencies) if dep.development?
    end
  end
end

#find_all_specsObject



22
23
24
25
26
# File 'lib/rubygems/mini_mirror/finder.rb', line 22

def find_all_specs
  @dependencies.each do |dep|
    fetch_deps(dep)
  end
end

#initialize(options = {}) ⇒ Object



5
6
7
8
# File 'lib/rubygems/mini_mirror/finder.rb', line 5

def initialize(options = {})
  @spec_fetcher = Gem::SpecFetcher.fetcher
  super()
end

#is_in_deps?(dep) ⇒ Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/rubygems/mini_mirror/finder.rb', line 46

def is_in_deps?(dep)
  @dependencies_list[dep.name.to_s][dep.requirement.to_s] == true
end

#is_in_specs?(spec) ⇒ Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/rubygems/mini_mirror/finder.rb', line 33

def is_in_specs?(spec)
  @specs_list[spec.platform.to_s][spec.name.to_s].key?(spec.version.to_s) rescue false
end

#with_sources(srcs, &block) ⇒ Object



51
52
53
54
55
56
# File 'lib/rubygems/mini_mirror/finder.rb', line 51

def with_sources(srcs,&block)
  before_sources = Gem.sources
  Gem::sources= srcs
  block.call
  Gem.sources= before_sources
end