metadata-json-lint 0.0.1 → 0.0.2

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.
@@ -1,6 +1,12 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+
4
+ lib = File.expand_path('../../lib', __FILE__)
5
+ $:.unshift(lib) unless $:.include?(lib)
6
+
3
7
  require "json"
8
+ require "metadata_json_lint"
9
+ #require "MetadataJsonLint"
4
10
 
5
11
  if ARGV[0].nil?
6
12
  abort("Error: Must provide a metadata.json file to parse")
@@ -8,42 +14,4 @@ end
8
14
 
9
15
  metadata = ARGV[0]
10
16
 
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
17
+ MetadataJsonLint.parse(metadata)
@@ -0,0 +1,47 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ module MetadataJsonLint
4
+ def MetadataJsonLint.parse(metadata)
5
+
6
+ f = File.read(metadata)
7
+
8
+ begin
9
+ parsed = JSON.parse(f)
10
+ rescue
11
+ abort("Error: Unable to parse json. There is a syntax error somewhere.")
12
+ end
13
+
14
+ # Fields required to be in metadata.json
15
+ # From: https://docs.puppetlabs.com/puppet/latest/reference/modules_publishing.html#write-a-metadatajson-file
16
+ error_state = false
17
+
18
+ required_fields = [ "name", "version", "author", "license", "summary", "source", "dependencies" ]
19
+
20
+ required_fields.each do |field|
21
+ if parsed[field].nil?
22
+ puts "Error: Required field '#{field}' not found in metadata.json."
23
+ error_state = true
24
+ end
25
+ end
26
+
27
+
28
+
29
+ # Deprecated fields
30
+ # From: https://docs.puppetlabs.com/puppet/latest/reference/modules_publishing.html#write-a-metadatajson-file
31
+
32
+ deprecated_fields = ["types", "checksum"]
33
+
34
+ deprecated_fields.each do |field|
35
+ if not parsed[field].nil?
36
+ puts "Error: Deprecated field '#{field}' found in metadata.json."
37
+ error_state = true
38
+ end
39
+ end
40
+
41
+
42
+ if error_state
43
+ abort("Errors found in metadata.json")
44
+ end
45
+
46
+ end
47
+ end
metadata CHANGED
@@ -1,7 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metadata-json-lint
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Spencer Krum
@@ -19,28 +20,30 @@ extensions: []
19
20
  extra_rdoc_files: []
20
21
  files:
21
22
  - bin/metadata-json-lint
23
+ - lib/metadata_json_lint.rb
22
24
  homepage: http://github.com/nibalizer/metadata-json-lint.rb
23
25
  licenses:
24
26
  - Apache 2
25
- metadata: {}
26
27
  post_install_message:
27
28
  rdoc_options: []
28
29
  require_paths:
29
30
  - lib
30
31
  required_ruby_version: !ruby/object:Gem::Requirement
32
+ none: false
31
33
  requirements:
32
34
  - - ! '>='
33
35
  - !ruby/object:Gem::Version
34
36
  version: '0'
35
37
  required_rubygems_version: !ruby/object:Gem::Requirement
38
+ none: false
36
39
  requirements:
37
40
  - - ! '>='
38
41
  - !ruby/object:Gem::Version
39
42
  version: '0'
40
43
  requirements: []
41
44
  rubyforge_project:
42
- rubygems_version: 2.2.2
45
+ rubygems_version: 1.8.23
43
46
  signing_key:
44
- specification_version: 4
47
+ specification_version: 3
45
48
  summary: metadata-json-lint /path/to/metadata.json
46
49
  test_files: []
checksums.yaml DELETED
@@ -1,15 +0,0 @@
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=