librarian-puppet 1.3.0 → 1.3.1

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: aea15d42f3f537214c5256248b821f12558b266f
4
- data.tar.gz: d0f110467f43c2f090bb8697988731f0020e32b2
3
+ metadata.gz: 292735ed218859976126f0a08ee529645f3a2805
4
+ data.tar.gz: f0a8b83aaf1d6f243b6c09580884ec4e33b6f96e
5
5
  SHA512:
6
- metadata.gz: 9b0df8f65615913ab73d48d03a8d29fc1753cf26009a96aaf821e49368d8fbbab1b51dd89c513f98644764dcda6bb84c826bb0b4e2bf3132f42964ce3de1aeb8
7
- data.tar.gz: 03ffefa4e42cabf289f754b24763d98a44f671f8198f89f27a39758703615e1c090259f9a1426c15d03bb1f2d3e30523b7c32562739c142abb336ba887689164
6
+ metadata.gz: 87a3a7d30bdb73d810bd15e681a197ef6960ab5f88203f1c8ca52c36b5293dd6bd5ea2c5bf30206805c628e65abe2050d4396b4089be99e230e4a225e30ecc60
7
+ data.tar.gz: dd981e980e3a32b42ed911181b448b986af2e48f88c29ab9eb6d3fb538f5c4daaa8bd3b12be450baa9291534b9a8ae1a185561ef63a9c4198578b7a66f18cd40
@@ -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://forgeapi.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.3.0"
3
+ VERSION = "1.3.1"
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.3.0
4
+ version: 1.3.1
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