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.
@@ -93,18 +93,29 @@ module Sprinkle
93
93
  #++
94
94
  module Package
95
95
  PACKAGES = {}
96
- VIRTUAL_PACKAGES = []
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 |dep|
294
- package = PACKAGES[dep]
295
- next unless package # skip missing optional packages as they're allow to not exist
296
- block.call(self, package, depth) if block
297
- packages << package.tree(depth + 1, &block)
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
 
@@ -2,7 +2,7 @@ module Sprinkle #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 0
5
- TINY = 15
5
+ TINY = 16
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
data/sprinkle.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = %q{sprinkle}
3
- s.version = "0.0.15"
3
+ s.version = "0.0.16"
4
4
 
5
5
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
6
6
  s.authors = ["Marcus Crafter", "Mitchell Hashimoto"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lachlan-sprinkle
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.15
4
+ version: 0.0.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcus Crafter