Class: GemSuit::Application::Utils::Gemfile

Inherits:
Object
  • Object
show all
Defined in:
lib/gem_suit/application/utils/gemfile.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*files) ⇒ Gemfile

Returns a new instance of Gemfile.



10
11
12
# File 'lib/gem_suit/application/utils/gemfile.rb', line 10

def initialize(*files)
  @files = files
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args) ⇒ Object



34
35
36
37
# File 'lib/gem_suit/application/utils/gemfile.rb', line 34

def method_missing(method, *args)
  # e.g. group :test do
  # end
end

Instance Attribute Details

#source(src) ⇒ Object

A simple class which derives a Gemfile



8
9
10
# File 'lib/gem_suit/application/utils/gemfile.rb', line 8

def source
  @source
end

Instance Method Details

#gem(name, *args) ⇒ Object



28
29
30
31
32
# File 'lib/gem_suit/application/utils/gemfile.rb', line 28

def gem(name, *args)
  options = (args.pop if args.last.is_a?(Hash)) || {}
  options[:version] = args.first if args.first.is_a?(String)
  @gems[name] = options
end

#gemsObject



14
15
16
17
18
19
20
21
22
# File 'lib/gem_suit/application/utils/gemfile.rb', line 14

def gems
  @gems ||= begin
    @gems     = {}
    gem_file  = @files.detect{|file| File.exists? file}
    gem_specs = File.readlines(gem_file).join "\n"
    instance_eval gem_specs
    gems
  end
end