raml-rb 0.0.3 → 0.0.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f32149c287b8afb783fe1e9505634c1d913d0a5e
4
- data.tar.gz: c4cff4f2e32605588cd5495eb72509cef3387b1c
3
+ metadata.gz: 4457c134a65fe34fe1f266e3e834542e4a9dbf8c
4
+ data.tar.gz: 4ae3a0f6701619e430215480b27d039278a2ecf5
5
5
  SHA512:
6
- metadata.gz: c88c819e3af6f4b49c1e13cb9dac144f0be1f0c999bc6502638e7e2bc100088d1cc2fc40d66ae2850bb1c6163646ebbf32c41320bcf8da0cec9c4bbd1c7c9bbb
7
- data.tar.gz: 77596856bd5b3383fb42e33761b2708d78bd634b7ea228f4c1940bd2e00e7a63b145c9cdbfeb0f66291030e08b7f8263ba9ffb8b82beaf78ff57ab3f8f2e2aec
6
+ metadata.gz: 32d69e8c922a5581370d890d0b0885817db1a7895763fb23b11f1af05d7040833fca8ec36c011c97201e0b601453afcb2d54348a7d7974cfb65adce043dfaa7e
7
+ data.tar.gz: 22b4f168b1d3af5fd2be83bb6e894384b92c637662ad2f7ec531946584b5b30062ed033c749016bdae29d7fbacce06081d6c756fd66c18330ce6edfc54658b15
data/lib/raml/body.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module Raml
2
2
  class Body
3
- attr_accessor :content_type, :schema
3
+ attr_accessor :content_type, :schema, :example
4
4
 
5
5
  def initialize(content_type)
6
6
  @content_type = content_type
@@ -7,7 +7,7 @@ module Raml
7
7
  class Body
8
8
  include Raml::Parser::Util
9
9
 
10
- BASIC_ATTRIBUTES = %w[schema]
10
+ BASIC_ATTRIBUTES = %w[schema example]
11
11
 
12
12
  attr_accessor :body, :attributes
13
13
 
@@ -7,7 +7,7 @@ module Raml
7
7
  class QueryParameter
8
8
  include Raml::Parser::Util
9
9
 
10
- BASIC_ATTRIBUTES = %w[description type example]
10
+ BASIC_ATTRIBUTES = %w[description type example required]
11
11
 
12
12
  attr_accessor :query_parameter, :attributes
13
13
 
@@ -14,7 +14,6 @@ module Raml
14
14
  METHODS = %w[get put post delete]
15
15
 
16
16
  attr_accessor :parent_node, :resource, :trait_names, :attributes
17
- def_delegators :@parent_node, :resources
18
17
  def_delegators :@parent, :traits, :resource_types
19
18
 
20
19
  def initialize(parent)
@@ -37,7 +36,7 @@ module Raml
37
36
  key = underscore(key)
38
37
  case key
39
38
  when /^\//
40
- resources << Raml::Parser::Resource.new(self).parse(resource, key, value)
39
+ resource.resources << Raml::Parser::Resource.new(self).parse(resource, key, value)
41
40
  when *METHODS
42
41
  resource.methods << Raml::Parser::Method.new(self).parse(key, value)
43
42
  when 'is'
@@ -1,9 +1,10 @@
1
1
  module Raml
2
2
  class QueryParameter
3
- attr_accessor :name, :description, :type, :example
3
+ attr_accessor :name, :description, :type, :example, :required
4
4
 
5
5
  def initialize(name)
6
6
  @name = name
7
+ @required = false
7
8
  end
8
9
 
9
10
  end
data/lib/raml/resource.rb CHANGED
@@ -1,11 +1,12 @@
1
1
  module Raml
2
2
  class Resource
3
- attr_accessor :parent, :methods, :uri_partial
3
+ attr_accessor :parent, :methods, :uri_partial, :resources
4
4
 
5
5
  def initialize(parent, uri_partial)
6
6
  @parent = parent
7
7
  @uri_partial = uri_partial
8
8
  @methods = []
9
+ @resources = []
9
10
  end
10
11
 
11
12
  def path
data/lib/raml/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Raml
2
- VERSION = '0.0.3'
2
+ VERSION = '0.0.4'
3
3
  end
@@ -49,6 +49,8 @@ traits:
49
49
  },
50
50
  "required": [ "title", "artist" ]
51
51
  }
52
+ example: |
53
+ {"artist":"Pink Floyd", "title":"Wish You Were Here"}
52
54
  delete:
53
55
  description: |
54
56
  This method will *delete* an **individual song**
@@ -35,6 +35,8 @@ traits:
35
35
  },
36
36
  "required": [ "title", "artist" ]
37
37
  }
38
+ example: |
39
+ {"artist":"Pink Floyd", "title":"Wish You Were Here"}
38
40
  application/xml:
39
41
  delete:
40
42
  description: |
@@ -21,4 +21,11 @@ describe Raml::Body do
21
21
  it { should == 'schema' }
22
22
  end
23
23
 
24
+ describe '#example' do
25
+ let(:body) { Raml::Body.new('the content_type') }
26
+ before { body.example = 'example' }
27
+ subject { body.example }
28
+ it { should == 'example' }
29
+ end
30
+
24
31
  end
@@ -3,13 +3,14 @@ require 'raml/parser/body'
3
3
  describe Raml::Parser::Body do
4
4
  let(:instance) { Raml::Parser::Body.new }
5
5
  let(:type) { 'application/json' }
6
- let(:attribute) { { 'schema' => 'dogs' } }
6
+ let(:attribute) { { 'schema' => 'dogs', 'example' => 'cats' } }
7
7
 
8
8
  describe '#parse' do
9
9
  subject { instance.parse(type, attribute) }
10
10
 
11
11
  it { should be_kind_of Raml::Body }
12
12
  its(:schema) { should == 'dogs' }
13
+ its(:example) { should == 'cats' }
13
14
  end
14
15
 
15
16
  describe '#body' do
@@ -4,6 +4,7 @@ describe Raml::Parser::Resource do
4
4
 
5
5
  let(:parent) { double(resource_types: { 'cats' => { 'post' => {} } }) }
6
6
  let(:resources) { double('<<'.to_sym => nil) }
7
+ let(:resource) { double('<<'.to_sym => nil, resources: resources) }
7
8
  let(:parent_node) { double(resources: resources) }
8
9
  let(:instance) { Raml::Parser::Resource.new(parent) }
9
10
  let(:uri_partial) { '/cats' }
@@ -14,10 +15,13 @@ describe Raml::Parser::Resource do
14
15
  it { should be_kind_of Raml::Resource }
15
16
 
16
17
  context 'resource' do
17
- before { subject }
18
+ before do
19
+ allow(instance).to receive(:resource).and_return(resource)
20
+ subject
21
+ end
18
22
  let(:attributes) { { '/bar' => {} } }
19
23
  it 'should create a method' do
20
- resources.should have_received('<<').with(kind_of(Raml::Resource))
24
+ resource.resources.should have_received('<<').with(kind_of(Raml::Resource))
21
25
  end
22
26
  end
23
27
 
@@ -11,21 +11,24 @@ describe Raml::Parser::Root do
11
11
  its(:base_uri) { should == 'http://example.api.com/{version}' }
12
12
  its(:uri) { should == 'http://example.api.com/v1' }
13
13
  its(:version) { should == 'v1' }
14
- its('resources.count') { should == 2 }
14
+ its('resources.count') { should == 1 }
15
15
  its('resources.first.methods.count') { should == 2 }
16
- its('resources.first.methods.first.responses.count') { should == 1 }
17
- its('resources.first.methods.first.query_parameters.count') { should == 0 }
16
+ its('resources.first.methods.first.responses.count') { should == 0 }
17
+ its('resources.first.methods.first.query_parameters.count') { should == 2 }
18
18
  its('documentation.count') { should == 0 }
19
+ its('resources.first.resources.first.methods.first.responses.first.bodies.first.example') do
20
+ should include '{"artist":"Pink Floyd", "title":"Wish You Were Here"}'
21
+ end
19
22
 
20
23
  context 'trait-inherited attributes' do
21
- subject { Raml::Parser::Root.new.parse(raml).resources.fetch(1).methods.first.query_parameters.first }
24
+ subject { Raml::Parser::Root.new.parse(raml).resources.first.methods.first.query_parameters.first }
22
25
  its(:name) { should == 'pages' }
23
26
  its(:description) { should == 'The number of pages to return' }
24
27
  its(:type) { should == 'number' }
25
28
  end
26
29
 
27
30
  context 'non trait-inherited attributes' do
28
- subject { Raml::Parser::Root.new.parse(raml).resources.fetch(1).methods.first.query_parameters.last }
31
+ subject { Raml::Parser::Root.new.parse(raml).resources.first.methods.first.query_parameters.last }
29
32
  its(:name) { should == 'genre' }
30
33
  its(:description) { should == 'filter the songs by genre' }
31
34
  its(:type) { should == nil }
metadata CHANGED
@@ -1,69 +1,69 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: raml-rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Brennan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-20 00:00:00.000000000 Z
11
+ date: 2014-11-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.6'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.6'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '10.3'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '10.3'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: '3.0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '3.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rspec-its
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ~>
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
61
  version: '1.0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ~>
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '1.0'
69
69
  description:
@@ -73,8 +73,8 @@ executables: []
73
73
  extensions: []
74
74
  extra_rdoc_files: []
75
75
  files:
76
- - .gitignore
77
- - .rspec
76
+ - ".gitignore"
77
+ - ".rspec"
78
78
  - Gemfile
79
79
  - LICENSE.txt
80
80
  - README.md
@@ -130,12 +130,12 @@ require_paths:
130
130
  - lib
131
131
  required_ruby_version: !ruby/object:Gem::Requirement
132
132
  requirements:
133
- - - '>='
133
+ - - ">="
134
134
  - !ruby/object:Gem::Version
135
135
  version: '0'
136
136
  required_rubygems_version: !ruby/object:Gem::Requirement
137
137
  requirements:
138
- - - '>='
138
+ - - ">="
139
139
  - !ruby/object:Gem::Version
140
140
  version: '0'
141
141
  requirements: []
@@ -164,4 +164,3 @@ test_files:
164
164
  - spec/lib/raml/response_spec.rb
165
165
  - spec/lib/raml/root_spec.rb
166
166
  - spec/spec_helper.rb
167
- has_rdoc: