matter_compiler 0.1.1 → 0.2.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: f19e325ef7a0cbf7f7694b87d6b4a2947658e2e1
4
- data.tar.gz: 7f46dbae5982e326b5bb2111bbf405fa8a9c1d17
3
+ metadata.gz: 2438e7716b2607e8788be4e332aff2eedb0d460c
4
+ data.tar.gz: db36d457d1d9ab69d0553e6f447d30adf486dd8f
5
5
  SHA512:
6
- metadata.gz: daabff21fb92ea1d400c256fc2745cfe54c0dca159690ee826af45afc219bcef81d9c1534aca7c0498d6fe7ec7e77f4d96609bc234e7351535381eed5640c0cf
7
- data.tar.gz: 1167484610a8a5a500dff8249a4c5222c9c9559536da38acfd0c71da23d8eb3e0538aad2b3c72b45ab4614c85e4df66c44ade92ecb11bba33859c16c8816d522
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: 7afbc5c0cbae9c9a946d70c4c2735ccb86e00f08
3
+ revision: 99d8e6a5992af17b014783e775409bc3fd422273
4
4
  specs:
5
- aruba (0.5.3)
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.1.1)
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.3.9)
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 (4.7.5)
32
- multi_json (1.8.2)
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
@@ -1,6 +1,6 @@
1
1
  (The MIT License)
2
2
 
3
- Copyright (c) 2013 Apiary Inc. <support@apiary.io>.
3
+ Copyright (c) 2014 Apiary Inc. <support@apiary.io>.
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining
6
6
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -1,9 +1,7 @@
1
1
  # Matter Compiler [![Build Status](https://travis-ci.org/apiaryio/matter_compiler.png?branch=master)](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'`)
@@ -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
@@ -1,4 +1,4 @@
1
- Then /^the output should contain the content file "(.*)"$/ do |filename|
1
+ Then /^the output should contain the content of file "(.*)"$/ do |filename|
2
2
  expected = nil
3
3
  in_current_dir do
4
4
  expected = File.read(filename)
@@ -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
- end
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
@@ -1,3 +1,3 @@
1
1
  module MatterCompiler
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.0"
3
3
  end
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::Unit::TestCase
7
+ class ActionTest < Minitest::Test
8
8
  AST_HASH = {
9
9
  :name => "Into Action",
10
10
  :description => "Dolor sit amet\n\n",
@@ -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::Unit::TestCase
6
+ class BlueprintTest < Minitest::Test
7
7
  AST_HASH = {
8
8
  :_version => 1.0,
9
9
  :metadata => MetadataTest::AST_HASH,
@@ -1,7 +1,7 @@
1
1
  require 'minitest/autorun'
2
2
  require 'matter_compiler/composer'
3
3
 
4
- class ComposerTest < Minitest::Unit::TestCase
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
@@ -1,7 +1,7 @@
1
1
  require 'minitest/autorun'
2
2
  require 'matter_compiler/blueprint'
3
3
 
4
- class HeadersTest < Minitest::Unit::TestCase
4
+ class HeadersTest < Minitest::Test
5
5
  AST_HASH = {
6
6
  :'X-Header' => {
7
7
  :value => "1"
@@ -1,7 +1,7 @@
1
1
  require 'minitest/autorun'
2
2
  require 'matter_compiler/blueprint'
3
3
 
4
- class MetadataTest < Minitest::Unit::TestCase
4
+ class MetadataTest < Minitest::Test
5
5
  AST_HASH = {
6
6
  :FORMAT => {
7
7
  :value => "1A"
@@ -1,7 +1,7 @@
1
1
  require 'minitest/autorun'
2
2
  require 'matter_compiler/blueprint'
3
3
 
4
- class ParametersTest < Minitest::Unit::TestCase
4
+ class ParametersTest < Minitest::Test
5
5
  AST_HASH = {
6
6
  :id => {
7
7
  :description => "Lorem\nIpsum\n",
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::Unit::TestCase
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::Unit::TestCase
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::Unit::TestCase
89
+ class ResponseTest < Minitest::Test
90
90
  AST_HASH = {
91
91
  :name => "200",
92
92
  :description => nil,
@@ -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::Unit::TestCase
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",
@@ -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::Unit::TestCase
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",
@@ -2,7 +2,7 @@ require 'minitest/autorun'
2
2
  require 'matter_compiler/blueprint'
3
3
  require_relative 'payload_test'
4
4
 
5
- class TransactionExampleTest < Minitest::Unit::TestCase
5
+ class TransactionExampleTest < Minitest::Test
6
6
  AST_HASH = {
7
7
  :name => "",
8
8
  :description => "",
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.1.1
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-16 00:00:00.000000000 Z
11
+ date: 2014-01-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler