metadata_json_deps 0.3.0 → 0.4.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
  SHA256:
3
- metadata.gz: ad198e5c2c7b7de60e4a34f4a41515b427a1f7ef749b66326f299709fe409799
4
- data.tar.gz: e8a053d3b0579229b9f780e0f2287a57b76eab67efb6fbe5bea94c429e8c8b24
3
+ metadata.gz: 376a5a0f5181d0d6095b02fd5eb968c8acc887c8f85c1127c80d3fd622ed4a14
4
+ data.tar.gz: 2a8978e1c706f98b80a82c04e9bc4cb5721d72026ab7089b044d0981e1db16c7
5
5
  SHA512:
6
- metadata.gz: 58f9c3d25849c6c85b49c3387314a4b846a9c643d4d86bb98f78195e167916828e2a9cf70c435e03237e8b0e2e90c28f50dcfb05787f4f4b88a703b20fc2db9a
7
- data.tar.gz: 3d9fb9211f62d760e38cdaa597de86e53b1a8dea381389a5d4151ddade9c32c6cd1c0fdd2331bfcb94f8684e56996e620555b7a2b8c8a8ce6b5584ba5255eb56
6
+ metadata.gz: d7a981df5b61c4ff15f7f016ce4f90ad5045f47c3556db8d686c6cd5ada2eff218daa240507f73c071f249c255bae1c39073ba04a675bb4426158ca3f9b56b68
7
+ data.tar.gz: 28fabc4c9c1cfe758875314d137117a7c7b437d39f15e94b160469f2a7fade2a3a59eba9eaa39e4d5f71e054d9aa1df9b760f3c1a7a63db860fbb27d9c0dcdb4
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'optparse'
4
+ require 'metadata_json_deps'
5
+
6
+ parser = OptionParser.new do |opts|
7
+ opts.banner = "Usage: #{opts.program_name} metadata"
8
+ end
9
+
10
+ parser.parse!
11
+ if ARGV.empty?
12
+ puts parser.help
13
+ exit 1
14
+ end
15
+
16
+ MetadataJsonDeps.build_fixtures(ARGV.first)
@@ -5,9 +5,7 @@ require 'metadata_json_deps'
5
5
 
6
6
  options = {}
7
7
  OptionParser.new do |opts|
8
- opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
9
- options[:verbose] = v
10
- end
11
- end.parse!
8
+ opts.on("-v", "--[no-]verbose", "Run verbosely")
9
+ end.parse!(into: options)
12
10
 
13
11
  MetadataJsonDeps.run(ARGV, options[:verbose])
@@ -7,12 +7,34 @@ module MetadataJsonDeps
7
7
  @cache = cache
8
8
  end
9
9
 
10
- def get_current_version(name)
11
- name = name.sub('/', '-')
12
- @cache[name] ||= PuppetForge::Module.find(name).current_release.version
10
+ def get_module(name)
11
+ name = PuppetForge::V3.normalize_name(name)
12
+ @cache[name] ||= PuppetForge::Module.find(name)
13
13
  end
14
14
  end
15
15
 
16
+ def self.build_fixtures(filename)
17
+ require 'yaml'
18
+
19
+ result = {}
20
+
21
+ dependencies = PuppetMetadata.read(filename).dependencies
22
+ if dependencies.any?
23
+ forge = ForgeVersions.new
24
+
25
+ repositories = {}
26
+ result['fixtures'] = {'repositories' => repositories}
27
+
28
+ dependencies.each do |dependency, _constraint|
29
+ mod = forge.get_module(dependency)
30
+ # TODO: The forge should expose the source URL directly
31
+ repositories[mod.name] = mod.current_release.metadata[:source]
32
+ end
33
+ end
34
+
35
+ puts result.to_yaml
36
+ end
37
+
16
38
  def self.run(filenames, verbose = false)
17
39
  forge = ForgeVersions.new
18
40
 
@@ -21,14 +43,26 @@ module MetadataJsonDeps
21
43
  metadata = PuppetMetadata.read(filename)
22
44
 
23
45
  metadata.dependencies.map do |dependency, constraint|
24
- current = forge.get_current_version(dependency)
46
+ mod = forge.get_module(dependency)
25
47
 
26
- if metadata.satisfies_dependency?(dependency, current)
27
- if verbose
28
- puts " #{dependency} (#{constraint}) matches #{current}"
48
+ if mod.deprecated_at
49
+ if mod.superseded_by
50
+ puts " #{dependency} was superseded by #{mod.superseded_by[:slug]}"
51
+ elsif mod.deprecated_for
52
+ puts " #{dependency} was deprecated: #{mod.deprecated_for}"
53
+ else
54
+ puts " #{dependency} was deprecated"
29
55
  end
30
56
  else
31
- puts " #{dependency} (#{constraint}) doesn't match #{current}"
57
+ current = mod.current_release.version
58
+
59
+ if metadata.satisfies_dependency?(dependency, current)
60
+ if verbose
61
+ puts " #{dependency} (#{constraint}) matches #{current}"
62
+ end
63
+ else
64
+ puts " #{dependency} (#{constraint}) doesn't match #{current}"
65
+ end
32
66
  end
33
67
  end
34
68
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metadata_json_deps
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ewoud Kohl van Wijngaarden
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-08-13 00:00:00.000000000 Z
11
+ date: 2022-02-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: puppet_forge
@@ -50,9 +50,38 @@ dependencies:
50
50
  - - "<"
51
51
  - !ruby/object:Gem::Version
52
52
  version: '2'
53
+ - !ruby/object:Gem::Dependency
54
+ name: rspec
55
+ requirement: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - "~>"
58
+ - !ruby/object:Gem::Version
59
+ version: '3.0'
60
+ type: :development
61
+ prerelease: false
62
+ version_requirements: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - "~>"
65
+ - !ruby/object:Gem::Version
66
+ version: '3.0'
67
+ - !ruby/object:Gem::Dependency
68
+ name: rake
69
+ requirement: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - "~>"
72
+ - !ruby/object:Gem::Version
73
+ version: '13.0'
74
+ type: :development
75
+ prerelease: false
76
+ version_requirements: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - "~>"
79
+ - !ruby/object:Gem::Version
80
+ version: '13.0'
53
81
  description: Verify all your dependencies allow the latest versions on Puppet Forge
54
82
  email: ewoud+rubygems@kohlvanwijngaarden.nl
55
83
  executables:
84
+ - generate-fixtures-yaml
56
85
  - metadata-json-deps
57
86
  extensions: []
58
87
  extra_rdoc_files:
@@ -60,6 +89,7 @@ extra_rdoc_files:
60
89
  files:
61
90
  - LICENSE
62
91
  - README.md
92
+ - bin/generate-fixtures-yaml
63
93
  - bin/metadata-json-deps
64
94
  - lib/metadata_json_deps.rb
65
95
  homepage: https://github.com/ekohl/metadata_json_deps