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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 579c3db87d3792ad0cec85d4ffe6cc8768c75ecf
4
- data.tar.gz: a268c574753449a9c4c26b133edbb197e110a656
3
+ metadata.gz: b6c1c60fbfffb354907c790aa138cf4cf32d3e8f
4
+ data.tar.gz: 39a28c6f1b00bf1099f25c50bac8dc629b781073
5
5
  SHA512:
6
- metadata.gz: b47a74089c0f70e5e981f8c684935158a1efce15393979605aa9a6773f9464c37b9ab2c8398de071912b30c5655bbe1dc0467cb947fdc8979e56ff8ea1f3ebf6
7
- data.tar.gz: d2e6700a36c36a4483d09949ea54c96e2ced5d1faa031e63f00d8f3e401df2a61d29f4edfa5fb14c4746ce0061b8956a3ab13f46664a4d9a337547331f83ff98
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
 
@@ -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
 
@@ -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
- errors = Prmd.verify(data)
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) }
@@ -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
- data = JSON.parse(File.read(file))
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
@@ -46,7 +46,7 @@ module Prmd
46
46
 
47
47
  class Schema < OpenStruct
48
48
  def has_properties?
49
- !self.properties.empty?
49
+ self.properties && !self.properties.empty?
50
50
  end
51
51
 
52
52
  def property_is_required?(property_name)
@@ -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, 10, 0, nil
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.10.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-04 00:00:00.000000000 Z
11
+ date: 2016-01-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: erubis