markbates-gemtronics 0.4.1.20090820114612 → 0.4.5.20090820130250
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/gemtronics/definition.rb +22 -0
- data/lib/gemtronics/manager.rb +22 -5
- metadata +1 -1
@@ -68,6 +68,28 @@ module Gemtronics
|
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
71
|
+
# Calls the <tt>gem</tt> method with <tt>name</tt> and <tt>version</tt>.
|
72
|
+
# It does NOT do any requiring!
|
73
|
+
#
|
74
|
+
# Example:
|
75
|
+
# gd = Gemtronics::Definition.new
|
76
|
+
# gd.name = 'my_gem'
|
77
|
+
# gd.version = '1.2.3'
|
78
|
+
# gd.load_gem # => gem('my_gem', '1.2.3')
|
79
|
+
def load_gem
|
80
|
+
gem(self.name, self.version)
|
81
|
+
end
|
82
|
+
|
83
|
+
# Calls the <tt>load_gem</tt> method and then requires each
|
84
|
+
# file in the <tt>require_list</tt>
|
85
|
+
def require_gem(options = {})
|
86
|
+
load_gem
|
87
|
+
self.require_list.each do |f|
|
88
|
+
puts "require #{f}" if options[:verbose]
|
89
|
+
require f
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
71
93
|
private
|
72
94
|
def self.build_method(name, defval = nil, key = name) # :nodoc:
|
73
95
|
define_method(name) do
|
data/lib/gemtronics/manager.rb
CHANGED
@@ -100,11 +100,7 @@ module Gemtronics
|
|
100
100
|
options = {:verbose => false}.merge(options)
|
101
101
|
group.gems.each do |g|
|
102
102
|
if g.load? == true
|
103
|
-
|
104
|
-
g.require_list.each do |f|
|
105
|
-
puts "require #{f}" if options[:verbose]
|
106
|
-
require f
|
107
|
-
end
|
103
|
+
g.require_gem
|
108
104
|
end
|
109
105
|
end
|
110
106
|
end
|
@@ -191,6 +187,27 @@ module Gemtronics
|
|
191
187
|
raise "#{name} has not been defined!"
|
192
188
|
end
|
193
189
|
|
190
|
+
# Allows you to chain method calls together. An important note is
|
191
|
+
# that the <tt>*args</tt> are only passed into the first method in
|
192
|
+
# the chain.
|
193
|
+
#
|
194
|
+
# Example:
|
195
|
+
# Gemtronics.find_and_require_gem('gem1', :group => :production)
|
196
|
+
#
|
197
|
+
# This will call the <tt>find</tt> method on Gemtronics::Manager
|
198
|
+
# and pass it the arguments <tt>{:group => :production}</tt>. It will then
|
199
|
+
# call the <tt>require_gem</tt> method on the Gemtronics::Definition class
|
200
|
+
# returned by the <tt>find</tt> method.
|
201
|
+
def method_missing(sym, *args)
|
202
|
+
chain = sym.to_s.split('_and_')
|
203
|
+
raise NoMethodError.new(sym.to_s) if chain.nil? || chain.empty? || chain.size == 1
|
204
|
+
res = self.send(chain[0], *args)
|
205
|
+
chain[1..chain.size].each do |meth|
|
206
|
+
res = res.send(meth)
|
207
|
+
end
|
208
|
+
return res
|
209
|
+
end
|
210
|
+
|
194
211
|
private
|
195
212
|
def gem_installed?(gemdef) # :nodoc:
|
196
213
|
return true if self.installed_gems.include?(gemdef.to_s)
|