apipie-rails 0.0.13 → 0.0.14

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. data/Gemfile.lock +5 -3
  2. data/README.rst +688 -0
  3. data/apipie-rails.gemspec +2 -4
  4. data/app/controllers/apipie/apipies_controller.rb +73 -41
  5. data/app/views/apipie/apipies/index.html.erb +10 -3
  6. data/app/views/apipie/apipies/method.html.erb +5 -2
  7. data/app/views/apipie/apipies/resource.html.erb +10 -3
  8. data/lib/apipie-rails.rb +1 -0
  9. data/lib/apipie/apipie_module.rb +28 -79
  10. data/lib/apipie/application.rb +194 -97
  11. data/lib/apipie/client/generator.rb +5 -4
  12. data/lib/apipie/configuration.rb +112 -0
  13. data/lib/apipie/dsl_definition.rb +93 -16
  14. data/lib/apipie/extractor.rb +12 -5
  15. data/lib/apipie/extractor/collector.rb +1 -1
  16. data/lib/apipie/extractor/recorder.rb +2 -1
  17. data/lib/apipie/extractor/writer.rb +11 -4
  18. data/lib/apipie/helpers.rb +15 -4
  19. data/lib/apipie/markup.rb +3 -4
  20. data/lib/apipie/method_description.rb +28 -22
  21. data/lib/apipie/resource_description.rb +44 -42
  22. data/lib/apipie/routing.rb +3 -1
  23. data/lib/apipie/static_dispatcher.rb +0 -1
  24. data/lib/apipie/version.rb +1 -1
  25. data/lib/generators/apipie/install/README +6 -0
  26. data/lib/generators/apipie/install/install_generator.rb +25 -0
  27. data/lib/generators/apipie/install/templates/initializer.rb.erb +7 -0
  28. data/lib/tasks/apipie.rake +31 -39
  29. data/spec/controllers/api/v1/architectures_controller_spec.rb +30 -0
  30. data/spec/controllers/api/v2/architectures_controller_spec.rb +12 -0
  31. data/spec/controllers/apipies_controller_spec.rb +18 -12
  32. data/spec/controllers/users_controller_spec.rb +56 -19
  33. data/spec/dummy/app/controllers/api/base_controller.rb +4 -0
  34. data/spec/dummy/app/controllers/api/v1/architectures_controller.rb +32 -0
  35. data/spec/dummy/app/controllers/api/v1/base_controller.rb +11 -0
  36. data/spec/dummy/app/controllers/api/v2/architectures_controller.rb +32 -0
  37. data/spec/dummy/app/controllers/api/v2/base_controller.rb +11 -0
  38. data/spec/dummy/app/controllers/twitter_example_controller.rb +1 -1
  39. data/spec/dummy/app/controllers/users_controller.rb +2 -3
  40. data/spec/dummy/config/initializers/apipie.rb +29 -6
  41. data/spec/lib/method_description_spec.rb +29 -0
  42. data/spec/lib/param_description_spec.rb +41 -0
  43. data/spec/lib/resource_description_spec.rb +28 -0
  44. data/spec/spec_helper.rb +1 -1
  45. metadata +99 -164
  46. data/README.rdoc +0 -367
  47. data/lib/apipie/client/base.rb +0 -133
  48. data/lib/apipie/client/cli_command.rb +0 -130
  49. data/lib/apipie/client/main.rb +0 -101
  50. data/lib/apipie/client/rest_client_oauth.rb +0 -19
  51. data/lib/apipie/client/template/Gemfile.tt +0 -3
  52. data/lib/apipie/client/template/README.tt +0 -3
  53. data/lib/apipie/client/template/Rakefile.tt +0 -2
  54. data/lib/apipie/client/template/a_name.gemspec.tt +0 -23
  55. data/lib/apipie/client/template/bin/bin.rb.tt +0 -30
  56. data/lib/apipie/client/template/lib/a_name.rb.tt +0 -27
  57. data/lib/apipie/client/template/lib/a_name/commands/cli.rb.tt +0 -22
  58. data/lib/apipie/client/template/lib/a_name/config.yml +0 -6
  59. data/lib/apipie/client/template/lib/a_name/resources/resource.rb.tt +0 -22
  60. data/lib/apipie/client/template/lib/a_name/version.rb.tt +0 -3
  61. data/lib/apipie/client/thor.rb +0 -21
  62. data/rubygem-apipie-rails.spec +0 -122
  63. data/spec/lib/parameter_description_spec.rb +0 -41
@@ -0,0 +1,29 @@
1
+ require "spec_helper"
2
+
3
+ describe Apipie::MethodDescription do
4
+
5
+ describe "params descriptions" do
6
+
7
+ before(:each) do
8
+ Apipie.clear_last
9
+ @resource = Apipie::ResourceDescription.new(ApplicationController, "dummy")
10
+ Apipie.last_dsl_data[:params] << Apipie::ParamDescription.new(:a, String)
11
+ Apipie.last_dsl_data[:params] << Apipie::ParamDescription.new(:b, String)
12
+ Apipie.last_dsl_data[:params] << Apipie::ParamDescription.new(:c, String)
13
+ @method = Apipie::MethodDescription.new(:a, @resource, Apipie.app)
14
+ @resource.add_method_description @method
15
+ end
16
+
17
+ it "should be ordered" do
18
+ @method.params.keys.should == [:a, :b, :c]
19
+ @method.to_json[:params].map{|h| h[:name]}.should == ['a', 'b', 'c']
20
+ end
21
+
22
+ it "should be still ordered" do
23
+ @method.params.keys.should == [:a, :b, :c]
24
+ @method.to_json[:params].map{|h| h[:name]}.should == ['a', 'b', 'c']
25
+ end
26
+
27
+ end
28
+
29
+ end
@@ -0,0 +1,41 @@
1
+ require "spec_helper"
2
+
3
+ describe Apipie::ParamDescription do
4
+
5
+ describe "required_by_default config option" do
6
+
7
+ context "parameters required by default" do
8
+
9
+ before { Apipie.configuration.required_by_default = true }
10
+
11
+ it "should set param as required by default" do
12
+ param = Apipie::ParamDescription.new(:required_by_default, String)
13
+ param.required.should be_true
14
+ end
15
+
16
+ it "should be possible to set param as optional" do
17
+ param = Apipie::ParamDescription.new(:optional, String, :required => false)
18
+ param.required.should be_false
19
+ end
20
+
21
+ end
22
+
23
+ context "parameters optional by default" do
24
+
25
+ before { Apipie.configuration.required_by_default = false }
26
+
27
+ it "should set param as optional by default" do
28
+ param = Apipie::ParamDescription.new(:optional_by_default, String)
29
+ param.required.should be_false
30
+ end
31
+
32
+ it "should be possible to set param as required" do
33
+ param = Apipie::ParamDescription.new(:required, String, 'description','required' => true)
34
+ param.required.should be_true
35
+ end
36
+
37
+ end
38
+
39
+ end
40
+
41
+ end
@@ -0,0 +1,28 @@
1
+ require "spec_helper"
2
+
3
+ describe Apipie::ResourceDescription do
4
+
5
+ describe "methods descriptions" do
6
+
7
+ before(:each) do
8
+ @resource = Apipie::ResourceDescription.new(ApplicationController, "dummy")
9
+ a = Apipie::MethodDescription.new(:a, @resource, Apipie.app)
10
+ b = Apipie::MethodDescription.new(:b, @resource, Apipie.app)
11
+ c = Apipie::MethodDescription.new(:c, @resource, Apipie.app)
12
+ @resource.add_method_description a
13
+ @resource.add_method_description b
14
+ @resource.add_method_description c
15
+ end
16
+
17
+ it "should be ordered" do
18
+ @resource._methods.keys.should == [:a, :b, :c]
19
+ @resource.to_json[:methods].map{|h| h[:name]}.should == ['a', 'b', 'c']
20
+ end
21
+
22
+ it "should be still ordered" do
23
+ @resource._methods.keys.should == [:a, :b, :c]
24
+ @resource.to_json[:methods].map{|h| h[:name]}.should == ['a', 'b', 'c']
25
+ end
26
+
27
+ end
28
+ end
@@ -14,7 +14,7 @@ require 'apipie-rails'
14
14
  Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
15
15
 
16
16
  RSpec.configure do |config|
17
-
17
+
18
18
  config.mock_with :rspec
19
19
 
20
20
  # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
metadata CHANGED
@@ -1,162 +1,102 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: apipie-rails
3
- version: !ruby/object:Gem::Version
4
- hash: 5
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.14
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 0
9
- - 13
10
- version: 0.0.13
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Pavel Pokorny
14
9
  - Ivan Necas
15
10
  autorequire:
16
11
  bindir: bin
17
12
  cert_chain: []
18
-
19
- date: 2012-10-25 00:00:00 Z
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
22
- name: rspec-rails
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- hash: 3
30
- segments:
31
- - 0
32
- version: "0"
33
- type: :development
34
- version_requirements: *id001
35
- - !ruby/object:Gem::Dependency
13
+ date: 2013-01-25 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
36
16
  name: rails
37
- prerelease: false
38
- requirement: &id002 !ruby/object:Gem::Requirement
17
+ requirement: &6778440 !ruby/object:Gem::Requirement
39
18
  none: false
40
- requirements:
41
- - - ">="
42
- - !ruby/object:Gem::Version
43
- hash: 19
44
- segments:
45
- - 3
46
- - 0
47
- - 10
19
+ requirements:
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
48
22
  version: 3.0.10
49
- type: :development
50
- version_requirements: *id002
51
- - !ruby/object:Gem::Dependency
52
- name: sqlite3
23
+ type: :runtime
53
24
  prerelease: false
54
- requirement: &id003 !ruby/object:Gem::Requirement
25
+ version_requirements: *6778440
26
+ - !ruby/object:Gem::Dependency
27
+ name: rspec-rails
28
+ requirement: &6777800 !ruby/object:Gem::Requirement
55
29
  none: false
56
- requirements:
57
- - - ">="
58
- - !ruby/object:Gem::Version
59
- hash: 3
60
- segments:
61
- - 0
62
- version: "0"
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
63
34
  type: :development
64
- version_requirements: *id003
65
- - !ruby/object:Gem::Dependency
66
- name: minitest
67
35
  prerelease: false
68
- requirement: &id004 !ruby/object:Gem::Requirement
36
+ version_requirements: *6777800
37
+ - !ruby/object:Gem::Dependency
38
+ name: sqlite3
39
+ requirement: &6777100 !ruby/object:Gem::Requirement
69
40
  none: false
70
- requirements:
71
- - - ">="
72
- - !ruby/object:Gem::Version
73
- hash: 3
74
- segments:
75
- - 0
76
- version: "0"
41
+ requirements:
42
+ - - ! '>='
43
+ - !ruby/object:Gem::Version
44
+ version: '0'
77
45
  type: :development
78
- version_requirements: *id004
79
- - !ruby/object:Gem::Dependency
80
- name: redcarpet
81
46
  prerelease: false
82
- requirement: &id005 !ruby/object:Gem::Requirement
47
+ version_requirements: *6777100
48
+ - !ruby/object:Gem::Dependency
49
+ name: minitest
50
+ requirement: &6776620 !ruby/object:Gem::Requirement
83
51
  none: false
84
- requirements:
85
- - - ">="
86
- - !ruby/object:Gem::Version
87
- hash: 3
88
- segments:
89
- - 0
90
- version: "0"
52
+ requirements:
53
+ - - ! '>='
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
91
56
  type: :development
92
- version_requirements: *id005
93
- - !ruby/object:Gem::Dependency
94
- name: RedCloth
95
57
  prerelease: false
96
- requirement: &id006 !ruby/object:Gem::Requirement
58
+ version_requirements: *6776620
59
+ - !ruby/object:Gem::Dependency
60
+ name: maruku
61
+ requirement: &6802620 !ruby/object:Gem::Requirement
97
62
  none: false
98
- requirements:
99
- - - ">="
100
- - !ruby/object:Gem::Version
101
- hash: 3
102
- segments:
103
- - 0
104
- version: "0"
63
+ requirements:
64
+ - - ! '>='
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
105
67
  type: :development
106
- version_requirements: *id006
107
- - !ruby/object:Gem::Dependency
108
- name: rake
109
68
  prerelease: false
110
- requirement: &id007 !ruby/object:Gem::Requirement
69
+ version_requirements: *6802620
70
+ - !ruby/object:Gem::Dependency
71
+ name: RedCloth
72
+ requirement: &6802040 !ruby/object:Gem::Requirement
111
73
  none: false
112
- requirements:
113
- - - ">="
114
- - !ruby/object:Gem::Version
115
- hash: 3
116
- segments:
117
- - 0
118
- version: "0"
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
119
78
  type: :development
120
- version_requirements: *id007
121
- - !ruby/object:Gem::Dependency
122
- name: rest-client
123
79
  prerelease: false
124
- requirement: &id008 !ruby/object:Gem::Requirement
80
+ version_requirements: *6802040
81
+ - !ruby/object:Gem::Dependency
82
+ name: rake
83
+ requirement: &6801560 !ruby/object:Gem::Requirement
125
84
  none: false
126
- requirements:
127
- - - ">="
128
- - !ruby/object:Gem::Version
129
- hash: 3
130
- segments:
131
- - 0
132
- version: "0"
85
+ requirements:
86
+ - - ! '>='
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
133
89
  type: :development
134
- version_requirements: *id008
135
- - !ruby/object:Gem::Dependency
136
- name: oauth
137
90
  prerelease: false
138
- requirement: &id009 !ruby/object:Gem::Requirement
139
- none: false
140
- requirements:
141
- - - ">="
142
- - !ruby/object:Gem::Version
143
- hash: 3
144
- segments:
145
- - 0
146
- version: "0"
147
- type: :development
148
- version_requirements: *id009
91
+ version_requirements: *6801560
149
92
  description: Maintain your API documentation up to date!
150
- email:
93
+ email:
151
94
  - pajkycz@gmail.com
152
95
  - inecas@redhat.com
153
96
  executables: []
154
-
155
97
  extensions: []
156
-
157
98
  extra_rdoc_files: []
158
-
159
- files:
99
+ files:
160
100
  - .gitignore
161
101
  - .rspec
162
102
  - .rvmrc
@@ -166,7 +106,7 @@ files:
166
106
  - Gemfile.lock
167
107
  - MIT-LICENSE
168
108
  - NOTICE
169
- - README.rdoc
109
+ - README.rst
170
110
  - Rakefile
171
111
  - apipie-rails.gemspec
172
112
  - app/controllers/apipie/apipies_controller.rb
@@ -192,22 +132,8 @@ files:
192
132
  - lib/apipie-rails.rb
193
133
  - lib/apipie/apipie_module.rb
194
134
  - lib/apipie/application.rb
195
- - lib/apipie/client/base.rb
196
- - lib/apipie/client/cli_command.rb
197
135
  - lib/apipie/client/generator.rb
198
- - lib/apipie/client/main.rb
199
- - lib/apipie/client/rest_client_oauth.rb
200
- - lib/apipie/client/template/Gemfile.tt
201
- - lib/apipie/client/template/README.tt
202
- - lib/apipie/client/template/Rakefile.tt
203
- - lib/apipie/client/template/a_name.gemspec.tt
204
- - lib/apipie/client/template/bin/bin.rb.tt
205
- - lib/apipie/client/template/lib/a_name.rb.tt
206
- - lib/apipie/client/template/lib/a_name/commands/cli.rb.tt
207
- - lib/apipie/client/template/lib/a_name/config.yml
208
- - lib/apipie/client/template/lib/a_name/resources/resource.rb.tt
209
- - lib/apipie/client/template/lib/a_name/version.rb.tt
210
- - lib/apipie/client/thor.rb
136
+ - lib/apipie/configuration.rb
211
137
  - lib/apipie/dsl_definition.rb
212
138
  - lib/apipie/error_description.rb
213
139
  - lib/apipie/errors.rb
@@ -225,14 +151,23 @@ files:
225
151
  - lib/apipie/static_dispatcher.rb
226
152
  - lib/apipie/validator.rb
227
153
  - lib/apipie/version.rb
154
+ - lib/generators/apipie/install/README
155
+ - lib/generators/apipie/install/install_generator.rb
156
+ - lib/generators/apipie/install/templates/initializer.rb.erb
228
157
  - lib/tasks/apipie.rake
229
158
  - rel-eng/packages/.readme
230
159
  - rel-eng/packages/rubygem-apipie-rails
231
160
  - rel-eng/tito.props
232
- - rubygem-apipie-rails.spec
161
+ - spec/controllers/api/v1/architectures_controller_spec.rb
162
+ - spec/controllers/api/v2/architectures_controller_spec.rb
233
163
  - spec/controllers/apipies_controller_spec.rb
234
164
  - spec/controllers/users_controller_spec.rb
235
165
  - spec/dummy/Rakefile
166
+ - spec/dummy/app/controllers/api/base_controller.rb
167
+ - spec/dummy/app/controllers/api/v1/architectures_controller.rb
168
+ - spec/dummy/app/controllers/api/v1/base_controller.rb
169
+ - spec/dummy/app/controllers/api/v2/architectures_controller.rb
170
+ - spec/dummy/app/controllers/api/v2/base_controller.rb
236
171
  - spec/dummy/app/controllers/application_controller.rb
237
172
  - spec/dummy/app/controllers/twitter_example_controller.rb
238
173
  - spec/dummy/app/controllers/users_controller.rb
@@ -267,46 +202,45 @@ files:
267
202
  - spec/dummy/public/javascripts/rails.js
268
203
  - spec/dummy/public/stylesheets/.gitkeep
269
204
  - spec/dummy/script/rails
205
+ - spec/lib/method_description_spec.rb
270
206
  - spec/lib/param_description_spec.rb
271
- - spec/lib/parameter_description_spec.rb
207
+ - spec/lib/resource_description_spec.rb
272
208
  - spec/spec_helper.rb
273
209
  homepage: http://github.com/Pajk/apipie-rails
274
210
  licenses: []
275
-
276
211
  post_install_message:
277
212
  rdoc_options: []
278
-
279
- require_paths:
213
+ require_paths:
280
214
  - lib
281
- required_ruby_version: !ruby/object:Gem::Requirement
215
+ required_ruby_version: !ruby/object:Gem::Requirement
282
216
  none: false
283
- requirements:
284
- - - ">="
285
- - !ruby/object:Gem::Version
286
- hash: 3
287
- segments:
288
- - 0
289
- version: "0"
290
- required_rubygems_version: !ruby/object:Gem::Requirement
217
+ requirements:
218
+ - - ! '>='
219
+ - !ruby/object:Gem::Version
220
+ version: '0'
221
+ required_rubygems_version: !ruby/object:Gem::Requirement
291
222
  none: false
292
- requirements:
293
- - - ">="
294
- - !ruby/object:Gem::Version
295
- hash: 3
296
- segments:
297
- - 0
298
- version: "0"
223
+ requirements:
224
+ - - ! '>='
225
+ - !ruby/object:Gem::Version
226
+ version: '0'
299
227
  requirements: []
300
-
301
228
  rubyforge_project:
302
- rubygems_version: 1.8.24
229
+ rubygems_version: 1.8.6
303
230
  signing_key:
304
231
  specification_version: 3
305
232
  summary: Rails REST API documentation tool
306
- test_files:
233
+ test_files:
234
+ - spec/controllers/api/v1/architectures_controller_spec.rb
235
+ - spec/controllers/api/v2/architectures_controller_spec.rb
307
236
  - spec/controllers/apipies_controller_spec.rb
308
237
  - spec/controllers/users_controller_spec.rb
309
238
  - spec/dummy/Rakefile
239
+ - spec/dummy/app/controllers/api/base_controller.rb
240
+ - spec/dummy/app/controllers/api/v1/architectures_controller.rb
241
+ - spec/dummy/app/controllers/api/v1/base_controller.rb
242
+ - spec/dummy/app/controllers/api/v2/architectures_controller.rb
243
+ - spec/dummy/app/controllers/api/v2/base_controller.rb
310
244
  - spec/dummy/app/controllers/application_controller.rb
311
245
  - spec/dummy/app/controllers/twitter_example_controller.rb
312
246
  - spec/dummy/app/controllers/users_controller.rb
@@ -341,6 +275,7 @@ test_files:
341
275
  - spec/dummy/public/javascripts/rails.js
342
276
  - spec/dummy/public/stylesheets/.gitkeep
343
277
  - spec/dummy/script/rails
278
+ - spec/lib/method_description_spec.rb
344
279
  - spec/lib/param_description_spec.rb
345
- - spec/lib/parameter_description_spec.rb
280
+ - spec/lib/resource_description_spec.rb
346
281
  - spec/spec_helper.rb