matter_compiler 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/.travis.yml +13 -0
- data/Gemfile +9 -0
- data/Gemfile.lock +47 -0
- data/LICENSE +22 -0
- data/README.md +37 -0
- data/Rakefile +21 -0
- data/bin/matter_compiler +3 -0
- data/features/compose.feature +364 -0
- data/features/step_definitions/file_content_step.rb +8 -0
- data/features/support/setup.rb +1 -0
- data/lib/matter_compiler/blueprint.rb +522 -0
- data/lib/matter_compiler/cli.rb +82 -0
- data/lib/matter_compiler/composer.rb +89 -0
- data/lib/matter_compiler/version.rb +3 -0
- data/lib/matter_compiler.rb +5 -0
- data/lib/object.rb +17 -0
- data/matter_compiler.gemspec +28 -0
- data/test/action_test.rb +48 -0
- data/test/blueprint_test.rb +43 -0
- data/test/composer_test.rb +10 -0
- data/test/headers_test.rb +75 -0
- data/test/metadata_test.rb +28 -0
- data/test/parameters_test.rb +84 -0
- data/test/payload_test.rb +166 -0
- data/test/resource_group_test.rb +32 -0
- data/test/resource_test.rb +53 -0
- data/test/transaction_example_test.rb +38 -0
- metadata +143 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f19e325ef7a0cbf7f7694b87d6b4a2947658e2e1
|
4
|
+
data.tar.gz: 7f46dbae5982e326b5bb2111bbf405fa8a9c1d17
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: daabff21fb92ea1d400c256fc2745cfe54c0dca159690ee826af45afc219bcef81d9c1534aca7c0498d6fe7ec7e77f4d96609bc234e7351535381eed5640c0cf
|
7
|
+
data.tar.gz: 1167484610a8a5a500dff8249a4c5222c9c9559536da38acfd0c71da23d8eb3e0538aad2b3c72b45ab4614c85e4df66c44ade92ecb11bba33859c16c8816d522
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
language: ruby
|
2
|
+
rvm:
|
3
|
+
- 1.9.3
|
4
|
+
- 2.1.0
|
5
|
+
before_install: gem update bundler
|
6
|
+
notifications:
|
7
|
+
email:
|
8
|
+
recipients:
|
9
|
+
- z@apiary.io
|
10
|
+
on_success: change
|
11
|
+
on_failure: always
|
12
|
+
hipchat:
|
13
|
+
secure: "m5NzHq8NoO6dvKFCgOuo8sV3ALe601IcZ4nvFSmmG79tx9YhwC5dOaZ0YgihZrLvdyxRDe7Tf9jtgicMkZ//uEiQ8+0qkXvxRkfu8KbdR09JbkbkkgoD3mIvw5f09H0HDhddZWcPHmBOjjGLrlWlBXfbqBX3gEHpHeumWdJ6nRA="
|
data/Gemfile
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
# Specify your gem's dependencies in matter_compiler.gemspec
|
4
|
+
gemspec
|
5
|
+
|
6
|
+
# Override aruba to include the latest version from its repository
|
7
|
+
group :development do
|
8
|
+
gem 'aruba', :git => 'git://github.com/cucumber/aruba.git'
|
9
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
GIT
|
2
|
+
remote: git://github.com/cucumber/aruba.git
|
3
|
+
revision: 7afbc5c0cbae9c9a946d70c4c2735ccb86e00f08
|
4
|
+
specs:
|
5
|
+
aruba (0.5.3)
|
6
|
+
childprocess (>= 0.3.6)
|
7
|
+
cucumber (>= 1.1.1)
|
8
|
+
rspec-expectations (>= 2.7.0)
|
9
|
+
|
10
|
+
PATH
|
11
|
+
remote: .
|
12
|
+
specs:
|
13
|
+
matter_compiler (0.1.1)
|
14
|
+
|
15
|
+
GEM
|
16
|
+
remote: https://rubygems.org/
|
17
|
+
specs:
|
18
|
+
builder (3.2.2)
|
19
|
+
childprocess (0.3.9)
|
20
|
+
ffi (~> 1.0, >= 1.0.11)
|
21
|
+
cucumber (1.3.10)
|
22
|
+
builder (>= 2.1.2)
|
23
|
+
diff-lcs (>= 1.1.3)
|
24
|
+
gherkin (~> 2.12)
|
25
|
+
multi_json (>= 1.7.5, < 2.0)
|
26
|
+
multi_test (>= 0.0.2)
|
27
|
+
diff-lcs (1.2.5)
|
28
|
+
ffi (1.9.3)
|
29
|
+
gherkin (2.12.2)
|
30
|
+
multi_json (~> 1.3)
|
31
|
+
minitest (4.7.5)
|
32
|
+
multi_json (1.8.2)
|
33
|
+
multi_test (0.0.3)
|
34
|
+
rake (10.1.1)
|
35
|
+
rspec-expectations (2.14.4)
|
36
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
37
|
+
|
38
|
+
PLATFORMS
|
39
|
+
ruby
|
40
|
+
|
41
|
+
DEPENDENCIES
|
42
|
+
aruba!
|
43
|
+
bundler (~> 1.5)
|
44
|
+
cucumber
|
45
|
+
matter_compiler!
|
46
|
+
minitest
|
47
|
+
rake
|
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
(The MIT License)
|
2
|
+
|
3
|
+
Copyright (c) 2013 Apiary Inc. <support@apiary.io>.
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
'Software'), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
19
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
20
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
21
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
22
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# Matter Compiler [![Build Status](https://travis-ci.org/apiaryio/matter_compiler.png?branch=master)](https://travis-ci.org/apiaryio/matter_compiler)
|
2
|
+
|
3
|
+
Matter Compiler is a [API Blueprint AST Media Types](https://github.com/apiaryio/snowcrash/wiki/API-Blueprint-AST-Media-Types) to [API Blueprint](https://apiblueprint.org) conversion tool. It composes an API blueprint from its serialzed AST media-type.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'matter_compiler'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install matter_compiler
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
To compose a blueprint from a serialized AST media-type run:
|
21
|
+
|
22
|
+
```sh
|
23
|
+
$ matter_compiler path/to/ast.yaml
|
24
|
+
```
|
25
|
+
|
26
|
+
See the [compose feature](features/compose.feature) for details or run `matter_compiler --help`.
|
27
|
+
|
28
|
+
## Contributing
|
29
|
+
|
30
|
+
1. Fork it (https://github.com/apiaryio/matter_compiler/fork)
|
31
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
32
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
33
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
34
|
+
5. Create new Pull Request
|
35
|
+
|
36
|
+
## License
|
37
|
+
MIT License. See the [LICENSE](LICENSE) file.
|
data/Rakefile
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require 'rake/testtask'
|
3
|
+
require 'cucumber/rake/task'
|
4
|
+
|
5
|
+
Rake::TestTask.new do |t|
|
6
|
+
t.libs.push "lib"
|
7
|
+
t.test_files = FileList['test/*_test.rb']
|
8
|
+
t.verbose = true
|
9
|
+
end
|
10
|
+
|
11
|
+
Cucumber::Rake::Task.new(:features) do |t|
|
12
|
+
t.cucumber_opts = "features --format pretty"
|
13
|
+
end
|
14
|
+
|
15
|
+
desc "Run all CI tests"
|
16
|
+
task :test_ci do
|
17
|
+
Rake::Task['test'].invoke
|
18
|
+
Rake::Task['features'].invoke
|
19
|
+
end
|
20
|
+
|
21
|
+
task :default => :test_ci
|
data/bin/matter_compiler
ADDED
@@ -0,0 +1,364 @@
|
|
1
|
+
Feature: Compose
|
2
|
+
|
3
|
+
Background:
|
4
|
+
Given a file named "blueprint.md" with:
|
5
|
+
"""
|
6
|
+
FORMAT: 1A
|
7
|
+
|
8
|
+
# My API
|
9
|
+
Description of *My API*.
|
10
|
+
|
11
|
+
## /
|
12
|
+
### GET
|
13
|
+
+ Response 200 (text/plain)
|
14
|
+
|
15
|
+
Hello World!
|
16
|
+
|
17
|
+
# Group Red
|
18
|
+
Description of *Red* Group.
|
19
|
+
|
20
|
+
## My Resource [/myresource/{id}]
|
21
|
+
Description of *My Resource*
|
22
|
+
|
23
|
+
+ Model (application/json)
|
24
|
+
+ Headers
|
25
|
+
|
26
|
+
X-Header: 1
|
27
|
+
|
28
|
+
+ Body
|
29
|
+
|
30
|
+
{ "message": "Hello World" }
|
31
|
+
|
32
|
+
+ Schema
|
33
|
+
|
34
|
+
{ "$schema": "http://json-schema.org/draft-03/schema" }
|
35
|
+
|
36
|
+
+ Parameters
|
37
|
+
+ id = `42` (number, optional, `1000`) ... Parameter `id` description.
|
38
|
+
|
39
|
+
### Retrieve My Resource [GET]
|
40
|
+
+ Response 200 (application/json)
|
41
|
+
+ Headers
|
42
|
+
|
43
|
+
X-Header: 1
|
44
|
+
|
45
|
+
+ Body
|
46
|
+
|
47
|
+
{ "message": "Hello World" }
|
48
|
+
|
49
|
+
+ Schema
|
50
|
+
|
51
|
+
{ "$schema": "http://json-schema.org/draft-03/schema" }
|
52
|
+
|
53
|
+
### Create My Resource [POST]
|
54
|
+
+ Request (text/plain)
|
55
|
+
|
56
|
+
Ni Hao!
|
57
|
+
|
58
|
+
+ Response 204
|
59
|
+
|
60
|
+
"""
|
61
|
+
|
62
|
+
And a file named "ast.yaml" with:
|
63
|
+
"""
|
64
|
+
_version: 1.0
|
65
|
+
metadata:
|
66
|
+
FORMAT:
|
67
|
+
value: 1A
|
68
|
+
name: My API
|
69
|
+
description: "Description of *My API*.\n\n"
|
70
|
+
resourceGroups:
|
71
|
+
- name:
|
72
|
+
description:
|
73
|
+
resources:
|
74
|
+
- name:
|
75
|
+
description:
|
76
|
+
uriTemplate: /
|
77
|
+
model:
|
78
|
+
parameters:
|
79
|
+
headers:
|
80
|
+
actions:
|
81
|
+
- name:
|
82
|
+
description:
|
83
|
+
method: GET
|
84
|
+
parameters:
|
85
|
+
headers:
|
86
|
+
examples:
|
87
|
+
- name:
|
88
|
+
description:
|
89
|
+
requests:
|
90
|
+
responses:
|
91
|
+
- name: 200
|
92
|
+
description:
|
93
|
+
headers:
|
94
|
+
Content-Type:
|
95
|
+
value: text/plain
|
96
|
+
body: "Hello World!\n"
|
97
|
+
schema:
|
98
|
+
- name: Red
|
99
|
+
description: "Description of *Red* Group.\n\n"
|
100
|
+
resources:
|
101
|
+
- name: My Resource
|
102
|
+
description: "Description of *My Resource*\n\n"
|
103
|
+
uriTemplate: "/myresource/{id}"
|
104
|
+
model:
|
105
|
+
name: My Resource
|
106
|
+
description:
|
107
|
+
headers:
|
108
|
+
Content-Type:
|
109
|
+
value: application/json
|
110
|
+
X-Header:
|
111
|
+
value: 1
|
112
|
+
body: "{ \"message\": \"Hello World\" }\n"
|
113
|
+
schema: "{ \"$schema\": \"http://json-schema.org/draft-03/schema\" }\n"
|
114
|
+
parameters:
|
115
|
+
id:
|
116
|
+
description: "Parameter `id` description.\n"
|
117
|
+
type: number
|
118
|
+
required: false
|
119
|
+
default: 42
|
120
|
+
example: 1000
|
121
|
+
values:
|
122
|
+
headers:
|
123
|
+
actions:
|
124
|
+
- name: Retrieve My Resource
|
125
|
+
description:
|
126
|
+
method: GET
|
127
|
+
parameters:
|
128
|
+
headers:
|
129
|
+
examples:
|
130
|
+
- name:
|
131
|
+
description:
|
132
|
+
requests:
|
133
|
+
responses:
|
134
|
+
- name: 200
|
135
|
+
description:
|
136
|
+
headers:
|
137
|
+
Content-Type:
|
138
|
+
value: application/json
|
139
|
+
X-Header:
|
140
|
+
value: 1
|
141
|
+
body: "{ \"message\": \"Hello World\" }\n"
|
142
|
+
schema: "{ \"$schema\": \"http://json-schema.org/draft-03/schema\" }\n"
|
143
|
+
- name: Create My Resource
|
144
|
+
description:
|
145
|
+
method: POST
|
146
|
+
parameters:
|
147
|
+
headers:
|
148
|
+
examples:
|
149
|
+
- name:
|
150
|
+
description:
|
151
|
+
requests:
|
152
|
+
- name:
|
153
|
+
description:
|
154
|
+
headers:
|
155
|
+
Content-Type:
|
156
|
+
value: text/plain
|
157
|
+
body: "Ni Hao!\n"
|
158
|
+
schema:
|
159
|
+
responses:
|
160
|
+
- name: 204
|
161
|
+
description:
|
162
|
+
headers:
|
163
|
+
body:
|
164
|
+
schema:
|
165
|
+
|
166
|
+
"""
|
167
|
+
|
168
|
+
And a file named "ast.json" with:
|
169
|
+
"""
|
170
|
+
{
|
171
|
+
"_version": "1.0",
|
172
|
+
"metadata": {
|
173
|
+
"FORMAT": {
|
174
|
+
"value": "1A"
|
175
|
+
}
|
176
|
+
},
|
177
|
+
"name": "My API",
|
178
|
+
"description": "Description of *My API*.\n\n",
|
179
|
+
"resourceGroups": [
|
180
|
+
{
|
181
|
+
"name": "",
|
182
|
+
"description": "",
|
183
|
+
"resources": [
|
184
|
+
{
|
185
|
+
"name": "",
|
186
|
+
"description": "",
|
187
|
+
"uriTemplate": "/",
|
188
|
+
"model": {},
|
189
|
+
"parameters": {},
|
190
|
+
"headers": {},
|
191
|
+
"actions": [
|
192
|
+
{
|
193
|
+
"name": "",
|
194
|
+
"description": "",
|
195
|
+
"method": "GET",
|
196
|
+
"parameters": {},
|
197
|
+
"headers": {},
|
198
|
+
"examples": [
|
199
|
+
{
|
200
|
+
"name": "",
|
201
|
+
"description": "",
|
202
|
+
"requests": [],
|
203
|
+
"responses": [
|
204
|
+
{
|
205
|
+
"name": "200",
|
206
|
+
"description": "",
|
207
|
+
"headers": {
|
208
|
+
"Content-Type": {
|
209
|
+
"value": "text/plain"
|
210
|
+
}
|
211
|
+
},
|
212
|
+
"body": "Hello World!\n",
|
213
|
+
"schema": ""
|
214
|
+
}
|
215
|
+
]
|
216
|
+
}
|
217
|
+
]
|
218
|
+
}
|
219
|
+
]
|
220
|
+
}
|
221
|
+
]
|
222
|
+
},
|
223
|
+
{
|
224
|
+
"name": "Red",
|
225
|
+
"description": "Description of *Red* Group.\n\n",
|
226
|
+
"resources": [
|
227
|
+
{
|
228
|
+
"name": "My Resource",
|
229
|
+
"description": "Description of *My Resource*\n\n",
|
230
|
+
"uriTemplate": "/myresource/{id}",
|
231
|
+
"model": {
|
232
|
+
"name": "My Resource",
|
233
|
+
"description": "",
|
234
|
+
"headers": {
|
235
|
+
"Content-Type": {
|
236
|
+
"value": "application/json"
|
237
|
+
},
|
238
|
+
"X-Header": {
|
239
|
+
"value": "1"
|
240
|
+
}
|
241
|
+
},
|
242
|
+
"body": "{ \"message\": \"Hello World\" }\n",
|
243
|
+
"schema": "{ \"$schema\": \"http://json-schema.org/draft-03/schema\" }\n"
|
244
|
+
},
|
245
|
+
"parameters": {
|
246
|
+
"id": {
|
247
|
+
"description": "Parameter `id` description.\n",
|
248
|
+
"type": "number",
|
249
|
+
"required": false,
|
250
|
+
"default": "42",
|
251
|
+
"example": "1000",
|
252
|
+
"values": []
|
253
|
+
}
|
254
|
+
},
|
255
|
+
"headers": {},
|
256
|
+
"actions": [
|
257
|
+
{
|
258
|
+
"name": "Retrieve My Resource",
|
259
|
+
"description": "",
|
260
|
+
"method": "GET",
|
261
|
+
"parameters": {},
|
262
|
+
"headers": {},
|
263
|
+
"examples": [
|
264
|
+
{
|
265
|
+
"name": "",
|
266
|
+
"description": "",
|
267
|
+
"requests": [],
|
268
|
+
"responses": [
|
269
|
+
{
|
270
|
+
"name": "200",
|
271
|
+
"description": "",
|
272
|
+
"headers": {
|
273
|
+
"Content-Type": {
|
274
|
+
"value": "application/json"
|
275
|
+
},
|
276
|
+
"X-Header": {
|
277
|
+
"value": "1"
|
278
|
+
}
|
279
|
+
},
|
280
|
+
"body": "{ \"message\": \"Hello World\" }\n",
|
281
|
+
"schema": "{ \"$schema\": \"http://json-schema.org/draft-03/schema\" }\n"
|
282
|
+
}
|
283
|
+
]
|
284
|
+
}
|
285
|
+
]
|
286
|
+
},
|
287
|
+
{
|
288
|
+
"name": "Create My Resource",
|
289
|
+
"description": "",
|
290
|
+
"method": "POST",
|
291
|
+
"parameters": {},
|
292
|
+
"headers": {},
|
293
|
+
"examples": [
|
294
|
+
{
|
295
|
+
"name": "",
|
296
|
+
"description": "",
|
297
|
+
"requests": [
|
298
|
+
{
|
299
|
+
"name": "",
|
300
|
+
"description": "",
|
301
|
+
"headers": {
|
302
|
+
"Content-Type": {
|
303
|
+
"value": "text/plain"
|
304
|
+
}
|
305
|
+
},
|
306
|
+
"body": "Ni Hao!\n",
|
307
|
+
"schema": ""
|
308
|
+
}
|
309
|
+
],
|
310
|
+
"responses": [
|
311
|
+
{
|
312
|
+
"name": "204",
|
313
|
+
"description": "",
|
314
|
+
"headers": {},
|
315
|
+
"body": "",
|
316
|
+
"schema": ""
|
317
|
+
}
|
318
|
+
]
|
319
|
+
}
|
320
|
+
]
|
321
|
+
}
|
322
|
+
]
|
323
|
+
}
|
324
|
+
]
|
325
|
+
}
|
326
|
+
]
|
327
|
+
}
|
328
|
+
|
329
|
+
"""
|
330
|
+
|
331
|
+
Scenario: Compose blueprint from an YAML stdin input
|
332
|
+
When I run `matter_compiler --format yaml` interactively
|
333
|
+
When I pipe in the file "ast.yaml"
|
334
|
+
Then the output should contain the content file "blueprint.md"
|
335
|
+
|
336
|
+
Scenario: Compose blueprint from an YAML file
|
337
|
+
When I run `matter_compiler ast.yaml`
|
338
|
+
Then the output should contain the content file "blueprint.md"
|
339
|
+
|
340
|
+
Scenario: Compose blueprint from a JSON stdin input
|
341
|
+
When I run `matter_compiler --format json` interactively
|
342
|
+
When I pipe in the file "ast.json"
|
343
|
+
Then the output should contain the content file "blueprint.md"
|
344
|
+
|
345
|
+
Scenario: Compose blueprint from a JSON file
|
346
|
+
When I run `matter_compiler ast.json`
|
347
|
+
Then the output should contain the content file "blueprint.md"
|
348
|
+
|
349
|
+
|
350
|
+
Scenario: Copose unsupported version of blueprint AST
|
351
|
+
Given a file named "future_ast.yaml" with:
|
352
|
+
"""
|
353
|
+
_version: 42000.0.0
|
354
|
+
metadata:
|
355
|
+
name:
|
356
|
+
description:
|
357
|
+
resourceGroups:
|
358
|
+
"""
|
359
|
+
When I run `matter_compiler future_ast.yaml`
|
360
|
+
Then it should fail with:
|
361
|
+
"""
|
362
|
+
unsupported AST version
|
363
|
+
"""
|
364
|
+
|