matter_compiler 0.2.0 → 0.3.0

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: 2438e7716b2607e8788be4e332aff2eedb0d460c
4
- data.tar.gz: db36d457d1d9ab69d0553e6f447d30adf486dd8f
3
+ metadata.gz: e13f630c4b130bf43697303afd645e6b1a4096f2
4
+ data.tar.gz: a1f722c98b404306fbf489a6ac1a271668b0a84f
5
5
  SHA512:
6
- metadata.gz: 3005e01e75d7ac2ed028f5c4caccc3aae4557b9a26d3b51cf4d3fde2ac19f6a62861e57e5a22f54722bd443046d5c161fae76e36943a18c83a5d95a0b8b6c50c
7
- data.tar.gz: 2515278165482136a04b5d6e827d3222a0ab859e91d44b04360f5cfc54504464e5e26c6adfb42c7b02e7f2f2c731e4c75aa488c8bfc099e3b548442c186b973f
6
+ metadata.gz: a5411f90dee965254c2bc5a2fc8210ca44aaa72f4d4ce0613a9c890fed56ae297584ae56fbf4aaeef86994cd38d67a33710bf2b3bea5e8a03437de1727e270e8
7
+ data.tar.gz: 373232ffed7326fdc78064c7dee831962a6d8e37152f807b0d9fdc1c55aac64b879b0615486407f732865639652649375912c9aee4d42e5650591a3af5bebfa5
data/Gemfile.lock CHANGED
@@ -10,7 +10,7 @@ GIT
10
10
  PATH
11
11
  remote: .
12
12
  specs:
13
- matter_compiler (0.2.0)
13
+ matter_compiler (0.3.0)
14
14
 
15
15
  GEM
16
16
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
+ ![logo](https://raw.github.com/apiaryio/api-blueprint/gh-pages/assets/logo_apiblueprint.png)
2
+
1
3
  # Matter Compiler [![Build Status](https://travis-ci.org/apiaryio/matter_compiler.png?branch=master)](https://travis-ci.org/apiaryio/matter_compiler)
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
+ 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:
@@ -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
- buffer << "#{@metadata.serialize}" unless @metadata.nil?
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)
@@ -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
@@ -1,3 +1,3 @@
1
1
  module MatterCompiler
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  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.2.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-01-22 00:00:00.000000000 Z
11
+ date: 2014-02-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler