prmd 0.7.1 → 0.7.2

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: f2d8980d47308e01724a4038226dcb44581cd4ad
4
- data.tar.gz: 528abc2bf4b32d96469d27453bf011944a43e0fe
3
+ metadata.gz: ad3015a34801fc75b07428616e167869efbff607
4
+ data.tar.gz: e15c2358f3f537025e8c9d10a852b04cadfe501d
5
5
  SHA512:
6
- metadata.gz: af62a75a4a3cba5bec58e76be3ce9243697abbfec32fded14745a1f89cc29b32a7344b4fbd1fd2a3559b97a9b2ebce2eeb097f448a836353a52b52388e556587
7
- data.tar.gz: e67e0d992a1ac14686565ddb53c071b46055ee8e57bb61fc149afb5c32fd458969cd080f87c5db1b57eb90d7f84c1f466250214eba8a22f1a61cc64508d22732
6
+ metadata.gz: b97e766bfc40c8fa7208cd81e9cf39702c69f662950db04cae6a5eee9e9e99c949ff920338e1609276028aa964ee8d3a943f1e3e6e8631171a299fe39a39a589
7
+ data.tar.gz: 05dec32d1af0abc88f4aaa62c53335e1083b0c6121de47205bec8a0213ef49959431c9cba806fddc28e5ceed9526cd07334c02a3ed0b07b45a6fc109322befb3
data/lib/prmd/schema.rb CHANGED
@@ -3,6 +3,21 @@ require 'yaml'
3
3
 
4
4
  # :nodoc:
5
5
  module Prmd
6
+ # @api private
7
+ DefaultExamples = {
8
+ "boolean" => true,
9
+ "integer" => 42,
10
+ "number" => 42.0,
11
+ "string" => "example",
12
+
13
+ "date-time" => "2015-01-01T12:00:00Z",
14
+ "email" => "username@example.com",
15
+ "hostname" => "example.com",
16
+ "ipv4" => "192.0.2.1",
17
+ "ipv6" => "2001:DB8::1",
18
+ "uuid" => "01234567-89ab-cdef-0123-456789abcdef",
19
+ }
20
+
6
21
  # Schema object
7
22
  class Schema
8
23
  # @return [Hash] data
@@ -111,6 +126,10 @@ module Prmd
111
126
  else
112
127
  [schema_example(items)]
113
128
  end
129
+ elsif DefaultExamples.key?(value["format"])
130
+ DefaultExamples[value["format"]]
131
+ elsif DefaultExamples.key?(value["type"][0])
132
+ DefaultExamples[value["type"][0]]
114
133
  end
115
134
  end
116
135
 
@@ -56,6 +56,12 @@
56
56
  attributes << build_attribute(schema, key, value)
57
57
  end
58
58
  end
59
+ attributes.map! { |key, type, description, example|
60
+ if example.nil? && Prmd::DefaultExamples.key?(type)
61
+ example = Prmd::DefaultExamples[type]
62
+ end
63
+ [key, type, description, example]
64
+ }
59
65
  return attributes
60
66
  end
61
67
 
@@ -70,10 +70,10 @@ HTTP/1.1 <%=
70
70
  <%- else %>
71
71
  <%- if link['rel'] == 'empty' %>
72
72
  <%- elsif link.has_key?('targetSchema') %>
73
- <%- if link['targetSchema']['type'] == 'array' -%>
74
- <%= JSON.pretty_generate(schema.schema_example(link['targetSchema'])) %>
75
- <%- else -%>
73
+ <%- if link['targetSchema']['type'].include?('array') -%>
76
74
  <%= JSON.pretty_generate([schema.schema_example(link['targetSchema'])]) %>
75
+ <%- else -%>
76
+ <%= JSON.pretty_generate(schema.schema_example(link['targetSchema'])) %>
77
77
  <%- end -%>
78
78
  <%- elsif link['rel'] == 'instances' %>
79
79
  <%= JSON.pretty_generate([schema.schemata_example(resource)]) %>
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, 7, 1, nil
5
+ MAJOR, MINOR, TEENY, PATCH = 0, 7, 2, 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.7.1
4
+ version: 0.7.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - geemus
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-12 00:00:00.000000000 Z
11
+ date: 2015-05-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: erubis