prmd 0.11.11 → 0.12.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
  SHA1:
3
- metadata.gz: 360cb547141b8b6cb7530276cee8937fc3d67eeb
4
- data.tar.gz: e5258d2ab83ccf065bed3c366ce915ad3b499f22
3
+ metadata.gz: d1010706b78a9b6d770bb52a5a3bc0dd40cbb516
4
+ data.tar.gz: 0c6021aedeb0bbeaee1af485ffdddcb7c4a83ec5
5
5
  SHA512:
6
- metadata.gz: 05fe9b1d724b0fa2290b1fbd93338eda26819e6bfe2ebaaf27fae5b49a9c8c3fb1eac37377be484280ccf713ac10db897605195337146fe7c8285a2ff066b60a
7
- data.tar.gz: 729a5aa7351f1ffd3777194370bb5a6beb59eed6407c00506baa1a0312eccdfd424d679552a91f555935080faf564a754c8305449c1bc1d3c4c42914d2c69dc9
6
+ metadata.gz: 812720e3b67bcf3f524a545364129751e4b87afb10dc67c74aaf586f6d18f5de644eaa20852bbe68017439004a3a6571eb4230dee4222221344c243a1ad26c99
7
+ data.tar.gz: 442813d217485037daf7aa7a9854c99ec76ddd6371f4d0945c69a9d0000812a232a6b8e8acc6d793f8a4a94952f41335c83a39fd4b592cda212e9526fd5cdc81
@@ -42,7 +42,7 @@ Each attribute MUST include the following properties:
42
42
  Each attribute MAY include the following properties:
43
43
 
44
44
  * `pattern` - a javascript regex encoded in a string that the valid values MUST match
45
- * `format` - format of the value. MUST be one of spec defined `["date-time", "email", "hostname", "ipv4", "ipv6", "uri"]` or defined by us `["uuid"]`
45
+ * `format` - format of the value. MUST be one of spec defined `["date", "date-time", "email", "hostname", "ipv4", "ipv6", "uri"]` or defined by us `["uuid"]`
46
46
 
47
47
  Examples:
48
48
 
@@ -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('-t', '--type-as-string', 'Allow type as string') do |t|
26
+ options[:type_as_string] = t
27
+ end
25
28
  end
26
29
  end
27
30
 
@@ -30,7 +33,8 @@ module Prmd
30
33
  # @example Usage
31
34
  # Prmd::CLI::Combine.execute(argv: ['schema/schemata/api'],
32
35
  # meta: 'schema/meta.json',
33
- # output_file: 'schema/api.json')
36
+ # output_file: 'schema/api.json',
37
+ # type-as-string)
34
38
  #
35
39
  # @param (see Prmd::CLI::Base#execute)
36
40
  # @return (see Prmd::CLI::Base#execute)
@@ -119,7 +119,7 @@ module Prmd
119
119
  end
120
120
  meta ||= {}
121
121
  end
122
- combiner = Prmd::Combiner.new(meta: meta, base: base, schema: schema)
122
+ combiner = Prmd::Combiner.new(meta: meta, base: base, schema: schema, options: options)
123
123
  combiner.combine(*schemata)
124
124
  end
125
125
 
@@ -13,6 +13,7 @@ module Prmd
13
13
  @schema = properties.fetch(:schema)
14
14
  @base = properties.fetch(:base, {})
15
15
  @meta = properties.fetch(:meta, {})
16
+ @options = properties.fetch(:options, {})
16
17
  end
17
18
 
18
19
  # @param [Object] datum
@@ -53,7 +54,7 @@ module Prmd
53
54
  reference_localizer(data['definitions'][id_ary])
54
55
  end
55
56
 
56
- Prmd::Schema.new(data)
57
+ Prmd::Schema.new(data, @options)
57
58
  end
58
59
 
59
60
  private :reference_localizer
@@ -10,6 +10,7 @@ module Prmd
10
10
  "number" => 42.0,
11
11
  "string" => "example",
12
12
 
13
+ "date" => "2015-01-01",
13
14
  "date-time" => "2015-01-01T12:00:00Z",
14
15
  "email" => "username@example.com",
15
16
  "hostname" => "example.com",
@@ -24,24 +25,28 @@ module Prmd
24
25
  attr_reader :data
25
26
 
26
27
  # @param [Hash<String, Object>] new_data
27
- def initialize(new_data = {})
28
- @data = convert_type_to_array(new_data)
28
+ def initialize(new_data = {}, options = {})
29
+ @data = convert_type_to_array(new_data, options)
29
30
  @schemata_examples = {}
30
31
  end
31
32
 
32
33
  #
33
34
  # @param [Object] datum
34
35
  # @return [Object] same type as the input object
35
- def convert_type_to_array(datum)
36
+ def convert_type_to_array(datum, options)
36
37
  case datum
37
38
  when Array
38
- datum.map { |element| convert_type_to_array(element) }
39
+ datum.map { |element| convert_type_to_array(element, options) }
39
40
  when Hash
40
- if datum.key?('type') && datum['type'].is_a?(String)
41
+ if datum.key?('type') && datum['type'].is_a?(String) && !options[:type_as_string]
41
42
  datum['type'] = [*datum['type']]
42
43
  end
43
44
  datum.each_with_object({}) do |(k, v), hash|
44
- hash[k] = convert_type_to_array(v)
45
+ if k != 'example'
46
+ hash[k] = convert_type_to_array(v, options)
47
+ else
48
+ hash[k] = v
49
+ end
45
50
  end
46
51
  else
47
52
  datum
@@ -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, 11, 11, nil
5
+ MAJOR, MINOR, TEENY, PATCH = 0, 12, 0, nil
6
6
  # version string
7
7
  # @return [String]
8
8
  STRING = [MAJOR, MINOR, TEENY, PATCH].compact.join('.').freeze
@@ -90,10 +90,6 @@
90
90
  {
91
91
  "required": ["example", "type"]
92
92
  },
93
- {
94
- "required": ["type"],
95
- "type": ["array"]
96
- },
97
93
  {
98
94
  "required": ["type"],
99
95
  "type": ["object"]
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.11.11
4
+ version: 0.12.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-05-26 00:00:00.000000000 Z
11
+ date: 2016-09-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: erubis