Class: Bundler::Dsl

Inherits:
Object
  • Object
show all
Defined in:
lib/indexer/gemfile.rb

Overview

Mixin for Bundler::Dsl.

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(s, *a, &b) ⇒ Object

Evaluating on the Builder instance, allows Ruby basic metadata to be built via this method.



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/indexer/gemfile.rb', line 47

def method_missing(s, *a, &b)
  r = s.to_s.chomp('=')
  case a.size
  when 0
    if .respond_to?(s)
      return .__send__(s, &b)
    end
  when 1
    if .respond_to?("#{r}=")
      return .__send__("#{r}=", *a)
    end
  else
    if .respond_to?("#{r}=")
      return .__send__("#{r}=", a)
    end
  end

  _method_missing(s, *a, &b)
  #super(s, *a, &b)  # if cases don't match-up
end

Instance Method Details

#_method_missingObject



41
# File 'lib/indexer/gemfile.rb', line 41

alias :_method_missing :method_missing

#indexObject

Dynamically update a Gemfile from the .index file. Just call index from your Gemfile.

rubyfile

This is analogous to the Gemfile's gemspec method.



27
28
29
30
31
32
33
# File 'lib/indexer/gemfile.rb', line 27

def index
  spec = Indexer::Metadata.open
  spec.requirements.each do |req|
    next if req.external?
    gem(req.name, req.version, :group=>req.groups)
  end
end

#metadataObject



36
37
38
# File 'lib/indexer/gemfile.rb', line 36

def 
  @metadata ||= Indexer::Metadata.new
end