matter_compiler 0.2.0 → 0.3.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 +1 -1
- data/README.md +3 -1
- data/features/compose.feature +17 -2
- data/lib/matter_compiler/blueprint.rb +13 -2
- data/lib/matter_compiler/cli.rb +7 -1
- data/lib/matter_compiler/composer.rb +2 -2
- data/lib/matter_compiler/version.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: e13f630c4b130bf43697303afd645e6b1a4096f2
|
4
|
+
data.tar.gz: a1f722c98b404306fbf489a6ac1a271668b0a84f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a5411f90dee965254c2bc5a2fc8210ca44aaa72f4d4ce0613a9c890fed56ae297584ae56fbf4aaeef86994cd38d67a33710bf2b3bea5e8a03437de1727e270e8
|
7
|
+
data.tar.gz: 373232ffed7326fdc78064c7dee831962a6d8e37152f807b0d9fdc1c55aac64b879b0615486407f732865639652649375912c9aee4d42e5650591a3af5bebfa5
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
|
+

|
2
|
+
|
1
3
|
# Matter Compiler [](https://travis-ci.org/apiaryio/matter_compiler)
|
2
|
-
Matter Compiler is a [API Blueprint AST Media Types](https://github.com/apiaryio/
|
4
|
+
Matter Compiler is a [API Blueprint AST Media Types](https://github.com/apiaryio/api-blueprint-ast) to [API Blueprint](https://apiblueprint.org) conversion tool. It composes an API blueprint from its serialzed AST media-type.
|
3
5
|
|
4
6
|
## Installation
|
5
7
|
Add this line to your application's Gemfile:
|
data/features/compose.feature
CHANGED
@@ -346,8 +346,7 @@
|
|
346
346
|
When I run `matter_compiler ast.json`
|
347
347
|
Then the output should contain the content of file "blueprint.md"
|
348
348
|
|
349
|
-
|
350
|
-
Scenario: Copose unsupported version of blueprint AST
|
349
|
+
Scenario: Compose unsupported version of blueprint AST
|
351
350
|
Given a file named "future_ast.yaml" with:
|
352
351
|
"""
|
353
352
|
_version: 42000.0.0
|
@@ -361,4 +360,20 @@
|
|
361
360
|
"""
|
362
361
|
unsupported AST version
|
363
362
|
"""
|
363
|
+
|
364
|
+
Scenario: Explicitly set API Blueprint Format
|
365
|
+
Given a file named "no-format.yaml" with:
|
366
|
+
"""
|
367
|
+
_version: 1.0
|
368
|
+
metadata:
|
369
|
+
name: My API
|
370
|
+
description:
|
371
|
+
resourceGroups:
|
372
|
+
"""
|
373
|
+
When I run `matter_compiler --set-blueprint-format no-format.yaml`
|
374
|
+
Then the output should contain:
|
375
|
+
"""
|
376
|
+
FORMAT: 1A
|
364
377
|
|
378
|
+
# My API
|
379
|
+
"""
|
@@ -532,9 +532,20 @@ module MatterCompiler
|
|
532
532
|
end
|
533
533
|
end
|
534
534
|
|
535
|
-
def serialize
|
535
|
+
def serialize(set_blueprint_format = false)
|
536
536
|
buffer = ""
|
537
|
-
|
537
|
+
|
538
|
+
if set_blueprint_format
|
539
|
+
buffer << "FORMAT: 1A\n"
|
540
|
+
if @metadata
|
541
|
+
buffer << "#{@metadata.serialize(0, [:FORMAT])}"
|
542
|
+
else
|
543
|
+
buffer << "\n"
|
544
|
+
end
|
545
|
+
else
|
546
|
+
buffer << "#{@metadata.serialize}" unless @metadata.nil?
|
547
|
+
end
|
548
|
+
|
538
549
|
buffer << "# #{@name}\n" unless @name.blank?
|
539
550
|
buffer << "#{@description}" unless @description.blank?
|
540
551
|
ensure_description_newlines(buffer)
|
data/lib/matter_compiler/cli.rb
CHANGED
@@ -29,7 +29,7 @@ module MatterCompiler
|
|
29
29
|
|
30
30
|
case command
|
31
31
|
when :compose
|
32
|
-
Composer.compose(args.first, options[:format])
|
32
|
+
Composer.compose(args.first, options[:format], options[:'set-blueprint-format'])
|
33
33
|
when :version
|
34
34
|
puts MatterCompiler::VERSION
|
35
35
|
else
|
@@ -54,6 +54,11 @@ module MatterCompiler
|
|
54
54
|
opts.on( '-h', '--help') do
|
55
55
|
@command = :help
|
56
56
|
end
|
57
|
+
|
58
|
+
opts.on( '--set-blueprint-format') do
|
59
|
+
options[:'set-blueprint-format'] = true
|
60
|
+
end
|
61
|
+
|
57
62
|
end
|
58
63
|
|
59
64
|
options_parser.parse!
|
@@ -74,6 +79,7 @@ module MatterCompiler
|
|
74
79
|
puts "\t-f, --format (yaml|json) Set the AST media-type format of the input"
|
75
80
|
puts "\t-h, --help Show this help"
|
76
81
|
puts "\t-v, --version Show version"
|
82
|
+
puts "\t--set-blueprint-format Set API Blueprint format in the output"
|
77
83
|
puts "\n"
|
78
84
|
end
|
79
85
|
|
@@ -46,7 +46,7 @@ module MatterCompiler
|
|
46
46
|
|
47
47
|
# Compose API Blueprint from an AST file.
|
48
48
|
# Returns a string with composed API Blueprint.
|
49
|
-
def self.compose(file = nil, format = nil)
|
49
|
+
def self.compose(file = nil, format = nil, set_blueprint_format = false)
|
50
50
|
# Read input
|
51
51
|
input = nil
|
52
52
|
if file.nil?
|
@@ -81,7 +81,7 @@ module MatterCompiler
|
|
81
81
|
blueprint = Blueprint.new(ast_hash)
|
82
82
|
|
83
83
|
# TODO: use $stdout for now, add serialization options later
|
84
|
-
puts blueprint.serialize
|
84
|
+
puts blueprint.serialize(set_blueprint_format)
|
85
85
|
end
|
86
86
|
|
87
87
|
end
|
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.3.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-
|
11
|
+
date: 2014-02-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|