apipie-rails 0.2.4 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
data/.travis.yml CHANGED
@@ -1,6 +1,5 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 1.8.7
4
3
  - 1.9.3
5
4
  - 2.0.0
6
5
  - 2.1.1
@@ -8,9 +7,3 @@ gemfile:
8
7
  - Gemfile.rails32
9
8
  - Gemfile.rails40
10
9
  - Gemfile.rails41
11
- matrix:
12
- exclude:
13
- - rvm: 1.8.7
14
- gemfile: Gemfile.rails40
15
- - rvm: 1.8.7
16
- gemfile: Gemfile.rails41
data/CHANGELOG.md CHANGED
@@ -2,6 +2,13 @@
2
2
  Changelog
3
3
  ===========
4
4
 
5
+ v0.2.5
6
+ ------
7
+
8
+ * Name substitution for referenced param_group defined in a concern
9
+ [#280](https://github.com/Apipie/apipie-rails/pull/280) [@tstrachota][]
10
+ * expected_type 'array' for ArrayValidator
11
+ [#276](https://github.com/Apipie/apipie-rails/pull/276) [@dustint-rh][]
5
12
 
6
13
  THE FURTHER SUPPORT FOR RUBY 1.8.7 WILL NOT BE ENSURED IN THE MASTER
7
14
  AND THE `>= 0.3.0` RELAEASES. We discourage anyone to keep using ruby
@@ -202,3 +209,4 @@ v0.0.15
202
209
  [@exAspArk]: https://github.com/exAspArk
203
210
  [@mourad-ifeelgoods]: https://github.com/mourad-ifeelgoods
204
211
  [@domcleal]: https://github.com/domcleal
212
+ [@dustint-rh]: https://github.com/dustint-rh
@@ -264,7 +264,13 @@ module Apipie
264
264
  scope = scope_or_options
265
265
  end
266
266
  scope ||= _default_param_group_scope
267
- @_current_param_group = {:scope => scope, :name => name, :options => options}
267
+
268
+ @_current_param_group = {
269
+ :scope => scope,
270
+ :name => name,
271
+ :options => options,
272
+ :from_concern => scope.apipie_concern?
273
+ }
268
274
  self.instance_exec(&Apipie.get_param_group(scope, name))
269
275
  ensure
270
276
  @_current_param_group = nil
@@ -322,6 +328,10 @@ module Apipie
322
328
  end
323
329
  end
324
330
 
331
+ def apipie_concern?
332
+ false
333
+ end
334
+
325
335
  # create method api and redefine newly added method
326
336
  def method_added(method_name) #:doc:
327
337
  super
@@ -363,6 +373,10 @@ module Apipie
363
373
  @_apipie_concern_data ||= []
364
374
  end
365
375
 
376
+ def apipie_concern?
377
+ true
378
+ end
379
+
366
380
  # create method api and redefine newly added method
367
381
  def method_added(method_name) #:doc:
368
382
  super
@@ -35,6 +35,9 @@ module Apipie
35
35
 
36
36
  # we save options to know what was passed in DSL
37
37
  @options = options
38
+ if @options[:param_group]
39
+ @from_concern = @options[:param_group][:from_concern]
40
+ end
38
41
 
39
42
  @method_description = method_description
40
43
  @name = concern_subst(name)
@@ -66,6 +69,10 @@ module Apipie
66
69
  end
67
70
  end
68
71
 
72
+ def from_concern?
73
+ method_description.from_concern? || @from_concern
74
+ end
75
+
69
76
  def validate(value)
70
77
  return true if @allow_nil && value.nil?
71
78
  if (!@allow_nil && value.nil?) || !@validator.valid?(value)
@@ -187,7 +194,7 @@ module Apipie
187
194
  end
188
195
 
189
196
  def concern_subst(string)
190
- return string if string.nil? or !method_description.from_concern?
197
+ return string if string.nil? or !from_concern?
191
198
 
192
199
  original = string
193
200
  string = ":#{original}" if original.is_a? Symbol
@@ -175,6 +175,10 @@ module Apipie
175
175
  "Must be an array of #{items}"
176
176
  end
177
177
 
178
+ def expected_type
179
+ "array"
180
+ end
181
+
178
182
  def self.build(param_description, argument, options, block)
179
183
  if argument == Array && !block.is_a?(Proc)
180
184
  self.new(param_description, argument, options)
@@ -1,3 +1,3 @@
1
1
  module Apipie
2
- VERSION = '0.2.4'
2
+ VERSION = '0.2.5'
3
3
  end
@@ -0,0 +1,31 @@
1
+ class OverriddenConcernsController < ApplicationController
2
+
3
+ resource_description { resource_id 'overridden_concern_resources' }
4
+
5
+ apipie_concern_subst(:concern => 'user')
6
+ include ::Concerns::SampleController
7
+
8
+ def_param_group :concern do
9
+ param :concern, String
10
+ end
11
+
12
+ api :PUT, '/:resource_id/:id'
13
+ param :custom_parameter, String, "New parameter added by the overriding method"
14
+ param_group :concern, ::Concerns::SampleController
15
+ def update
16
+ super
17
+ end
18
+
19
+ api :POST, '/:resource_id', "Create a :concern"
20
+ param_group :concern
21
+ def create
22
+ super
23
+ end
24
+
25
+ api :GET, '/:resource_id/custom'
26
+ param :concern, String
27
+ def custom
28
+ render :text => "OK #{params.inspect}"
29
+ end
30
+
31
+ end
@@ -41,5 +41,20 @@ describe "param groups" do
41
41
 
42
42
  arch_v1_params.sort_by(&:to_s).should == arch_v2_params.sort_by(&:to_s)
43
43
  end
44
+
45
+ it "should replace parameter name in a group when it comes from concern" do
46
+ Apipie["overridden_concern_resources#update"].params.has_key?(:user).should == true
47
+ end
48
+
49
+ it "shouldn't replace parameter name in a group redefined in the controller" do
50
+ Apipie["overridden_concern_resources#create"].params.has_key?(:concern).should == true
51
+ Apipie["overridden_concern_resources#create"].params.has_key?(:user).should == false
52
+ end
53
+
54
+ it "shouldn't replace name of a parameter defined in the controller" do
55
+ Apipie["overridden_concern_resources#custom"].params.has_key?(:concern).should == true
56
+ Apipie["overridden_concern_resources#custom"].params.has_key?(:user).should == false
57
+ end
58
+
44
59
  end
45
60
 
metadata CHANGED
@@ -1,169 +1,165 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: apipie-rails
3
- version: !ruby/object:Gem::Version
4
- version: 0.2.4
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
5
  prerelease:
6
+ segments:
7
+ - 0
8
+ - 2
9
+ - 5
10
+ version: 0.2.5
6
11
  platform: ruby
7
- authors:
12
+ authors:
8
13
  - Pavel Pokorny
9
14
  - Ivan Necas
10
15
  autorequire:
11
16
  bindir: bin
12
17
  cert_chain: []
13
- date: 2014-08-11 00:00:00.000000000 Z
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
18
+
19
+ date: 2014-08-22 00:00:00 +02:00
20
+ default_executable:
21
+ dependencies:
22
+ - !ruby/object:Gem::Dependency
16
23
  name: rails
17
- requirement: !ruby/object:Gem::Requirement
18
- none: false
19
- requirements:
20
- - - ! '>='
21
- - !ruby/object:Gem::Version
22
- version: 3.0.10
23
- type: :development
24
24
  prerelease: false
25
- version_requirements: !ruby/object:Gem::Requirement
25
+ requirement: &id001 !ruby/object:Gem::Requirement
26
26
  none: false
27
- requirements:
28
- - - ! '>='
29
- - !ruby/object:Gem::Version
27
+ requirements:
28
+ - - ">="
29
+ - !ruby/object:Gem::Version
30
+ hash: 19
31
+ segments:
32
+ - 3
33
+ - 0
34
+ - 10
30
35
  version: 3.0.10
31
- - !ruby/object:Gem::Dependency
36
+ type: :development
37
+ version_requirements: *id001
38
+ - !ruby/object:Gem::Dependency
32
39
  name: json
33
- requirement: !ruby/object:Gem::Requirement
34
- none: false
35
- requirements:
36
- - - ! '>='
37
- - !ruby/object:Gem::Version
38
- version: '0'
39
- type: :runtime
40
40
  prerelease: false
41
- version_requirements: !ruby/object:Gem::Requirement
41
+ requirement: &id002 !ruby/object:Gem::Requirement
42
42
  none: false
43
- requirements:
44
- - - ! '>='
45
- - !ruby/object:Gem::Version
46
- version: '0'
47
- - !ruby/object:Gem::Dependency
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ hash: 3
47
+ segments:
48
+ - 0
49
+ version: "0"
50
+ type: :runtime
51
+ version_requirements: *id002
52
+ - !ruby/object:Gem::Dependency
48
53
  name: rspec-rails
49
- requirement: !ruby/object:Gem::Requirement
50
- none: false
51
- requirements:
52
- - - ~>
53
- - !ruby/object:Gem::Version
54
- version: 2.14.2
55
- type: :development
56
54
  prerelease: false
57
- version_requirements: !ruby/object:Gem::Requirement
55
+ requirement: &id003 !ruby/object:Gem::Requirement
58
56
  none: false
59
- requirements:
57
+ requirements:
60
58
  - - ~>
61
- - !ruby/object:Gem::Version
59
+ - !ruby/object:Gem::Version
60
+ hash: 51
61
+ segments:
62
+ - 2
63
+ - 14
64
+ - 2
62
65
  version: 2.14.2
63
- - !ruby/object:Gem::Dependency
64
- name: sqlite3
65
- requirement: !ruby/object:Gem::Requirement
66
- none: false
67
- requirements:
68
- - - ! '>='
69
- - !ruby/object:Gem::Version
70
- version: '0'
71
66
  type: :development
67
+ version_requirements: *id003
68
+ - !ruby/object:Gem::Dependency
69
+ name: sqlite3
72
70
  prerelease: false
73
- version_requirements: !ruby/object:Gem::Requirement
74
- none: false
75
- requirements:
76
- - - ! '>='
77
- - !ruby/object:Gem::Version
78
- version: '0'
79
- - !ruby/object:Gem::Dependency
80
- name: minitest
81
- requirement: !ruby/object:Gem::Requirement
71
+ requirement: &id004 !ruby/object:Gem::Requirement
82
72
  none: false
83
- requirements:
84
- - - ! '>='
85
- - !ruby/object:Gem::Version
86
- version: '0'
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ hash: 3
77
+ segments:
78
+ - 0
79
+ version: "0"
87
80
  type: :development
81
+ version_requirements: *id004
82
+ - !ruby/object:Gem::Dependency
83
+ name: minitest
88
84
  prerelease: false
89
- version_requirements: !ruby/object:Gem::Requirement
90
- none: false
91
- requirements:
92
- - - ! '>='
93
- - !ruby/object:Gem::Version
94
- version: '0'
95
- - !ruby/object:Gem::Dependency
96
- name: maruku
97
- requirement: !ruby/object:Gem::Requirement
85
+ requirement: &id005 !ruby/object:Gem::Requirement
98
86
  none: false
99
- requirements:
100
- - - ! '>='
101
- - !ruby/object:Gem::Version
102
- version: '0'
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ hash: 3
91
+ segments:
92
+ - 0
93
+ version: "0"
103
94
  type: :development
95
+ version_requirements: *id005
96
+ - !ruby/object:Gem::Dependency
97
+ name: maruku
104
98
  prerelease: false
105
- version_requirements: !ruby/object:Gem::Requirement
106
- none: false
107
- requirements:
108
- - - ! '>='
109
- - !ruby/object:Gem::Version
110
- version: '0'
111
- - !ruby/object:Gem::Dependency
112
- name: RedCloth
113
- requirement: !ruby/object:Gem::Requirement
99
+ requirement: &id006 !ruby/object:Gem::Requirement
114
100
  none: false
115
- requirements:
116
- - - ! '>='
117
- - !ruby/object:Gem::Version
118
- version: '0'
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ hash: 3
105
+ segments:
106
+ - 0
107
+ version: "0"
119
108
  type: :development
109
+ version_requirements: *id006
110
+ - !ruby/object:Gem::Dependency
111
+ name: RedCloth
120
112
  prerelease: false
121
- version_requirements: !ruby/object:Gem::Requirement
113
+ requirement: &id007 !ruby/object:Gem::Requirement
122
114
  none: false
123
- requirements:
124
- - - ! '>='
125
- - !ruby/object:Gem::Version
126
- version: '0'
127
- - !ruby/object:Gem::Dependency
128
- name: rake
129
- requirement: !ruby/object:Gem::Requirement
130
- none: false
131
- requirements:
132
- - - ! '>='
133
- - !ruby/object:Gem::Version
134
- version: '0'
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ hash: 3
119
+ segments:
120
+ - 0
121
+ version: "0"
135
122
  type: :development
123
+ version_requirements: *id007
124
+ - !ruby/object:Gem::Dependency
125
+ name: rake
136
126
  prerelease: false
137
- version_requirements: !ruby/object:Gem::Requirement
127
+ requirement: &id008 !ruby/object:Gem::Requirement
138
128
  none: false
139
- requirements:
140
- - - ! '>='
141
- - !ruby/object:Gem::Version
142
- version: '0'
143
- - !ruby/object:Gem::Dependency
144
- name: rdoc
145
- requirement: !ruby/object:Gem::Requirement
146
- none: false
147
- requirements:
148
- - - ! '>='
149
- - !ruby/object:Gem::Version
150
- version: '0'
129
+ requirements:
130
+ - - ">="
131
+ - !ruby/object:Gem::Version
132
+ hash: 3
133
+ segments:
134
+ - 0
135
+ version: "0"
151
136
  type: :development
137
+ version_requirements: *id008
138
+ - !ruby/object:Gem::Dependency
139
+ name: rdoc
152
140
  prerelease: false
153
- version_requirements: !ruby/object:Gem::Requirement
141
+ requirement: &id009 !ruby/object:Gem::Requirement
154
142
  none: false
155
- requirements:
156
- - - ! '>='
157
- - !ruby/object:Gem::Version
158
- version: '0'
143
+ requirements:
144
+ - - ">="
145
+ - !ruby/object:Gem::Version
146
+ hash: 3
147
+ segments:
148
+ - 0
149
+ version: "0"
150
+ type: :development
151
+ version_requirements: *id009
159
152
  description: Rails REST API documentation tool
160
- email:
153
+ email:
161
154
  - pajkycz@gmail.com
162
155
  - inecas@redhat.com
163
156
  executables: []
157
+
164
158
  extensions: []
159
+
165
160
  extra_rdoc_files: []
166
- files:
161
+
162
+ files:
167
163
  - .gitignore
168
164
  - .rspec
169
165
  - .travis.yml
@@ -254,6 +250,7 @@ files:
254
250
  - spec/dummy/app/controllers/application_controller.rb
255
251
  - spec/dummy/app/controllers/concerns/sample_controller.rb
256
252
  - spec/dummy/app/controllers/concerns_controller.rb
253
+ - spec/dummy/app/controllers/overridden_concerns_controller.rb
257
254
  - spec/dummy/app/controllers/twitter_example_controller.rb
258
255
  - spec/dummy/app/controllers/users_controller.rb
259
256
  - spec/dummy/app/views/layouts/application.html.erb
@@ -300,31 +297,41 @@ files:
300
297
  - spec/lib/validators/array_validator_spec.rb
301
298
  - spec/spec_helper.rb
302
299
  - spec/support/rake.rb
300
+ has_rdoc: true
303
301
  homepage: http://github.com/Pajk/apipie-rails
304
302
  licenses: []
303
+
305
304
  post_install_message:
306
305
  rdoc_options: []
307
- require_paths:
306
+
307
+ require_paths:
308
308
  - lib
309
- required_ruby_version: !ruby/object:Gem::Requirement
309
+ required_ruby_version: !ruby/object:Gem::Requirement
310
310
  none: false
311
- requirements:
312
- - - ! '>='
313
- - !ruby/object:Gem::Version
314
- version: '0'
315
- required_rubygems_version: !ruby/object:Gem::Requirement
311
+ requirements:
312
+ - - ">="
313
+ - !ruby/object:Gem::Version
314
+ hash: 3
315
+ segments:
316
+ - 0
317
+ version: "0"
318
+ required_rubygems_version: !ruby/object:Gem::Requirement
316
319
  none: false
317
- requirements:
318
- - - ! '>='
319
- - !ruby/object:Gem::Version
320
- version: '0'
320
+ requirements:
321
+ - - ">="
322
+ - !ruby/object:Gem::Version
323
+ hash: 3
324
+ segments:
325
+ - 0
326
+ version: "0"
321
327
  requirements: []
328
+
322
329
  rubyforge_project:
323
- rubygems_version: 1.8.23
330
+ rubygems_version: 1.6.2
324
331
  signing_key:
325
332
  specification_version: 3
326
333
  summary: Rails REST API documentation tool
327
- test_files:
334
+ test_files:
328
335
  - spec/controllers/api/v1/architectures_controller_spec.rb
329
336
  - spec/controllers/api/v2/architectures_controller_spec.rb
330
337
  - spec/controllers/api/v2/nested/resources_controller_spec.rb
@@ -342,6 +349,7 @@ test_files:
342
349
  - spec/dummy/app/controllers/application_controller.rb
343
350
  - spec/dummy/app/controllers/concerns/sample_controller.rb
344
351
  - spec/dummy/app/controllers/concerns_controller.rb
352
+ - spec/dummy/app/controllers/overridden_concerns_controller.rb
345
353
  - spec/dummy/app/controllers/twitter_example_controller.rb
346
354
  - spec/dummy/app/controllers/users_controller.rb
347
355
  - spec/dummy/app/views/layouts/application.html.erb
@@ -388,4 +396,3 @@ test_files:
388
396
  - spec/lib/validators/array_validator_spec.rb
389
397
  - spec/spec_helper.rb
390
398
  - spec/support/rake.rb
391
- has_rdoc: