prmd 0.7.0 → 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/README.md +21 -4
  4. data/docs/schemata.md +4 -0
  5. data/lib/prmd/core/combiner.rb +4 -34
  6. data/lib/prmd/core/reference_localizer.rb +93 -0
  7. data/lib/prmd/load_schema_file.rb +3 -14
  8. data/lib/prmd/multi_loader.rb +2 -0
  9. data/lib/prmd/multi_loader/json.rb +19 -0
  10. data/lib/prmd/multi_loader/loader.rb +128 -0
  11. data/lib/prmd/multi_loader/toml.rb +19 -0
  12. data/lib/prmd/multi_loader/yajl.rb +19 -0
  13. data/lib/prmd/multi_loader/yaml.rb +19 -0
  14. data/lib/prmd/multi_loader/yml.rb +2 -0
  15. data/lib/prmd/rake_tasks/base.rb +33 -5
  16. data/lib/prmd/rake_tasks/combine.rb +20 -4
  17. data/lib/prmd/rake_tasks/doc.rb +24 -8
  18. data/lib/prmd/rake_tasks/verify.rb +17 -5
  19. data/lib/prmd/schema.rb +5 -1
  20. data/lib/prmd/templates/combine_head.json +3 -3
  21. data/lib/prmd/templates/init_default.json +5 -3
  22. data/lib/prmd/templates/init_resource.json.erb +18 -1
  23. data/lib/prmd/templates/schemata.md.erb +3 -0
  24. data/lib/prmd/templates/schemata/helper.erb +20 -0
  25. data/lib/prmd/templates/schemata/link.md.erb +11 -1
  26. data/lib/prmd/templates/schemata/link_curl_example.md.erb +8 -5
  27. data/lib/prmd/version.rb +1 -1
  28. data/test/commands/render_test.rb +60 -0
  29. data/test/core/reference_localizer_test.rb +65 -0
  30. data/test/helpers.rb +25 -3
  31. data/test/multi_loader/common.rb +35 -0
  32. data/test/multi_loader/json_test.rb +14 -0
  33. data/test/multi_loader/toml_test.rb +18 -0
  34. data/test/multi_loader/yajl_test.rb +18 -0
  35. data/test/multi_loader/yaml_test.rb +14 -0
  36. data/test/rake_tasks/combine_test.rb +38 -0
  37. data/test/rake_tasks/doc_test.rb +31 -0
  38. data/test/rake_tasks/verify_test.rb +23 -0
  39. data/test/schemata/data/test.json +6 -0
  40. data/test/schemata/data/test.toml +4 -0
  41. data/test/schemata/data/test.yaml +3 -0
  42. data/test/schemata/input/rake-meta.json +9 -0
  43. data/test/schemata/input/rake_combine/post.json +100 -0
  44. data/test/schemata/input/rake_combine/user.json +100 -0
  45. data/test/schemata/input/rake_doc.json +223 -0
  46. data/test/schemata/input/rake_verify.json +223 -0
  47. metadata +44 -3
  48. data/Gemfile.lock +0 -23
@@ -0,0 +1,100 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-04/hyper-schema",
3
+ "title": "User",
4
+ "definitions": {
5
+ "id": {
6
+ "description": "unique identifier of user",
7
+ "example": "01234567-89ab-cdef-0123-456789abcdef",
8
+ "format": "uuid",
9
+ "type": [
10
+ "string"
11
+ ]
12
+ },
13
+ "identity": {
14
+ "$ref": "/schemata/user#/definitions/id"
15
+ },
16
+ "created_at": {
17
+ "description": "when user was created",
18
+ "example": "2012-01-01T12:00:00Z",
19
+ "format": "date-time",
20
+ "type": [
21
+ "string"
22
+ ]
23
+ },
24
+ "updated_at": {
25
+ "description": "when user was updated",
26
+ "example": "2012-01-01T12:00:00Z",
27
+ "format": "date-time",
28
+ "type": [
29
+ "string"
30
+ ]
31
+ }
32
+ },
33
+ "description": "FIXME",
34
+ "links": [
35
+ {
36
+ "description": "Create a new user.",
37
+ "href": "/users",
38
+ "method": "POST",
39
+ "rel": "create",
40
+ "schema": {
41
+ "properties": {
42
+ },
43
+ "type": [
44
+ "object"
45
+ ]
46
+ },
47
+ "title": "Create"
48
+ },
49
+ {
50
+ "description": "Delete an existing user.",
51
+ "href": "/users/{(%2Fschemata%2Fuser%23%2Fdefinitions%2Fidentity)}",
52
+ "method": "DELETE",
53
+ "rel": "destroy",
54
+ "title": "Delete"
55
+ },
56
+ {
57
+ "description": "Info for existing user.",
58
+ "href": "/users/{(%2Fschemata%2Fuser%23%2Fdefinitions%2Fidentity)}",
59
+ "method": "GET",
60
+ "rel": "self",
61
+ "title": "Info"
62
+ },
63
+ {
64
+ "description": "List existing users.",
65
+ "href": "/users",
66
+ "method": "GET",
67
+ "rel": "instances",
68
+ "title": "List"
69
+ },
70
+ {
71
+ "description": "Update an existing user.",
72
+ "href": "/users/{(%2Fschemata%2Fuser%23%2Fdefinitions%2Fidentity)}",
73
+ "method": "PATCH",
74
+ "rel": "update",
75
+ "schema": {
76
+ "properties": {
77
+ },
78
+ "type": [
79
+ "object"
80
+ ]
81
+ },
82
+ "title": "Update"
83
+ }
84
+ ],
85
+ "properties": {
86
+ "created_at": {
87
+ "$ref": "/schemata/user#/definitions/created_at"
88
+ },
89
+ "id": {
90
+ "$ref": "/schemata/user#/definitions/id"
91
+ },
92
+ "updated_at": {
93
+ "$ref": "/schemata/user#/definitions/updated_at"
94
+ }
95
+ },
96
+ "type": [
97
+ "object"
98
+ ],
99
+ "id": "schemata/user"
100
+ }
@@ -0,0 +1,223 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-04/hyper-schema",
3
+ "definitions": {
4
+ "post": {
5
+ "$schema": "http://json-schema.org/draft-04/hyper-schema",
6
+ "title": "Post",
7
+ "definitions": {
8
+ "id": {
9
+ "description": "unique identifier of post",
10
+ "example": "01234567-89ab-cdef-0123-456789abcdef",
11
+ "format": "uuid",
12
+ "type": [
13
+ "string"
14
+ ]
15
+ },
16
+ "identity": {
17
+ "$ref": "#/definitions/post/definitions/id"
18
+ },
19
+ "created_at": {
20
+ "description": "when post was created",
21
+ "example": "2012-01-01T12:00:00Z",
22
+ "format": "date-time",
23
+ "type": [
24
+ "string"
25
+ ]
26
+ },
27
+ "updated_at": {
28
+ "description": "when post was updated",
29
+ "example": "2012-01-01T12:00:00Z",
30
+ "format": "date-time",
31
+ "type": [
32
+ "string"
33
+ ]
34
+ }
35
+ },
36
+ "description": "FIXME",
37
+ "links": [
38
+ {
39
+ "description": "Create a new post.",
40
+ "href": "/posts",
41
+ "method": "POST",
42
+ "rel": "create",
43
+ "schema": {
44
+ "properties": {
45
+ },
46
+ "type": [
47
+ "object"
48
+ ]
49
+ },
50
+ "title": "Create"
51
+ },
52
+ {
53
+ "description": "Delete an existing post.",
54
+ "href": "/posts/{(%23%2Fdefinitions%2Fpost%2Fdefinitions%2Fidentity)}",
55
+ "method": "DELETE",
56
+ "rel": "destroy",
57
+ "title": "Delete"
58
+ },
59
+ {
60
+ "description": "Info for existing post.",
61
+ "href": "/posts/{(%23%2Fdefinitions%2Fpost%2Fdefinitions%2Fidentity)}",
62
+ "method": "GET",
63
+ "rel": "self",
64
+ "title": "Info"
65
+ },
66
+ {
67
+ "description": "List existing posts.",
68
+ "href": "/posts",
69
+ "method": "GET",
70
+ "rel": "instances",
71
+ "title": "List"
72
+ },
73
+ {
74
+ "description": "Update an existing post.",
75
+ "href": "/posts/{(%23%2Fdefinitions%2Fpost%2Fdefinitions%2Fidentity)}",
76
+ "method": "PATCH",
77
+ "rel": "update",
78
+ "schema": {
79
+ "properties": {
80
+ },
81
+ "type": [
82
+ "object"
83
+ ]
84
+ },
85
+ "title": "Update"
86
+ }
87
+ ],
88
+ "properties": {
89
+ "created_at": {
90
+ "$ref": "#/definitions/post/definitions/created_at"
91
+ },
92
+ "id": {
93
+ "$ref": "#/definitions/post/definitions/id"
94
+ },
95
+ "updated_at": {
96
+ "$ref": "#/definitions/post/definitions/updated_at"
97
+ }
98
+ },
99
+ "type": [
100
+ "object"
101
+ ]
102
+ },
103
+ "user": {
104
+ "$schema": "http://json-schema.org/draft-04/hyper-schema",
105
+ "title": "User",
106
+ "definitions": {
107
+ "id": {
108
+ "description": "unique identifier of user",
109
+ "example": "01234567-89ab-cdef-0123-456789abcdef",
110
+ "format": "uuid",
111
+ "type": [
112
+ "string"
113
+ ]
114
+ },
115
+ "identity": {
116
+ "$ref": "#/definitions/user/definitions/id"
117
+ },
118
+ "created_at": {
119
+ "description": "when user was created",
120
+ "example": "2012-01-01T12:00:00Z",
121
+ "format": "date-time",
122
+ "type": [
123
+ "string"
124
+ ]
125
+ },
126
+ "updated_at": {
127
+ "description": "when user was updated",
128
+ "example": "2012-01-01T12:00:00Z",
129
+ "format": "date-time",
130
+ "type": [
131
+ "string"
132
+ ]
133
+ }
134
+ },
135
+ "description": "FIXME",
136
+ "links": [
137
+ {
138
+ "description": "Create a new user.",
139
+ "href": "/users",
140
+ "method": "POST",
141
+ "rel": "create",
142
+ "schema": {
143
+ "properties": {
144
+ },
145
+ "type": [
146
+ "object"
147
+ ]
148
+ },
149
+ "title": "Create"
150
+ },
151
+ {
152
+ "description": "Delete an existing user.",
153
+ "href": "/users/{(%23%2Fdefinitions%2Fuser%2Fdefinitions%2Fidentity)}",
154
+ "method": "DELETE",
155
+ "rel": "destroy",
156
+ "title": "Delete"
157
+ },
158
+ {
159
+ "description": "Info for existing user.",
160
+ "href": "/users/{(%23%2Fdefinitions%2Fuser%2Fdefinitions%2Fidentity)}",
161
+ "method": "GET",
162
+ "rel": "self",
163
+ "title": "Info"
164
+ },
165
+ {
166
+ "description": "List existing users.",
167
+ "href": "/users",
168
+ "method": "GET",
169
+ "rel": "instances",
170
+ "title": "List"
171
+ },
172
+ {
173
+ "description": "Update an existing user.",
174
+ "href": "/users/{(%23%2Fdefinitions%2Fuser%2Fdefinitions%2Fidentity)}",
175
+ "method": "PATCH",
176
+ "rel": "update",
177
+ "schema": {
178
+ "properties": {
179
+ },
180
+ "type": [
181
+ "object"
182
+ ]
183
+ },
184
+ "title": "Update"
185
+ }
186
+ ],
187
+ "properties": {
188
+ "created_at": {
189
+ "$ref": "#/definitions/user/definitions/created_at"
190
+ },
191
+ "id": {
192
+ "$ref": "#/definitions/user/definitions/id"
193
+ },
194
+ "updated_at": {
195
+ "$ref": "#/definitions/user/definitions/updated_at"
196
+ }
197
+ },
198
+ "type": [
199
+ "object"
200
+ ]
201
+ }
202
+ },
203
+ "properties": {
204
+ "post": {
205
+ "$ref": "#/definitions/post"
206
+ },
207
+ "user": {
208
+ "$ref": "#/definitions/user"
209
+ }
210
+ },
211
+ "type": [
212
+ "object"
213
+ ],
214
+ "id": "rake_task_meta",
215
+ "title": "Rake Task Test",
216
+ "links": [
217
+ {
218
+ "href": "https://prmd.rake_task_test.io",
219
+ "rel": "self"
220
+ }
221
+ ],
222
+ "description": "Testing schema for Prmd RakeTasks"
223
+ }
@@ -0,0 +1,223 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-04/hyper-schema",
3
+ "definitions": {
4
+ "post": {
5
+ "$schema": "http://json-schema.org/draft-04/hyper-schema",
6
+ "title": "Post",
7
+ "definitions": {
8
+ "id": {
9
+ "description": "unique identifier of post",
10
+ "example": "01234567-89ab-cdef-0123-456789abcdef",
11
+ "format": "uuid",
12
+ "type": [
13
+ "string"
14
+ ]
15
+ },
16
+ "identity": {
17
+ "$ref": "#/definitions/post/definitions/id"
18
+ },
19
+ "created_at": {
20
+ "description": "when post was created",
21
+ "example": "2012-01-01T12:00:00Z",
22
+ "format": "date-time",
23
+ "type": [
24
+ "string"
25
+ ]
26
+ },
27
+ "updated_at": {
28
+ "description": "when post was updated",
29
+ "example": "2012-01-01T12:00:00Z",
30
+ "format": "date-time",
31
+ "type": [
32
+ "string"
33
+ ]
34
+ }
35
+ },
36
+ "description": "FIXME",
37
+ "links": [
38
+ {
39
+ "description": "Create a new post.",
40
+ "href": "/posts",
41
+ "method": "POST",
42
+ "rel": "create",
43
+ "schema": {
44
+ "properties": {
45
+ },
46
+ "type": [
47
+ "object"
48
+ ]
49
+ },
50
+ "title": "Create"
51
+ },
52
+ {
53
+ "description": "Delete an existing post.",
54
+ "href": "/posts/{(%23%2Fdefinitions%2Fpost%2Fdefinitions%2Fidentity)}",
55
+ "method": "DELETE",
56
+ "rel": "destroy",
57
+ "title": "Delete"
58
+ },
59
+ {
60
+ "description": "Info for existing post.",
61
+ "href": "/posts/{(%23%2Fdefinitions%2Fpost%2Fdefinitions%2Fidentity)}",
62
+ "method": "GET",
63
+ "rel": "self",
64
+ "title": "Info"
65
+ },
66
+ {
67
+ "description": "List existing posts.",
68
+ "href": "/posts",
69
+ "method": "GET",
70
+ "rel": "instances",
71
+ "title": "List"
72
+ },
73
+ {
74
+ "description": "Update an existing post.",
75
+ "href": "/posts/{(%23%2Fdefinitions%2Fpost%2Fdefinitions%2Fidentity)}",
76
+ "method": "PATCH",
77
+ "rel": "update",
78
+ "schema": {
79
+ "properties": {
80
+ },
81
+ "type": [
82
+ "object"
83
+ ]
84
+ },
85
+ "title": "Update"
86
+ }
87
+ ],
88
+ "properties": {
89
+ "created_at": {
90
+ "$ref": "#/definitions/post/definitions/created_at"
91
+ },
92
+ "id": {
93
+ "$ref": "#/definitions/post/definitions/id"
94
+ },
95
+ "updated_at": {
96
+ "$ref": "#/definitions/post/definitions/updated_at"
97
+ }
98
+ },
99
+ "type": [
100
+ "object"
101
+ ]
102
+ },
103
+ "user": {
104
+ "$schema": "http://json-schema.org/draft-04/hyper-schema",
105
+ "title": "User",
106
+ "definitions": {
107
+ "id": {
108
+ "description": "unique identifier of user",
109
+ "example": "01234567-89ab-cdef-0123-456789abcdef",
110
+ "format": "uuid",
111
+ "type": [
112
+ "string"
113
+ ]
114
+ },
115
+ "identity": {
116
+ "$ref": "#/definitions/user/definitions/id"
117
+ },
118
+ "created_at": {
119
+ "description": "when user was created",
120
+ "example": "2012-01-01T12:00:00Z",
121
+ "format": "date-time",
122
+ "type": [
123
+ "string"
124
+ ]
125
+ },
126
+ "updated_at": {
127
+ "description": "when user was updated",
128
+ "example": "2012-01-01T12:00:00Z",
129
+ "format": "date-time",
130
+ "type": [
131
+ "string"
132
+ ]
133
+ }
134
+ },
135
+ "description": "FIXME",
136
+ "links": [
137
+ {
138
+ "description": "Create a new user.",
139
+ "href": "/users",
140
+ "method": "POST",
141
+ "rel": "create",
142
+ "schema": {
143
+ "properties": {
144
+ },
145
+ "type": [
146
+ "object"
147
+ ]
148
+ },
149
+ "title": "Create"
150
+ },
151
+ {
152
+ "description": "Delete an existing user.",
153
+ "href": "/users/{(%23%2Fdefinitions%2Fuser%2Fdefinitions%2Fidentity)}",
154
+ "method": "DELETE",
155
+ "rel": "destroy",
156
+ "title": "Delete"
157
+ },
158
+ {
159
+ "description": "Info for existing user.",
160
+ "href": "/users/{(%23%2Fdefinitions%2Fuser%2Fdefinitions%2Fidentity)}",
161
+ "method": "GET",
162
+ "rel": "self",
163
+ "title": "Info"
164
+ },
165
+ {
166
+ "description": "List existing users.",
167
+ "href": "/users",
168
+ "method": "GET",
169
+ "rel": "instances",
170
+ "title": "List"
171
+ },
172
+ {
173
+ "description": "Update an existing user.",
174
+ "href": "/users/{(%23%2Fdefinitions%2Fuser%2Fdefinitions%2Fidentity)}",
175
+ "method": "PATCH",
176
+ "rel": "update",
177
+ "schema": {
178
+ "properties": {
179
+ },
180
+ "type": [
181
+ "object"
182
+ ]
183
+ },
184
+ "title": "Update"
185
+ }
186
+ ],
187
+ "properties": {
188
+ "created_at": {
189
+ "$ref": "#/definitions/user/definitions/created_at"
190
+ },
191
+ "id": {
192
+ "$ref": "#/definitions/user/definitions/id"
193
+ },
194
+ "updated_at": {
195
+ "$ref": "#/definitions/user/definitions/updated_at"
196
+ }
197
+ },
198
+ "type": [
199
+ "object"
200
+ ]
201
+ }
202
+ },
203
+ "properties": {
204
+ "post": {
205
+ "$ref": "#/definitions/post"
206
+ },
207
+ "user": {
208
+ "$ref": "#/definitions/user"
209
+ }
210
+ },
211
+ "type": [
212
+ "object"
213
+ ],
214
+ "id": "rake_task_meta",
215
+ "title": "Rake Task Test",
216
+ "links": [
217
+ {
218
+ "href": "https://prmd.rake_task_test.io",
219
+ "rel": "self"
220
+ }
221
+ ],
222
+ "description": "Testing schema for Prmd RakeTasks"
223
+ }