matter_compiler 0.1.1 → 0.2.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 +4 -4
- data/Gemfile.lock +6 -6
- data/LICENSE +1 -1
- data/README.md +0 -3
- data/features/compose.feature +4 -4
- data/features/step_definitions/file_content_step.rb +1 -1
- data/lib/matter_compiler/blueprint.rb +26 -1
- data/lib/matter_compiler/version.rb +1 -1
- data/test/action_test.rb +1 -1
- data/test/blueprint_test.rb +1 -1
- data/test/composer_test.rb +1 -1
- data/test/headers_test.rb +1 -1
- data/test/metadata_test.rb +1 -1
- data/test/parameters_test.rb +1 -1
- data/test/payload_test.rb +3 -3
- data/test/resource_group_test.rb +1 -1
- data/test/resource_test.rb +1 -1
- data/test/transaction_example_test.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2438e7716b2607e8788be4e332aff2eedb0d460c
|
4
|
+
data.tar.gz: db36d457d1d9ab69d0553e6f447d30adf486dd8f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3005e01e75d7ac2ed028f5c4caccc3aae4557b9a26d3b51cf4d3fde2ac19f6a62861e57e5a22f54722bd443046d5c161fae76e36943a18c83a5d95a0b8b6c50c
|
7
|
+
data.tar.gz: 2515278165482136a04b5d6e827d3222a0ab859e91d44b04360f5cfc54504464e5e26c6adfb42c7b02e7f2f2c731e4c75aa488c8bfc099e3b548442c186b973f
|
data/Gemfile.lock
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
GIT
|
2
2
|
remote: git://github.com/cucumber/aruba.git
|
3
|
-
revision:
|
3
|
+
revision: 99d8e6a5992af17b014783e775409bc3fd422273
|
4
4
|
specs:
|
5
|
-
aruba (0.5.
|
5
|
+
aruba (0.5.4)
|
6
6
|
childprocess (>= 0.3.6)
|
7
7
|
cucumber (>= 1.1.1)
|
8
8
|
rspec-expectations (>= 2.7.0)
|
@@ -10,13 +10,13 @@ GIT
|
|
10
10
|
PATH
|
11
11
|
remote: .
|
12
12
|
specs:
|
13
|
-
matter_compiler (0.
|
13
|
+
matter_compiler (0.2.0)
|
14
14
|
|
15
15
|
GEM
|
16
16
|
remote: https://rubygems.org/
|
17
17
|
specs:
|
18
18
|
builder (3.2.2)
|
19
|
-
childprocess (0.
|
19
|
+
childprocess (0.4.0)
|
20
20
|
ffi (~> 1.0, >= 1.0.11)
|
21
21
|
cucumber (1.3.10)
|
22
22
|
builder (>= 2.1.2)
|
@@ -28,8 +28,8 @@ GEM
|
|
28
28
|
ffi (1.9.3)
|
29
29
|
gherkin (2.12.2)
|
30
30
|
multi_json (~> 1.3)
|
31
|
-
minitest (
|
32
|
-
multi_json (1.8.
|
31
|
+
minitest (5.2.1)
|
32
|
+
multi_json (1.8.4)
|
33
33
|
multi_test (0.0.3)
|
34
34
|
rake (10.1.1)
|
35
35
|
rspec-expectations (2.14.4)
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -1,9 +1,7 @@
|
|
1
1
|
# Matter Compiler [](https://travis-ci.org/apiaryio/matter_compiler)
|
2
|
-
|
3
2
|
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
3
|
|
5
4
|
## Installation
|
6
|
-
|
7
5
|
Add this line to your application's Gemfile:
|
8
6
|
|
9
7
|
gem 'matter_compiler'
|
@@ -26,7 +24,6 @@ $ matter_compiler path/to/ast.yaml
|
|
26
24
|
See the [compose feature](features/compose.feature) for details or run `matter_compiler --help`.
|
27
25
|
|
28
26
|
## Contributing
|
29
|
-
|
30
27
|
1. Fork it (https://github.com/apiaryio/matter_compiler/fork)
|
31
28
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
32
29
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
data/features/compose.feature
CHANGED
@@ -331,20 +331,20 @@
|
|
331
331
|
Scenario: Compose blueprint from an YAML stdin input
|
332
332
|
When I run `matter_compiler --format yaml` interactively
|
333
333
|
When I pipe in the file "ast.yaml"
|
334
|
-
Then the output should contain the content file "blueprint.md"
|
334
|
+
Then the output should contain the content of file "blueprint.md"
|
335
335
|
|
336
336
|
Scenario: Compose blueprint from an YAML file
|
337
337
|
When I run `matter_compiler ast.yaml`
|
338
|
-
Then the output should contain the content file "blueprint.md"
|
338
|
+
Then the output should contain the content of file "blueprint.md"
|
339
339
|
|
340
340
|
Scenario: Compose blueprint from a JSON stdin input
|
341
341
|
When I run `matter_compiler --format json` interactively
|
342
342
|
When I pipe in the file "ast.json"
|
343
|
-
Then the output should contain the content file "blueprint.md"
|
343
|
+
Then the output should contain the content of file "blueprint.md"
|
344
344
|
|
345
345
|
Scenario: Compose blueprint from a JSON file
|
346
346
|
When I run `matter_compiler ast.json`
|
347
|
-
Then the output should contain the content file "blueprint.md"
|
347
|
+
Then the output should contain the content of file "blueprint.md"
|
348
348
|
|
349
349
|
|
350
350
|
Scenario: Copose unsupported version of blueprint AST
|
@@ -32,6 +32,18 @@ module MatterCompiler
|
|
32
32
|
@name = hash[:name]
|
33
33
|
@description = hash[:description]
|
34
34
|
end
|
35
|
+
|
36
|
+
# Ensure a description serialization
|
37
|
+
# ends with two newlines.
|
38
|
+
def ensure_description_newlines(buffer)
|
39
|
+
return if description.blank?
|
40
|
+
|
41
|
+
if description[-1, 1] != "\n"
|
42
|
+
buffer << "\n\n"
|
43
|
+
elsif description.length > 1 && description[-2, 1] != "\n"
|
44
|
+
buffer << "\n"
|
45
|
+
end
|
46
|
+
end
|
35
47
|
end
|
36
48
|
|
37
49
|
#
|
@@ -269,19 +281,28 @@ module MatterCompiler
|
|
269
281
|
end
|
270
282
|
buffer << "\n"
|
271
283
|
|
284
|
+
got_new_line = false
|
272
285
|
@body.each_line do |line|
|
273
286
|
asset_indent_level.times { buffer << ONE_INDENTATION_LEVEL }
|
274
287
|
buffer << "#{line}"
|
288
|
+
got_new_line = line[-1, 1] == "\n"
|
275
289
|
end
|
290
|
+
|
291
|
+
buffer << "\n" unless got_new_line
|
276
292
|
buffer << "\n"
|
277
293
|
end
|
278
294
|
|
279
295
|
unless @schema.blank?
|
280
296
|
buffer << "#{ONE_INDENTATION_LEVEL}+ Schema\n\n"
|
297
|
+
|
298
|
+
got_new_line = false
|
281
299
|
@schema.each_line do |line|
|
282
300
|
3.times { buffer << ONE_INDENTATION_LEVEL }
|
283
301
|
buffer << "#{line}"
|
284
|
-
|
302
|
+
got_new_line = line[-1, 1] == "\n"
|
303
|
+
end
|
304
|
+
|
305
|
+
buffer << "\n" unless got_new_line
|
285
306
|
buffer << "\n"
|
286
307
|
end
|
287
308
|
|
@@ -400,6 +421,7 @@ module MatterCompiler
|
|
400
421
|
end
|
401
422
|
|
402
423
|
buffer << "#{@description}" unless @description.blank?
|
424
|
+
ensure_description_newlines(buffer)
|
403
425
|
|
404
426
|
buffer << @parameters.serialize unless @parameters.nil?
|
405
427
|
buffer << @headers.serialize unless @headers.nil?
|
@@ -444,6 +466,7 @@ module MatterCompiler
|
|
444
466
|
end
|
445
467
|
|
446
468
|
buffer << "#{@description}" unless @description.blank?
|
469
|
+
ensure_description_newlines(buffer)
|
447
470
|
|
448
471
|
buffer << @model.serialize unless @model.nil?
|
449
472
|
buffer << @parameters.serialize unless @parameters.nil?
|
@@ -475,6 +498,7 @@ module MatterCompiler
|
|
475
498
|
buffer = ""
|
476
499
|
buffer << "# Group #{@name}\n" unless @name.blank?
|
477
500
|
buffer << "#{@description}" unless @description.blank?
|
501
|
+
ensure_description_newlines(buffer)
|
478
502
|
|
479
503
|
@resources.each { |resource| buffer << resource.serialize } unless @resources.nil?
|
480
504
|
buffer
|
@@ -513,6 +537,7 @@ module MatterCompiler
|
|
513
537
|
buffer << "#{@metadata.serialize}" unless @metadata.nil?
|
514
538
|
buffer << "# #{@name}\n" unless @name.blank?
|
515
539
|
buffer << "#{@description}" unless @description.blank?
|
540
|
+
ensure_description_newlines(buffer)
|
516
541
|
|
517
542
|
@resource_groups.each { |group| buffer << group.serialize } unless @resource_groups.nil?
|
518
543
|
buffer
|
data/test/action_test.rb
CHANGED
@@ -4,7 +4,7 @@ require_relative 'parameters_test'
|
|
4
4
|
require_relative 'headers_test'
|
5
5
|
require_relative 'transaction_example_test'
|
6
6
|
|
7
|
-
class ActionTest < Minitest::
|
7
|
+
class ActionTest < Minitest::Test
|
8
8
|
AST_HASH = {
|
9
9
|
:name => "Into Action",
|
10
10
|
:description => "Dolor sit amet\n\n",
|
data/test/blueprint_test.rb
CHANGED
@@ -3,7 +3,7 @@ require 'matter_compiler/blueprint'
|
|
3
3
|
require_relative 'resource_group_test'
|
4
4
|
require_relative 'metadata_test'
|
5
5
|
|
6
|
-
class BlueprintTest < Minitest::
|
6
|
+
class BlueprintTest < Minitest::Test
|
7
7
|
AST_HASH = {
|
8
8
|
:_version => 1.0,
|
9
9
|
:metadata => MetadataTest::AST_HASH,
|
data/test/composer_test.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'minitest/autorun'
|
2
2
|
require 'matter_compiler/composer'
|
3
3
|
|
4
|
-
class ComposerTest < Minitest::
|
4
|
+
class ComposerTest < Minitest::Test
|
5
5
|
def test_guess_format
|
6
6
|
assert_equal :yaml_ast, MatterCompiler::Composer.guess_format('test.yaml')
|
7
7
|
assert_equal :json_ast, MatterCompiler::Composer.guess_format('test.json')
|
data/test/headers_test.rb
CHANGED
data/test/metadata_test.rb
CHANGED
data/test/parameters_test.rb
CHANGED
data/test/payload_test.rb
CHANGED
@@ -7,7 +7,7 @@ require_relative 'headers_test'
|
|
7
7
|
# with model test used as an archetype for payload.
|
8
8
|
#
|
9
9
|
|
10
|
-
class ModelTest < Minitest::
|
10
|
+
class ModelTest < Minitest::Test
|
11
11
|
AST_HASH = {
|
12
12
|
:name => "My Resource",
|
13
13
|
:description => "Lorem ipsum dolor sit amet.\n",
|
@@ -48,7 +48,7 @@ class ModelTest < Minitest::Unit::TestCase
|
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
|
-
class RequestTest < Minitest::
|
51
|
+
class RequestTest < Minitest::Test
|
52
52
|
AST_HASH = {
|
53
53
|
:name => "Name",
|
54
54
|
:description => "Lorem\nIpsum\n",
|
@@ -86,7 +86,7 @@ class RequestTest < Minitest::Unit::TestCase
|
|
86
86
|
end
|
87
87
|
end
|
88
88
|
|
89
|
-
class ResponseTest < Minitest::
|
89
|
+
class ResponseTest < Minitest::Test
|
90
90
|
AST_HASH = {
|
91
91
|
:name => "200",
|
92
92
|
:description => nil,
|
data/test/resource_group_test.rb
CHANGED
@@ -2,7 +2,7 @@ require 'minitest/autorun'
|
|
2
2
|
require 'matter_compiler/blueprint'
|
3
3
|
require_relative 'resource_test'
|
4
4
|
|
5
|
-
class ResourceGroupTest < Minitest::
|
5
|
+
class ResourceGroupTest < Minitest::Test
|
6
6
|
AST_HASH = {
|
7
7
|
:name => "My Resource Group",
|
8
8
|
:description => "Lorem Ipsum at [Apiary](http://apiary.io)\n\n",
|
data/test/resource_test.rb
CHANGED
@@ -5,7 +5,7 @@ require_relative 'payload_test'
|
|
5
5
|
require_relative 'parameters_test'
|
6
6
|
require_relative 'headers_test'
|
7
7
|
|
8
|
-
class ResourceTest < Minitest::
|
8
|
+
class ResourceTest < Minitest::Test
|
9
9
|
AST_HASH = {
|
10
10
|
:name => "My Resource",
|
11
11
|
:description => "Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n\n",
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: matter_compiler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zdenek Nemec
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-01-
|
11
|
+
date: 2014-01-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|