librarian-puppet 1.0.7 → 1.0.8

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: 010735fe88618f0ecd15edc880fa37086546d776
4
- data.tar.gz: fc6e6b124d06ef74f249b813486880649aee3dbd
3
+ metadata.gz: b67a1e452129a68f620fd106459e65a989214ad1
4
+ data.tar.gz: 37194dd860f12e353a03677ed2d5f0bc6c7e8504
5
5
  SHA512:
6
- metadata.gz: d65097488d97abe1ca30a251d62e02f3b3cebf0fb7ed1f594c7d98e3adec4e578dddf4e4ed5ffd73ee1627bf5eb4524097359e8777fb368f258fd0eb174bdef4
7
- data.tar.gz: 6ee5fc74eebe8a99f970affcfd53949fce28b3926bbd1c0d9bf740e5c24d4297c01e3679f72e4abec5e4076bcb4bed786124cc454fdd36debd3411eca0c3ed6d
6
+ metadata.gz: 60d6ae144ba0ca780d18f204685d00294fce51c318df54e314003b9cc4ac6455193c95818b66c67ccc2b8ada0a1588b6114ab4333ba9d032b6b32ffadacd5202
7
+ data.tar.gz: 7de4706904ec8a96ad482f61c1fdcca5ca619549ad2d0555841c1f803de7cffcbc73c64e2a5cac420f9d8242fa34a89007057712699a1f70772bc284f85eab23
@@ -96,7 +96,7 @@ module Librarian
96
96
  warn { "Replacing Puppet Forge API URL to use v3 #{module_repository} as required by your client version #{Librarian::Puppet.puppet_version}" }
97
97
  end
98
98
 
99
- m = module_repository.match(%r{^http(s)?://forgeapi\.puppetlabs\.com})
99
+ m = module_repository.match(%r{^http(s)?://forge(api)?\.puppetlabs\.com})
100
100
  if Forge.client_api_version() == 1 and m
101
101
  ssl = m[1]
102
102
  # Puppet 2.7 can't handle the 302 returned by the https url, so stick to http
@@ -37,41 +37,37 @@ module Librarian
37
37
  def fetch_dependencies(name, version, extra)
38
38
  dependencies = Set.new
39
39
 
40
- dependencyList = if metadata?
41
- JSON.parse(File.read(metadata))['dependencies']
42
- elsif modulefile?
43
- evaluate_modulefile(modulefile).dependencies.map do |dependency|
44
- {
45
- 'name' => dependency.instance_variable_get(:@full_module_name),
46
- 'version_requirement' => dependency.instance_variable_get(:@version_requirement)
47
- }
48
- end
49
- else []
50
- end
51
-
52
- dependencyList.each do |d|
53
- gem_requirement = Requirement.new(d['version_requirement']).gem_requirement
54
- dependencies << Dependency.new(d['name'], gem_requirement, forge_source)
55
- end
56
-
57
40
  if specfile?
58
41
  spec = environment.dsl(Pathname(specfile))
59
42
  dependencies.merge spec.dependencies
60
43
  end
61
44
 
45
+ parsed_metadata['dependencies'].each do |d|
46
+ gem_requirement = Requirement.new(d['version_requirement']).gem_requirement
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
52
+ end
53
+
62
54
  dependencies
63
55
  end
64
56
 
65
57
  def forge_source
66
- Forge.from_lock_options(environment, :remote=>"http://forge.puppetlabs.com")
58
+ Forge.from_lock_options(environment, :remote => "https://forge.puppetlabs.com")
67
59
  end
68
60
 
69
61
  private
70
62
 
71
63
  # Naming this method 'version' causes an exception to be raised.
72
64
  def module_version
73
- return '0.0.1' unless modulefile?
74
- evaluate_modulefile(modulefile).version
65
+ if parsed_metadata['version']
66
+ parsed_metadata['version']
67
+ else
68
+ warn { "Module #{to_s} does not have version, defaulting to 0.0.1" }
69
+ '0.0.1'
70
+ end
75
71
  end
76
72
 
77
73
  def require_puppet
@@ -106,6 +102,28 @@ module Librarian
106
102
  metadata
107
103
  end
108
104
 
105
+ def parsed_metadata
106
+ @metadata ||= if metadata?
107
+ JSON.parse(File.read(metadata))
108
+ elsif modulefile?
109
+ # translate Modulefile to metadata.json
110
+ evaluated = evaluate_modulefile(modulefile)
111
+ {
112
+ 'version' => evaluated.version,
113
+ 'dependencies' => evaluated.dependencies.map do |dependency|
114
+ {
115
+ 'name' => dependency.instance_variable_get(:@full_module_name),
116
+ 'version_requirement' => dependency.instance_variable_get(:@version_requirement)
117
+ }
118
+ end
119
+ }
120
+ else
121
+ warn { "Could not find metadata.json nor Modulefile at #{filesystem_path}" }
122
+ {}
123
+ end
124
+ @metadata
125
+ end
126
+
109
127
  def modulefile
110
128
  File.join(filesystem_path, 'Modulefile')
111
129
  end
@@ -1,5 +1,5 @@
1
1
  module Librarian
2
2
  module Puppet
3
- VERSION = "1.0.7"
3
+ VERSION = "1.0.8"
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: 1.0.7
4
+ version: 1.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Sharpe
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-08-03 00:00:00.000000000 Z
12
+ date: 2014-08-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: librarian