metadata-json-lint 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +15 -0
  2. data/bin/metadata-json-lint +49 -0
  3. metadata +46 -0
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ M2EzZThkOWJiNTk5MDJmMjBlZGEwMzdmZTRkOWMyYjcyMzBlZmJhOQ==
5
+ data.tar.gz: !binary |-
6
+ YTVkMGJlMDg5MzNhOTcxNmZkNmFmMTAxZDI0OTg0MDc4MDdiNjZhMg==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ MDg4Yjc1MGMxODEwOGU2MmNjMmU2NjI5YmUzMDYzZDhlZTg1YTFhYTdmZjM0
10
+ NGU1NzRhN2E0NjE3YzlkYjZjYzhjMDIxZDc3Y2IwZTMwNjg4OTM4MjdlZDcx
11
+ OTlhYmVmNGE3ZmUxMDViMjE3YTlmYzNjZTcyYzVhNGM1ODFmNTI=
12
+ data.tar.gz: !binary |-
13
+ ZGY2YTczOTAzMjI3ZGQxOWU1NTI3MmI5ZWU1ZjllNjI4OTZlOGUxZjNlYTcw
14
+ MjIyNjIyMjk2ZjVmYmFiYTY4NTJjMTUyNWVkMDBmNmY3ZWQ1OTU4Njk3YzZk
15
+ YWY0ZWE3YzI4NTgzN2JkNmFhNmFkNDg1ODczOTY3NTk3Y2IxNGY=
@@ -0,0 +1,49 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "json"
4
+
5
+ if ARGV[0].nil?
6
+ abort("Error: Must provide a metadata.json file to parse")
7
+ end
8
+
9
+ metadata = ARGV[0]
10
+
11
+ f = File.read(metadata)
12
+
13
+ begin
14
+ parsed = JSON.parse(f)
15
+ rescue
16
+ abort("Error: Unable to parse json. There is a syntax error somewhere.")
17
+ end
18
+
19
+ # Fields required to be in metadata.json
20
+ # From: https://docs.puppetlabs.com/puppet/latest/reference/modules_publishing.html#write-a-metadatajson-file
21
+ error_state = false
22
+
23
+ required_fields = [ "name", "version", "author", "license", "summary", "source", "dependencies" ]
24
+
25
+ required_fields.each do |field|
26
+ if parsed[field].nil?
27
+ puts "Error: Required field '#{field}' not found in metadata.json."
28
+ error_state = true
29
+ end
30
+ end
31
+
32
+
33
+
34
+ # Depricated fields
35
+ # From: https://docs.puppetlabs.com/puppet/latest/reference/modules_publishing.html#write-a-metadatajson-file
36
+
37
+ deprecated_fields = ["types", "checksum"]
38
+
39
+ deprecated_fields.each do |field|
40
+ if not parsed[field].nil?
41
+ puts "Error: Deprecated field '#{field}' found in metadata.json."
42
+ error_state = true
43
+ end
44
+ end
45
+
46
+
47
+ if error_state
48
+ abort("Errors found in metadata.json")
49
+ end
metadata ADDED
@@ -0,0 +1,46 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: metadata-json-lint
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Spencer Krum
8
+ - HP Development Corporation LP
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-10-06 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: Utility to verify Puppet metadata.json files
15
+ email: krum.spencer@gmail.com
16
+ executables:
17
+ - metadata-json-lint
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - bin/metadata-json-lint
22
+ homepage: http://github.com/nibalizer/metadata-json-lint.rb
23
+ licenses:
24
+ - Apache 2
25
+ metadata: {}
26
+ post_install_message:
27
+ rdoc_options: []
28
+ require_paths:
29
+ - lib
30
+ required_ruby_version: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ! '>='
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ required_rubygems_version: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ! '>='
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ requirements: []
41
+ rubyforge_project:
42
+ rubygems_version: 2.2.2
43
+ signing_key:
44
+ specification_version: 4
45
+ summary: metadata-json-lint /path/to/metadata.json
46
+ test_files: []