markbates-gemtronics 0.4.0.20090819151952 → 0.4.1.20090820114612
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/grouper.rb +12 -0
- data/lib/gemtronics/manager.rb +35 -1
- metadata +2 -2
data/lib/gemtronics/grouper.rb
CHANGED
@@ -143,5 +143,17 @@ module Gemtronics
|
|
143
143
|
end
|
144
144
|
end
|
145
145
|
|
146
|
+
# Finds and returns a Gemtronics::Definition for the specified
|
147
|
+
# gem, if one exists.
|
148
|
+
#
|
149
|
+
# Example:
|
150
|
+
# Gemtronics.group(:test).search('gem1')
|
151
|
+
def search(name, options = {})
|
152
|
+
self.gems.each do |g|
|
153
|
+
return g if g.name == name
|
154
|
+
end
|
155
|
+
return nil
|
156
|
+
end
|
157
|
+
|
146
158
|
end # Grouper
|
147
159
|
end # Gemtronics
|
data/lib/gemtronics/manager.rb
CHANGED
@@ -13,7 +13,6 @@ module Gemtronics
|
|
13
13
|
|
14
14
|
def initialize # :nodoc:
|
15
15
|
reset!
|
16
|
-
self.installed_gems = []
|
17
16
|
end
|
18
17
|
|
19
18
|
# Creates, or reopens a new group of gems. It takes the name of the
|
@@ -155,6 +154,41 @@ module Gemtronics
|
|
155
154
|
|
156
155
|
def reset! # :nodoc:
|
157
156
|
self.groups = {}
|
157
|
+
self.installed_gems = []
|
158
|
+
end
|
159
|
+
|
160
|
+
# Finds and returns a Gemtronics::Definition for the specified
|
161
|
+
# gem, if one exists.
|
162
|
+
#
|
163
|
+
# Search Order:
|
164
|
+
# If the option <tt>:group</tt> is passed in it will search
|
165
|
+
# only within that group.
|
166
|
+
#
|
167
|
+
# If <tt>RAILS_ENV</tt> is defined it will search in the group
|
168
|
+
# that matches the current Rails environment
|
169
|
+
#
|
170
|
+
# Finally it will search all gems and return the first one it
|
171
|
+
# finds. There is no guarantee as to the order it searches through
|
172
|
+
# the groups.
|
173
|
+
#
|
174
|
+
# Gemtronics.find('gem1')
|
175
|
+
# Gemtronics.find('gem1', :group => :production)
|
176
|
+
def find(name, options = {})
|
177
|
+
group = options[:group]
|
178
|
+
if group
|
179
|
+
group = self.groups[group.to_sym]
|
180
|
+
return nil if group.nil?
|
181
|
+
gemdef = group.search(name, options)
|
182
|
+
return gemdef unless gemdef.nil?
|
183
|
+
elsif defined?(RAILS_ENV)
|
184
|
+
return find(name, {:group => RAILS_ENV.to_sym}.merge(options))
|
185
|
+
else
|
186
|
+
self.groups.each do |key, group|
|
187
|
+
gemdef = group.search(name, options)
|
188
|
+
return gemdef unless gemdef.nil?
|
189
|
+
end
|
190
|
+
end
|
191
|
+
raise "#{name} has not been defined!"
|
158
192
|
end
|
159
193
|
|
160
194
|
private
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: markbates-gemtronics
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1.20090820114612
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- markbates
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-08-
|
12
|
+
date: 2009-08-20 00:00:00 -07:00
|
13
13
|
default_executable: gemtronics
|
14
14
|
dependencies: []
|
15
15
|
|