lachlan-sprinkle 0.0.15 → 0.0.16
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/sprinkle/package.rb +20 -7
- data/lib/sprinkle/version.rb +1 -1
- data/sprinkle.gemspec +1 -1
- metadata +1 -1
data/lib/sprinkle/package.rb
CHANGED
@@ -93,18 +93,29 @@ module Sprinkle
|
|
93
93
|
#++
|
94
94
|
module Package
|
95
95
|
PACKAGES = {}
|
96
|
-
|
96
|
+
|
97
|
+
# Keep a list of all the virtual packages defined, so if multiple packages are
|
98
|
+
# defined that provide this virtual package we can ask the user which they would
|
99
|
+
# like to install.
|
100
|
+
VIRTUAL_PACKAGES = []
|
97
101
|
|
98
102
|
def package(name, metadata = {}, &block)
|
99
103
|
package = Package.new(name, metadata, &block)
|
104
|
+
# there might be multiple versions of a package so append to the list
|
100
105
|
(PACKAGES[name] ||= []) << package
|
101
106
|
if package.provides
|
107
|
+
# there might be multiple providers so append to provider list and remember
|
108
|
+
# that this packages is virtual
|
102
109
|
(PACKAGES[package.provides] ||= []) << package
|
103
110
|
VIRTUAL_PACKAGES << package.provides
|
104
111
|
end
|
105
112
|
package
|
106
113
|
end
|
107
114
|
|
115
|
+
# Returns a list of packages with the given name. If multiple packages were
|
116
|
+
# defined with the same name (ie. different versions of the same software) then
|
117
|
+
# all versions are returned. If the given name identifies a virtual package then
|
118
|
+
# and there are multiple providers, then prompt the user to choose which to install.
|
108
119
|
def find(name)
|
109
120
|
packages = PACKAGES[name]
|
110
121
|
if packages and packages.length > 1 and VIRTUAL_PACKAGES.include? name
|
@@ -290,13 +301,15 @@ module Sprinkle
|
|
290
301
|
|
291
302
|
packages << self
|
292
303
|
|
293
|
-
@optional.each do |
|
294
|
-
|
295
|
-
next unless
|
296
|
-
|
297
|
-
|
304
|
+
@optional.each do |name|
|
305
|
+
list = find(name)
|
306
|
+
next unless list # skip missing optional packages as they're allowed to not exist
|
307
|
+
list.each { |package|
|
308
|
+
block.call(self, package, depth) if block
|
309
|
+
packages << package.tree(depth + 1, &block)
|
310
|
+
}
|
298
311
|
end
|
299
|
-
|
312
|
+
|
300
313
|
packages
|
301
314
|
end
|
302
315
|
|
data/lib/sprinkle/version.rb
CHANGED
data/sprinkle.gemspec
CHANGED