librarian-puppet 2.0.1 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2c4916fdcbc9dcfa3dcd3ce80abf048d41ba1a29
4
- data.tar.gz: 2de58a47da5361bb2f149c05ffd2b298f08c4fb9
3
+ metadata.gz: 0a7c6bf3dfb88d0d44e3c718e302167e04508fc2
4
+ data.tar.gz: d5affa81eab4acc5aff6b93ee39bfbe3e97a2e85
5
5
  SHA512:
6
- metadata.gz: 33e658e4b1a2513faf6bc4b3b9c3d0fa408b00e500735ee54d14f03578350f15dd829d54538ee4597d724b8645713c131c54f93bc601828e104a22886e9c0924
7
- data.tar.gz: f1cfaacbdff4df3e3842611a49eb359f27281845f064fac2208772613000d488c1b59250295d9165b55558c34233cedd8263aab0edfef60fa182c3e46972f566
6
+ metadata.gz: d4de7b61cffafdc51b4e46bcf7c42fd88da267620804ce52f6c55e85724e0993f71756720530ce47a7535122f13158cc5baba38485f9ccd5dc8c0c138bacb437
7
+ data.tar.gz: 743f2f84ad57d0041656e28824e59e906fdc5ab717d866ca09f151c1f1ca22fadf45acb49317f0c48bd69ac28196d71d5858aa271672fcef7491f856ffa89b95
data/README.md CHANGED
@@ -13,6 +13,7 @@ Git repositories or just a path.
13
13
  * Forge modules can be installed from [Puppetlabs Forge](https://forge.puppetlabs.com/) or an internal Forge such as [Pulp](http://www.pulpproject.org/)
14
14
  * Git modules can be installed from a branch, tag or specific commit, optionally using a path inside the repository
15
15
  * Modules can be installed from GitHub using tarballs, without needing Git installed
16
+ * Modules can be installed from a filesystem path
16
17
  * Module dependencies are resolved transitively without needing to list all the modules explicitly
17
18
 
18
19
 
@@ -69,6 +70,10 @@ as if the Puppetfile contained
69
70
  mod 'puppetlabs-apache', '0.6.0',
70
71
  :github_tarball => 'puppetlabs/puppetlabs-apache'
71
72
 
73
+ mod 'acme-mymodule', :path => './some_folder'
74
+
75
+ exclusion 'acme-bad_module'
76
+
72
77
 
73
78
  ### Recursive module dependency resolution
74
79
 
@@ -134,6 +139,21 @@ module subdirectory.
134
139
  Our puppet infrastructure repository depends on the `apt` module, which we have
135
140
  stored as a directory under our `puppet-modules` git repos.
136
141
 
142
+ mod 'puppetlabs-apache', '0.6.0',
143
+ :github_tarball => 'puppetlabs/puppetlabs-apache'
144
+
145
+ Our puppet infrastructure repository depends on the `puppetlabs-apache` module,
146
+ to be downloaded from GitHub tarball.
147
+
148
+ mod 'acme-mymodule', :path => './some_folder'
149
+
150
+ Our puppet infrastructure repository depends on the `acme-mymodule` module,
151
+ which is already in the filesystem.
152
+
153
+ exclusion 'acme-bad_module'
154
+
155
+ Exclude the module `acme-bad_module` from resolution and installation.
156
+
137
157
  ## How to Use
138
158
 
139
159
  Install librarian-puppet:
@@ -1 +1,2 @@
1
1
  require "librarian/puppet/action/install"
2
+ require "librarian/puppet/action/resolve"
@@ -0,0 +1,19 @@
1
+ module Librarian
2
+ module Puppet
3
+ module Action
4
+ class Resolve < Librarian::Action::Resolve
5
+ include Librarian::Puppet::Util
6
+
7
+ def run
8
+ super
9
+ manifests = environment.lock.manifests.select{ |m| m.name }
10
+ dupes = manifests.group_by{ |m| module_name(m.name) }.select { |k, v| v.size > 1 }
11
+ dupes.each do |k,v|
12
+ warn("Dependency on module '#{k}' is fullfilled by multiple modules and only one will be used: #{v.map{|m|m.name}}")
13
+ end
14
+ end
15
+
16
+ end
17
+ end
18
+ end
19
+ end
@@ -7,6 +7,7 @@ require 'librarian/puppet/action'
7
7
  module Librarian
8
8
  module Puppet
9
9
  class Cli < Librarian::Cli
10
+ include Librarian::Puppet::Util
10
11
 
11
12
  module Particularity
12
13
  def root_module
@@ -69,6 +70,12 @@ module Librarian
69
70
  install!
70
71
  end
71
72
 
73
+ # only used to replace / to - in the module names
74
+ def update(*names)
75
+ warn("Usage of module/name is deprecated, use module-name") if names.any? {|n| n.include?("/")}
76
+ super(*names.map{|n| normalize_name(n)})
77
+ end
78
+
72
79
  desc "package", "Cache the puppet modules in vendor/puppet/cache."
73
80
  option "quiet", :type => :boolean, :default => false
74
81
  option "verbose", :type => :boolean, :default => false
@@ -93,6 +100,9 @@ module Librarian
93
100
  def install!(options = { })
94
101
  Action::Install.new(environment, options).run
95
102
  end
103
+ def resolve!(options = { })
104
+ Action::Resolve.new(environment, options).run
105
+ end
96
106
  end
97
107
  end
98
108
  end
@@ -0,0 +1,18 @@
1
+ module Librarian
2
+ module Puppet
3
+
4
+ class Dependency < Librarian::Dependency
5
+
6
+ include Librarian::Puppet::Util
7
+
8
+ def initialize(name, requirement, source)
9
+ # Issue #235 fail if forge source is not defined
10
+ raise Error, "forge entry is not defined in Puppetfile" if source.instance_of?(Array) && source.empty?
11
+
12
+ super(normalize_name(name), requirement, source)
13
+ end
14
+
15
+ end
16
+
17
+ end
18
+ end
@@ -1,6 +1,7 @@
1
1
  require 'librarian/dsl'
2
2
  require 'librarian/dsl/target'
3
3
  require 'librarian/puppet/source'
4
+ require 'librarian/puppet/dependency'
4
5
 
5
6
  module Librarian
6
7
  module Puppet
@@ -15,32 +16,25 @@ module Librarian
15
16
  source :path => Source::Path
16
17
  source :github_tarball => Source::GitHubTarball
17
18
 
18
- # copied from Librarian::Dsl to use our own Receiver
19
- def run(specfile = nil, sources = [])
20
- specfile, sources = nil, specfile if specfile.kind_of?(Array) && sources.empty?
21
-
22
- if specfile.kind_of?(Pathname) and !File.exists?(specfile)
23
- debug { "Specfile not found, using defaults: #{specfile}" }
24
- specfile = Proc.new do
25
- forge FORGE_URL
26
- metadata
27
- end
19
+ def default_specfile
20
+ Proc.new do
21
+ forge FORGE_URL
22
+ metadata
28
23
  end
24
+ end
29
25
 
30
- Target.new(self).tap do |target|
31
- target.precache_sources(sources)
32
- debug_named_source_cache("Pre-Cached Sources", target)
33
-
34
- specfile ||= Proc.new if block_given?
35
- receiver = Receiver.new(target)
36
- receiver.run(specfile)
26
+ def self.dependency_type
27
+ Librarian::Puppet::Dependency
28
+ end
37
29
 
38
- # save the default forge defined
39
- default_forge = target.sources.select {|s| s.is_a? Librarian::Puppet::Source::Forge}.first
40
- Librarian::Puppet::Source::Forge.default = default_forge || Librarian::Puppet::Source::Forge.from_lock_options(environment, :remote => FORGE_URL)
30
+ def post_process_target(target)
31
+ # save the default forge defined
32
+ default_forge = target.sources.select {|s| s.is_a? Librarian::Puppet::Source::Forge}.first
33
+ Librarian::Puppet::Source::Forge.default = default_forge || Librarian::Puppet::Source::Forge.from_lock_options(environment, :remote => FORGE_URL)
34
+ end
41
35
 
42
- debug_named_source_cache("Post-Cached Sources", target)
43
- end.to_spec
36
+ def receiver(target)
37
+ Receiver.new(target)
44
38
  end
45
39
 
46
40
  class Receiver < Librarian::Dsl::Receiver
@@ -1,7 +1,7 @@
1
1
  require "librarian/environment"
2
2
  require "librarian/puppet/dsl"
3
3
  require "librarian/puppet/source"
4
- require "librarian/puppet/lockfile/parser"
4
+ require "librarian/puppet/lockfile"
5
5
 
6
6
  module Librarian
7
7
  module Puppet
@@ -11,6 +11,14 @@ module Librarian
11
11
  "puppet"
12
12
  end
13
13
 
14
+ def lockfile
15
+ Lockfile.new(self, lockfile_path)
16
+ end
17
+
18
+ def ephemeral_lockfile
19
+ Lockfile.new(self, nil)
20
+ end
21
+
14
22
  def tmp_path
15
23
  part = config_db["tmp"] || ".tmp"
16
24
  project_path.join(part)
@@ -6,224 +6,4 @@ module Librarian
6
6
  extend self
7
7
  extend Librarian
8
8
  end
9
-
10
- class Dependency
11
- include Librarian::Puppet::Util
12
-
13
- def initialize(name, requirement, source)
14
- assert_name_valid! name
15
-
16
- # Issue #235 fail if forge source is not defined
17
- raise Error, "forge entry is not defined in Puppetfile" if source.instance_of?(Array) && source.empty?
18
-
19
- # let's settle on provider-module syntax instead of provider/module
20
- self.name = normalize_name(name)
21
- self.requirement = Requirement.new(requirement)
22
- self.source = source
23
-
24
- @manifests = nil
25
- end
26
-
27
- class Requirement
28
- def initialize(*args)
29
- args = initialize_normalize_args(args)
30
- self.backing = Gem::Requirement.create(puppet_to_gem_versions(args))
31
- end
32
-
33
- def puppet_to_gem_versions(args)
34
- args.map do |arg|
35
- case arg
36
- when Array
37
- arg.map { |v| Librarian::Puppet::Requirement.new(v).gem_requirement }
38
- when String
39
- Librarian::Puppet::Requirement.new(arg).gem_requirement
40
- else
41
- # Gem::Requirement, convert to string (ie. =1.0) so we can concat later
42
- # Gem::Requirements can not be concatenated
43
- arg.requirements.map{|x,y| "#{x}#{y}"}
44
- end
45
- end.flatten
46
- end
47
- end
48
-
49
- alias :eql? :==
50
-
51
- def hash
52
- self.to_s.hash
53
- end
54
- end
55
-
56
- # Fixes for librarian not yet released in their gem
57
- module Mock
58
- module Source
59
- class Mock
60
- alias :eql? :==
61
-
62
- def hash
63
- self.to_s.hash
64
- end
65
- end
66
- end
67
- end
68
- module Source
69
- class Git
70
- alias :eql? :==
71
-
72
- def hash
73
- self.to_s.hash
74
- end
75
- end
76
-
77
- class Path
78
- alias :eql? :==
79
-
80
- def hash
81
- self.to_s.hash
82
- end
83
- end
84
- end
85
-
86
- class ManifestSet
87
- include Librarian::Puppet::Util
88
-
89
- private
90
-
91
- # Check if module doesn't exist and fail fast
92
- def dependencies_of(names)
93
- names = Array === names ? names.dup : names.to_a
94
- assert_strings!(names)
95
-
96
- deps = Set.new
97
- until names.empty?
98
- name = normalize_name(names.shift)
99
- next if deps.include?(name)
100
-
101
- deps << name
102
- raise(Error, "Unable to find module #{name}. Your Puppetfile may be out of sync with the lock, try running 'librarian-puppet install' first") if index[name].nil?
103
- names.concat index[name].dependencies.map(&:name)
104
- end
105
- deps.to_a
106
- end
107
- end
108
-
109
- class Manifest
110
- class PreReleaseVersion
111
-
112
- # Compares pre-release component ids using Semver 2.0.0 spec
113
- def self.compare_components(this_id,other_id)
114
- case # Strings have higher precedence than numbers
115
- when (this_id.is_a?(Integer) and other_id.is_a?(String))
116
- -1
117
- when (this_id.is_a?(String) and other_id.is_a?(Integer))
118
- 1
119
- else
120
- this_id <=> other_id
121
- end
122
- end
123
-
124
- # Parses pre-release components `a.b.c` into an array ``[a,b,c]`
125
- # Converts numeric components into +Integer+
126
- def self.parse(prerelease)
127
- if prerelease.nil?
128
- []
129
- else
130
- prerelease.split('.').collect do |id|
131
- id = Integer(id) if /^[0-9]+$/ =~ id
132
- id
133
- end
134
- end
135
- end
136
-
137
- include Comparable
138
-
139
- attr_reader :components
140
-
141
- def initialize(prerelease)
142
- @prerelease = prerelease
143
- @components = PreReleaseVersion.parse(prerelease)
144
- end
145
-
146
- def to_s
147
- @prerelease
148
- end
149
-
150
- def <=>(other)
151
- # null-fill zip array to prevent loss of components
152
- z = Array.new([components.length,other.components.length])
153
-
154
- # Compare each component against the other
155
- comp = z.zip(components,other.components).collect do |ids|
156
- case # All components being equal, the version with more of them takes precedence
157
- when ids[1].nil? # Self has less elements, other wins
158
- -1
159
- when ids[2].nil? # Other has less elements, self wins
160
- 1
161
- else
162
- PreReleaseVersion.compare_components(ids[1],ids[2])
163
- end
164
- end
165
- # Chose the first non-zero comparison or return 0
166
- comp.delete_if {|c| c == 0}[0] || 0
167
- end
168
- end
169
- class Version
170
- @@SEMANTIC_VERSION_PATTERN = /^([0-9]+\.[0-9]+(?:\.[0-9]+)?)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?$/
171
- def self.parse_semver(version_string)
172
- parsed = @@SEMANTIC_VERSION_PATTERN.match(version_string.strip)
173
- if parsed
174
- {
175
- :full_version => parsed[0],
176
- :version => parsed[1],
177
- :prerelease => (PreReleaseVersion.new(parsed[2]) if parsed[2]),
178
- :build => parsed[3]
179
- }
180
- end
181
- end
182
-
183
- attr_reader :prerelease
184
-
185
- def initialize(*args)
186
- args = initialize_normalize_args(args)
187
- semver = Version.parse_semver(*args)
188
- if semver
189
- self.backing = Gem::Version.new(semver[:version])
190
- @prerelease = semver[:prerelease]
191
- @full_version = semver[:full_version]
192
- else
193
- self.backing = Gem::Version.new(*args)
194
- @full_version = to_gem_version.to_s
195
- end
196
- end
197
-
198
- def <=>(other)
199
- cmp = to_gem_version <=> other.to_gem_version
200
-
201
- # Should compare pre-release versions?
202
- if cmp == 0 and not (prerelease.nil? and other.prerelease.nil?)
203
- case # Versions without prerelease take precedence
204
- when (prerelease.nil? and not other.prerelease.nil?)
205
- 1
206
- when (not prerelease.nil? and other.prerelease.nil?)
207
- -1
208
- else
209
- prerelease <=> other.prerelease
210
- end
211
- else
212
- cmp
213
- end
214
- end
215
-
216
- def to_s
217
- @full_version
218
- end
219
- end
220
- end
221
-
222
- class Logger
223
- def warn(string = nil, &block)
224
- return unless ui
225
-
226
- ui.warn(string || yield)
227
- end
228
- end
229
9
  end
@@ -0,0 +1,39 @@
1
+ # Extend Lockfile to normalize module names from acme/mod to acme-mod
2
+ module Librarian
3
+ module Puppet
4
+ class Lockfile < Librarian::Lockfile
5
+
6
+ # Extend the parser to normalize module names in old .lock files, converting / to -
7
+ class Parser < Librarian::Lockfile::Parser
8
+
9
+ include Librarian::Puppet::Util
10
+
11
+ def extract_and_parse_sources(lines)
12
+ sources = super
13
+ sources.each do |source|
14
+ source[:manifests] = Hash[source[:manifests].map do |name,manifest|
15
+ [normalize_name(name), manifest]
16
+ end]
17
+ end
18
+ sources
19
+ end
20
+
21
+ def extract_and_parse_dependencies(lines, manifests_index)
22
+ # when looking up in manifests_index normalize the name beforehand
23
+ class << manifests_index
24
+ include Librarian::Puppet::Util
25
+ alias_method :old_lookup, :[]
26
+ define_method(:[]) { |k| self.old_lookup(normalize_name(k)) }
27
+ end
28
+ super(lines, manifests_index)
29
+ end
30
+
31
+ end
32
+
33
+ def load(string)
34
+ Parser.new(environment).parse(string)
35
+ end
36
+
37
+ end
38
+ end
39
+ end
@@ -1,4 +1,3 @@
1
- require 'librarian/puppet/requirement'
2
1
  require 'librarian/puppet/source/path'
3
2
  require 'librarian/puppet/source/git'
4
3
  require 'librarian/puppet/source/forge'
@@ -143,7 +143,7 @@ module Librarian
143
143
 
144
144
  def fetch_dependencies(name, version, version_uri)
145
145
  repo(name).dependencies(version).map do |k, v|
146
- v = Requirement.new(v).gem_requirement
146
+ v = Librarian::Dependency::Requirement.new(v).to_gem_requirement
147
147
  Dependency.new(k, v, nil)
148
148
  end
149
149
  end
@@ -33,30 +33,9 @@ module Librarian
33
33
 
34
34
  private
35
35
 
36
- # Issue #223 dependencies may be duplicated
37
- # and convert organization/modulename to organization-modulename
38
- def clear_duplicated_dependencies(data)
36
+ # convert organization/modulename to organization-modulename
37
+ def normalize_dependencies(data)
39
38
  return nil if data.nil?
40
- data.each do |m,versions|
41
- versions.each do |v|
42
- if v["dependencies"] and !v["dependencies"].empty?
43
- # convert organization/modulename to organization-modulename
44
- v["dependencies"].each {|d| d[0] = normalize_name(d[0])}
45
-
46
- dependency_names = v["dependencies"].map {|d| d[0]}
47
- duplicated = dependency_names.select{ |e| dependency_names.count(e) > 1 }
48
- unless duplicated.empty?
49
- duplicated.uniq.each do |module_duplicated|
50
- to_remove = []
51
- v["dependencies"].each_index{|i| to_remove << i if module_duplicated == v["dependencies"][i][0]}
52
- warn { "Module #{m}@#{v["version"]} contains duplicated dependencies for #{module_duplicated}, ignoring all but the first of #{to_remove.map {|i| v["dependencies"][i]}}" }
53
- to_remove.slice(1..-1).reverse.each {|i| v["dependencies"].delete_at(i) }
54
- v["dependencies"] = v["dependencies"] - to_remove.slice(1..-1)
55
- end
56
- end
57
- end
58
- end
59
- end
60
39
  # convert organization/modulename to organization-modulename
61
40
  data.keys.each do |m|
62
41
  if m =~ %r{.*/.*}
@@ -71,7 +50,7 @@ module Librarian
71
50
  def api_data(module_name)
72
51
  return @api_data[module_name] if @api_data
73
52
  # call API and cache data
74
- @api_data = clear_duplicated_dependencies(api_call(module_name))
53
+ @api_data = normalize_dependencies(api_call(module_name))
75
54
  if @api_data.nil?
76
55
  raise Error, "Unable to find module '#{name}' on #{source}"
77
56
  end
@@ -83,7 +62,7 @@ module Librarian
83
62
  # if we already got all the versions, find in cached data
84
63
  return @api_data[module_name].detect{|x| x['version'] == version.to_s} if @api_data
85
64
  # otherwise call the api for this version if not cached already
86
- @api_version_data[version] = clear_duplicated_dependencies(api_call(name, version)) if @api_version_data[version].nil?
65
+ @api_version_data[version] = normalize_dependencies(api_call(name, version)) if @api_version_data[version].nil?
87
66
  @api_version_data[version]
88
67
  end
89
68
 
@@ -43,12 +43,9 @@ module Librarian
43
43
  end
44
44
 
45
45
  parsed_metadata['dependencies'].each do |d|
46
- gem_requirement = Requirement.new(d['version_requirement']).gem_requirement
46
+ gem_requirement = Librarian::Dependency::Requirement.new(d['version_requirement']).to_gem_requirement
47
47
  new_dependency = Dependency.new(d['name'], gem_requirement, forge_source)
48
- # Avoid duplicated dependencies with different sources
49
- unless dependencies.find { |spec_dependency| spec_dependency.name == new_dependency.name && spec_dependency.requirement == new_dependency.requirement }
50
- dependencies << new_dependency
51
- end
48
+ dependencies << new_dependency
52
49
  end
53
50
 
54
51
  dependencies
@@ -1,5 +1,5 @@
1
1
  module Librarian
2
2
  module Puppet
3
- VERSION = "2.0.1"
3
+ VERSION = "2.1.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: librarian-puppet
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Sharpe
@@ -9,22 +9,22 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-12-04 00:00:00.000000000 Z
12
+ date: 2015-03-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: librarian
15
+ name: librarianp
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
18
  - - ">="
19
19
  - !ruby/object:Gem::Version
20
- version: 0.1.2
20
+ version: 0.5.1
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - ">="
26
26
  - !ruby/object:Gem::Version
27
- version: 0.1.2
27
+ version: 0.5.1
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: rsync
30
30
  requirement: !ruby/object:Gem::Requirement
@@ -184,12 +184,13 @@ files:
184
184
  - lib/librarian/puppet.rb
185
185
  - lib/librarian/puppet/action.rb
186
186
  - lib/librarian/puppet/action/install.rb
187
+ - lib/librarian/puppet/action/resolve.rb
187
188
  - lib/librarian/puppet/cli.rb
189
+ - lib/librarian/puppet/dependency.rb
188
190
  - lib/librarian/puppet/dsl.rb
189
191
  - lib/librarian/puppet/environment.rb
190
192
  - lib/librarian/puppet/extension.rb
191
- - lib/librarian/puppet/lockfile/parser.rb
192
- - lib/librarian/puppet/requirement.rb
193
+ - lib/librarian/puppet/lockfile.rb
193
194
  - lib/librarian/puppet/source.rb
194
195
  - lib/librarian/puppet/source/forge.rb
195
196
  - lib/librarian/puppet/source/forge/repo.rb
@@ -224,7 +225,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
224
225
  version: '0'
225
226
  requirements: []
226
227
  rubyforge_project:
227
- rubygems_version: 2.2.0
228
+ rubygems_version: 2.4.3
228
229
  signing_key:
229
230
  specification_version: 4
230
231
  summary: Bundler for your Puppet modules
@@ -1,55 +0,0 @@
1
- require 'librarian/manifest'
2
- require 'librarian/dependency'
3
- require 'librarian/manifest_set'
4
-
5
- module Librarian
6
- class Lockfile
7
- class Parser
8
- include Librarian::Puppet::Util
9
-
10
- def parse(string)
11
- string = string.dup
12
- source_type_names_map = Hash[dsl_class.source_types.map{|t| [t[1].lock_name, t[1]]}]
13
- source_type_names = dsl_class.source_types.map{|t| t[1].lock_name}
14
- lines = string.split(/(\r|\n|\r\n)+/).select{|l| l =~ /\S/}
15
- sources = []
16
- while source_type_names.include?(lines.first)
17
- source = {}
18
- source_type_name = lines.shift
19
- source[:type] = source_type_names_map[source_type_name]
20
- options = {}
21
- while lines.first =~ /^ {2}([\w\-\/]+):\s+(.+)$/
22
- lines.shift
23
- options[$1.to_sym] = $2
24
- end
25
- source[:options] = options
26
- lines.shift # specs
27
- manifests = {}
28
- while lines.first =~ /^ {4}([\w\-\/]+) \((.*)\)$/ # This change allows forward slash
29
- lines.shift
30
- name, version = normalize_name($1), $2
31
- manifests[name] = {:version => version, :dependencies => {}}
32
- while lines.first =~ /^ {6}([\w\-\/]+) \((.*)\)$/
33
- lines.shift
34
- manifests[name][:dependencies][$1] = $2.split(/,\s*/)
35
- end
36
- end
37
- source[:manifests] = manifests
38
- sources << source
39
- end
40
- manifests = compile(sources)
41
- manifests_index = Hash[manifests.map{|m| [m.name, m]}]
42
- raise StandardError, "Expected DEPENDENCIES topic!" unless lines.shift == "DEPENDENCIES"
43
- dependencies = []
44
- while lines.first =~ /^ {2}([\w\-\/]+)(?: \((.*)\))?$/ # This change allows forward slash
45
- lines.shift
46
- name, requirement = normalize_name($1), $2.split(/,\s*/)
47
- dependencies << Dependency.new(name, requirement, manifests_index[name].source)
48
- end
49
-
50
- Resolution.new(dependencies, manifests)
51
- end
52
-
53
- end
54
- end
55
- end
@@ -1,35 +0,0 @@
1
- module Librarian
2
- module Puppet
3
- class Requirement
4
- attr_reader :requirement
5
-
6
- def initialize(requirement)
7
- @requirement = requirement || ">=0"
8
- end
9
-
10
- def gem_requirement
11
- if range_requirement?
12
- [@range_match[1], @range_match[2]]
13
- elsif pessimistic_requirement?
14
- "~> #{@pessimistic_match[1]}.0"
15
- else
16
- requirement
17
- end
18
- end
19
-
20
- def to_s
21
- gem_requirement.to_s
22
- end
23
-
24
- private
25
-
26
- def range_requirement?
27
- @range_match ||= requirement.match(/(>=? ?\d+(?:\.\d+){0,2}) (<=? ?\d+(?:\.\d+){0,2})/)
28
- end
29
-
30
- def pessimistic_requirement?
31
- @pessimistic_match ||= requirement.match(/(\d+(?:\.\d+)?)\.x/)
32
- end
33
- end
34
- end
35
- end