apipie-rails 0.0.18 → 0.0.19

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -7,3 +7,5 @@ spec/dummy/tmp/
7
7
  .idea
8
8
  Gemfile.lock
9
9
  .rvmrc
10
+
11
+ .DS_Store
data/CHANGELOG CHANGED
@@ -2,6 +2,12 @@
2
2
  Changelog
3
3
  ===========
4
4
 
5
+ v0.0.19
6
+ -------
7
+
8
+ * fix examples recording when resource_id is set
9
+ * use safe_yaml for loading examples file when available
10
+
5
11
  v0.0.18
6
12
  -------
7
13
 
@@ -207,7 +207,12 @@ module Apipie
207
207
  return @recorded_examples if @recorded_examples
208
208
  tape_file = File.join(Rails.root,"doc","apipie_examples.yml")
209
209
  if File.exists?(tape_file)
210
- @recorded_examples = YAML.load_file(tape_file)
210
+ #if SafeYAML gem is enabled, it will load examples as an array of Hash, instead of hash
211
+ if defined? SafeYAML
212
+ @recorded_examples = YAML.load_file(tape_file, :safe=>false)
213
+ else
214
+ @recorded_examples = YAML.load_file(tape_file)
215
+ end
211
216
  else
212
217
  @recorded_examples = {}
213
218
  end
@@ -19,7 +19,7 @@ module Apipie
19
19
  def ignore_call?(record)
20
20
  return true unless record[:controller]
21
21
  return true if @ignored.include?(record[:controller].name)
22
- return true if @ignored.include?("#{record[:controller].name}##{record[:action]}")
22
+ return true if @ignored.include?("#{Apipie.get_resource_name(record[:controller].name)}##{record[:action]}")
23
23
  return true unless @api_controllers_paths.include?(controller_full_path(record[:controller]))
24
24
  end
25
25
 
@@ -33,7 +33,7 @@ module Apipie
33
33
  end
34
34
 
35
35
  def add_to_records(record)
36
- key = "#{record[:controller].controller_name}##{record[:action]}"
36
+ key = "#{Apipie.get_resource_name(record[:controller])}##{record[:action]}"
37
37
  @records[key] << record
38
38
  end
39
39
 
@@ -13,6 +13,7 @@ module Apipie
13
13
  @params.merge!(env["action_dispatch.request.request_parameters"] || {})
14
14
  if data = parse_data(env["rack.input"].read)
15
15
  @request_data = data
16
+ env["rack.input"].rewind
16
17
  end
17
18
  end
18
19
 
@@ -99,7 +99,11 @@ module Apipie
99
99
 
100
100
  def load_old_examples
101
101
  if File.exists?(@examples_file)
102
- return YAML.load(File.read(@examples_file))
102
+ if defined? SafeYAML
103
+ return YAML.load_file(@examples_file, :safe=>false)
104
+ else
105
+ return YAML.load_file(@examples_file)
106
+ end
103
107
  end
104
108
  return {}
105
109
  end
@@ -1,3 +1,3 @@
1
1
  module Apipie
2
- VERSION = '0.0.18'
2
+ VERSION = '0.0.19'
3
3
  end
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ describe Api::V2::Nested::ResourcesController do
4
+ describe "resource id" do
5
+ subject { Apipie.get_resource_name(Api::V2::Nested::ResourcesController) }
6
+
7
+ it "should have resource_id set" do
8
+ subject.should eq("resource")
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,33 @@
1
+ module Api
2
+ module V2
3
+ class Nested::ResourcesController < V2::BaseController
4
+ resource_description do
5
+ name 'Resources'
6
+ resource_id "resource"
7
+ end
8
+ api :GET, "/nested/resources/", "List all nested resources."
9
+ def index
10
+ end
11
+
12
+ api :GET, "/nested/resources/:id/", "Show a nested resource."
13
+ def show
14
+ end
15
+
16
+ api :POST, "/nested/resources/", "Create a nested resource."
17
+ param_group :arch, Api::V1::ArchitecturesController
18
+ def create
19
+ end
20
+
21
+ api :PUT, "/nested/resources/:id/", "Update a nested resource."
22
+ param :architecture, Hash, :required => true do
23
+ param :name, String
24
+ end
25
+ def update
26
+ end
27
+
28
+ api :DELETE, "/resources/:id/", "Delete a nested resource."
29
+ def destroy
30
+ end
31
+ end
32
+ end
33
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apipie-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.18
4
+ version: 0.0.19
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,11 +10,11 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-02-22 00:00:00.000000000Z
13
+ date: 2013-03-13 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails
17
- requirement: &10023700 !ruby/object:Gem::Requirement
17
+ requirement: !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,10 +22,15 @@ dependencies:
22
22
  version: 3.0.10
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *10023700
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ! '>='
29
+ - !ruby/object:Gem::Version
30
+ version: 3.0.10
26
31
  - !ruby/object:Gem::Dependency
27
32
  name: rspec-rails
28
- requirement: &10023280 !ruby/object:Gem::Requirement
33
+ requirement: !ruby/object:Gem::Requirement
29
34
  none: false
30
35
  requirements:
31
36
  - - ! '>='
@@ -33,10 +38,15 @@ dependencies:
33
38
  version: '0'
34
39
  type: :development
35
40
  prerelease: false
36
- version_requirements: *10023280
41
+ version_requirements: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ! '>='
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
37
47
  - !ruby/object:Gem::Dependency
38
48
  name: sqlite3
39
- requirement: &10022820 !ruby/object:Gem::Requirement
49
+ requirement: !ruby/object:Gem::Requirement
40
50
  none: false
41
51
  requirements:
42
52
  - - ! '>='
@@ -44,10 +54,15 @@ dependencies:
44
54
  version: '0'
45
55
  type: :development
46
56
  prerelease: false
47
- version_requirements: *10022820
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ! '>='
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
48
63
  - !ruby/object:Gem::Dependency
49
64
  name: minitest
50
- requirement: &10022400 !ruby/object:Gem::Requirement
65
+ requirement: !ruby/object:Gem::Requirement
51
66
  none: false
52
67
  requirements:
53
68
  - - ! '>='
@@ -55,10 +70,15 @@ dependencies:
55
70
  version: '0'
56
71
  type: :development
57
72
  prerelease: false
58
- version_requirements: *10022400
73
+ version_requirements: !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ! '>='
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
59
79
  - !ruby/object:Gem::Dependency
60
80
  name: maruku
61
- requirement: &10021980 !ruby/object:Gem::Requirement
81
+ requirement: !ruby/object:Gem::Requirement
62
82
  none: false
63
83
  requirements:
64
84
  - - ! '>='
@@ -66,10 +86,15 @@ dependencies:
66
86
  version: '0'
67
87
  type: :development
68
88
  prerelease: false
69
- version_requirements: *10021980
89
+ version_requirements: !ruby/object:Gem::Requirement
90
+ none: false
91
+ requirements:
92
+ - - ! '>='
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
70
95
  - !ruby/object:Gem::Dependency
71
96
  name: RedCloth
72
- requirement: &10021560 !ruby/object:Gem::Requirement
97
+ requirement: !ruby/object:Gem::Requirement
73
98
  none: false
74
99
  requirements:
75
100
  - - ! '>='
@@ -77,10 +102,15 @@ dependencies:
77
102
  version: '0'
78
103
  type: :development
79
104
  prerelease: false
80
- version_requirements: *10021560
105
+ version_requirements: !ruby/object:Gem::Requirement
106
+ none: false
107
+ requirements:
108
+ - - ! '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
81
111
  - !ruby/object:Gem::Dependency
82
112
  name: rake
83
- requirement: &10047700 !ruby/object:Gem::Requirement
113
+ requirement: !ruby/object:Gem::Requirement
84
114
  none: false
85
115
  requirements:
86
116
  - - ! '>='
@@ -88,7 +118,12 @@ dependencies:
88
118
  version: '0'
89
119
  type: :development
90
120
  prerelease: false
91
- version_requirements: *10047700
121
+ version_requirements: !ruby/object:Gem::Requirement
122
+ none: false
123
+ requirements:
124
+ - - ! '>='
125
+ - !ruby/object:Gem::Version
126
+ version: '0'
92
127
  description: Maintain your API documentation up to date!
93
128
  email:
94
129
  - pajkycz@gmail.com
@@ -161,6 +196,7 @@ files:
161
196
  - rel-eng/tito.props
162
197
  - spec/controllers/api/v1/architectures_controller_spec.rb
163
198
  - spec/controllers/api/v2/architectures_controller_spec.rb
199
+ - spec/controllers/api/v2/nested/resources_controller_spec.rb
164
200
  - spec/controllers/apipies_controller_spec.rb
165
201
  - spec/controllers/users_controller_spec.rb
166
202
  - spec/dummy/Rakefile
@@ -169,6 +205,7 @@ files:
169
205
  - spec/dummy/app/controllers/api/v1/base_controller.rb
170
206
  - spec/dummy/app/controllers/api/v2/architectures_controller.rb
171
207
  - spec/dummy/app/controllers/api/v2/base_controller.rb
208
+ - spec/dummy/app/controllers/api/v2/nested/resources_controller.rb
172
209
  - spec/dummy/app/controllers/application_controller.rb
173
210
  - spec/dummy/app/controllers/twitter_example_controller.rb
174
211
  - spec/dummy/app/controllers/users_controller.rb
@@ -228,13 +265,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
228
265
  version: '0'
229
266
  requirements: []
230
267
  rubyforge_project:
231
- rubygems_version: 1.8.6
268
+ rubygems_version: 1.8.25
232
269
  signing_key:
233
270
  specification_version: 3
234
271
  summary: Rails REST API documentation tool
235
272
  test_files:
236
273
  - spec/controllers/api/v1/architectures_controller_spec.rb
237
274
  - spec/controllers/api/v2/architectures_controller_spec.rb
275
+ - spec/controllers/api/v2/nested/resources_controller_spec.rb
238
276
  - spec/controllers/apipies_controller_spec.rb
239
277
  - spec/controllers/users_controller_spec.rb
240
278
  - spec/dummy/Rakefile
@@ -243,6 +281,7 @@ test_files:
243
281
  - spec/dummy/app/controllers/api/v1/base_controller.rb
244
282
  - spec/dummy/app/controllers/api/v2/architectures_controller.rb
245
283
  - spec/dummy/app/controllers/api/v2/base_controller.rb
284
+ - spec/dummy/app/controllers/api/v2/nested/resources_controller.rb
246
285
  - spec/dummy/app/controllers/application_controller.rb
247
286
  - spec/dummy/app/controllers/twitter_example_controller.rb
248
287
  - spec/dummy/app/controllers/users_controller.rb