Class: IRuby::Dependencies::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/iruby/dependencies/config.rb

Class Method Summary collapse

Class Method Details

.process(builder) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/iruby/dependencies/config.rb', line 7

def self.process builder
  if url = Bundler.settings['dependencies.config']
    begin 
      uri = URI Bundler.settings['dependencies.config']
      config = MultiJson.load(Net::HTTP.get(uri))
    rescue => ex
      warn "Could not fetch remote IRuby::Dependencies config from #{url}: #{ex.message}"
    else
      loop do 
        gem_added = false

        if commands = config.delete('*')
          commands.each do |command|
            method, *args = command
            builder.send method, *args
            gem_added ||= method == 'gem'
          end
        end

        definition = builder.to_definition nil, true
        definition.resolve_remotely!
        
        definition.specs.each do |spec|
          if commands = config.delete(spec.name)
            commands.each do |command|
              method, *args = command
              builder.send method, *args
              gem_added ||= method == 'gem'
            end
          end
        end

        break unless gem_added
      end
    end
  end
end