prmd 0.10.0 → 0.11.0
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.
- checksums.yaml +4 -4
- data/lib/prmd/cli/doc.rb +3 -3
- data/lib/prmd/cli/render.rb +6 -3
- data/lib/prmd/cli/verify.rb +5 -1
- data/lib/prmd/commands/verify.rb +13 -7
- data/lib/prmd/link.rb +1 -1
- data/lib/prmd/templates/schemata/link_curl_example.md.erb +1 -1
- data/lib/prmd/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b6c1c60fbfffb354907c790aa138cf4cf32d3e8f
|
4
|
+
data.tar.gz: 39a28c6f1b00bf1099f25c50bac8dc629b781073
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3bde164e0084e1e6a0bc736b6620b67bff6d7099888fd0031a5074f15fd82d58f41e83f6d9c695ea6438f9a91fd2ae311417afeb333f9ec2c8391ace10a5aa57
|
7
|
+
data.tar.gz: a76bdc4c776a3e90127401c14efdb827f1db7cb6c1c89c2217532f9b199c120d87f4f33fdcdef24d0019d2656c28379b3f3e3472eb3fdafe3ef78eb96668d048
|
data/lib/prmd/cli/doc.rb
CHANGED
@@ -22,15 +22,15 @@ module Prmd
|
|
22
22
|
options = HashHelpers.deep_symbolize_keys(settings)
|
23
23
|
yield :settings, options
|
24
24
|
end
|
25
|
-
opts.on('-p', '--prepend header,overview', Array, 'Prepend files to output') do |p|
|
26
|
-
yield :prepend, p
|
27
|
-
end
|
28
25
|
opts.on('-c', '--content-type application/json', String, 'Content-Type header') do |c|
|
29
26
|
yield :content_type, c
|
30
27
|
end
|
31
28
|
opts.on('-o', '--output-file FILENAME', String, 'File to write result to') do |n|
|
32
29
|
yield :output_file, n
|
33
30
|
end
|
31
|
+
opts.on('-p', '--prepend header,overview', Array, 'Prepend files to output') do |p|
|
32
|
+
yield :prepend, p
|
33
|
+
end
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
data/lib/prmd/cli/render.rb
CHANGED
@@ -16,15 +16,18 @@ module Prmd
|
|
16
16
|
|
17
17
|
OptionParser.new do |opts|
|
18
18
|
opts.banner = "#{binname} render [options] <combined schema>"
|
19
|
+
opts.on('-c', '--content-type application/json', String, 'Content-Type header') do |c|
|
20
|
+
yield :content_type, c
|
21
|
+
end
|
22
|
+
opts.on('-o', '--output-file FILENAME', String, 'File to write result to') do |n|
|
23
|
+
yield :output_file, n
|
24
|
+
end
|
19
25
|
opts.on('-p', '--prepend header,overview', Array, 'Prepend files to output') do |p|
|
20
26
|
yield :prepend, p
|
21
27
|
end
|
22
28
|
opts.on('-t', '--template templates', String, 'Use alternate template') do |t|
|
23
29
|
yield :template, t
|
24
30
|
end
|
25
|
-
opts.on('-o', '--output-file FILENAME', String, 'File to write result to') do |n|
|
26
|
-
yield :output_file, n
|
27
|
-
end
|
28
31
|
end
|
29
32
|
end
|
30
33
|
|
data/lib/prmd/cli/verify.rb
CHANGED
@@ -22,6 +22,9 @@ module Prmd
|
|
22
22
|
opts.on('-o', '--output-file FILENAME', String, 'File to write result to') do |n|
|
23
23
|
yield :output_file, n
|
24
24
|
end
|
25
|
+
opts.on('-s', '--custom-schema FILENAME', String, 'Path to custom schema') do |n|
|
26
|
+
yield :custom_schema, n
|
27
|
+
end
|
25
28
|
end
|
26
29
|
end
|
27
30
|
|
@@ -35,7 +38,8 @@ module Prmd
|
|
35
38
|
def self.execute(options = {})
|
36
39
|
filename = options.fetch(:argv).first
|
37
40
|
_, data = try_read(filename)
|
38
|
-
|
41
|
+
custom_schema = options[:custom_schema]
|
42
|
+
errors = Prmd.verify(data, custom_schema: custom_schema)
|
39
43
|
unless errors.empty?
|
40
44
|
errors.map! { |error| "#{filename}: #{error}" } if filename
|
41
45
|
errors.each { |error| $stderr.puts(error) }
|
data/lib/prmd/commands/verify.rb
CHANGED
@@ -18,14 +18,19 @@ module Prmd
|
|
18
18
|
store = JsonSchema::DocumentStore.new
|
19
19
|
SCHEMAS.each do |file|
|
20
20
|
file = File.expand_path("../../../../schemas/#{file}", __FILE__)
|
21
|
-
|
22
|
-
schema = JsonSchema::Parser.new.parse!(data)
|
23
|
-
schema.expand_references!(store: store)
|
24
|
-
store.add_schema(schema)
|
21
|
+
add_schema(store, file)
|
25
22
|
end
|
23
|
+
add_schema(store, @custom_schema) unless @custom_schema.nil?
|
26
24
|
store
|
27
25
|
end
|
28
26
|
|
27
|
+
def self.add_schema(store, file)
|
28
|
+
data = JSON.parse(File.read(file))
|
29
|
+
schema = JsonSchema::Parser.new.parse!(data)
|
30
|
+
schema.expand_references!(store: store)
|
31
|
+
store.add_schema(schema)
|
32
|
+
end
|
33
|
+
|
29
34
|
# @return [JsonSchema::DocumentStore]
|
30
35
|
def self.document_store
|
31
36
|
@document_store ||= init_document_store
|
@@ -70,7 +75,8 @@ module Prmd
|
|
70
75
|
#
|
71
76
|
# @param [Hash] schema_data
|
72
77
|
# @return [Array<String>] errors from failed verification
|
73
|
-
def self.verify(schema_data)
|
78
|
+
def self.verify(schema_data, custom_schema: nil)
|
79
|
+
@custom_schema = custom_schema
|
74
80
|
a = verify_schema(schema_data)
|
75
81
|
return a unless a.empty?
|
76
82
|
b = verify_parsable(schema_data)
|
@@ -88,7 +94,7 @@ module Prmd
|
|
88
94
|
end
|
89
95
|
|
90
96
|
# (see Prmd::Verification.verify)
|
91
|
-
def self.verify(schema_data)
|
92
|
-
Verification.verify(schema_data)
|
97
|
+
def self.verify(schema_data, custom_schema: nil)
|
98
|
+
Verification.verify(schema_data, custom_schema: custom_schema)
|
93
99
|
end
|
94
100
|
end
|
data/lib/prmd/link.rb
CHANGED
@@ -22,7 +22,7 @@ $ curl -n -X <%= link['method'] %> <%= schema.href %><%= path -%><%- unless opti
|
|
22
22
|
$ curl -n <%= schema.href %><%= path -%><%- unless options[:http_header].empty? %> \<%- end %>
|
23
23
|
<%- end %>
|
24
24
|
<%- options[:http_header].each do |key, value| %>
|
25
|
-
-H "<%= key %>: <%= value %>"
|
25
|
+
-H "<%= key %>: <%= value %>"<%- unless key == options[:http_header].keys.last %> =<%- end %>
|
26
26
|
<%- end %>
|
27
27
|
<%- if !data.nil? && link['method'].upcase != 'GET' %> \
|
28
28
|
-d '<%= JSON.pretty_generate(data) %>'
|
data/lib/prmd/version.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
module Prmd
|
3
3
|
# Well, duh, its a Version module, what did you expect?
|
4
4
|
module Version
|
5
|
-
MAJOR, MINOR, TEENY, PATCH = 0,
|
5
|
+
MAJOR, MINOR, TEENY, PATCH = 0, 11, 0, nil
|
6
6
|
# version string
|
7
7
|
# @return [String]
|
8
8
|
STRING = [MAJOR, MINOR, TEENY, PATCH].compact.join('.').freeze
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: prmd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- geemus
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-01-
|
11
|
+
date: 2016-01-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: erubis
|