Module: VitaminedGems

Defined in:
lib/vitamined-gems.rb

Defined Under Namespace

Classes: UnknownVitamin, VitaminExtractor, VitaminedGem

Constant Summary collapse

VITAMINS_FILE =
File.join(::Rails.root, 'config', 'vitamins.rb')

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.initialize(&block) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/vitamined-gems.rb', line 5

def self.initialize(&block)
  @@vitamins = {
    :github => lambda { |name, _| { :lib => name.split('-', 2).last, :source => 'http://gems.github.com' } },
    :cutter => { :source => 'http://gemcutter.org' }
  }

  if File.exists?(VITAMINS_FILE)
    @@vitamins.merge!(VitaminExtractor.new(File.read(VITAMINS_FILE)).extract)
  end

  if block_given?
    @@vitamins.merge!(VitaminExtractor.new(&block).extract)
  end
end

Instance Method Details

#gem_with_vitamins(*args) ⇒ Object



20
21
22
# File 'lib/vitamined-gems.rb', line 20

def gem_with_vitamins(*args)
  args.empty? ? VitaminedGem.new(self, @@vitamins) : gem_without_vitamins(*args)
end