acts_as_api 0.4.3 → 0.4.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.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +4 -2
  3. data/History.txt +8 -0
  4. data/README.md +2 -2
  5. data/acts_as_api.gemspec +2 -2
  6. data/examples/introduction/index.html +6 -6
  7. data/examples/introduction/index.rb +1 -1
  8. data/examples/introduction/layout.mustache +4 -4
  9. data/lib/acts_as_api.rb +18 -2
  10. data/lib/acts_as_api/collection.rb +17 -0
  11. data/lib/acts_as_api/config.rb +15 -15
  12. data/lib/acts_as_api/rails_renderer.rb +6 -2
  13. data/lib/acts_as_api/rendering.rb +4 -4
  14. data/lib/acts_as_api/version.rb +1 -1
  15. data/spec/active_record_dummy/Gemfile +1 -1
  16. data/spec/active_record_dummy/app/models/profile.rb +2 -3
  17. data/spec/active_record_dummy/app/models/task.rb +2 -3
  18. data/spec/active_record_dummy/app/models/user.rb +6 -7
  19. data/spec/active_record_dummy/config/application.rb +0 -6
  20. data/spec/active_record_dummy/config/environments/development.rb +4 -7
  21. data/spec/active_record_dummy/config/environments/production.rb +0 -4
  22. data/spec/active_record_dummy/config/environments/test.rb +3 -3
  23. data/spec/controllers/plain_objects_controller_spec.rb +2 -1
  24. data/spec/controllers/respond_with_users_controller_spec.rb +8 -8
  25. data/spec/mongoid_dummy/Gemfile +2 -2
  26. data/spec/mongoid_dummy/config/application.rb +0 -7
  27. data/spec/mongoid_dummy/config/environments/development.rb +4 -0
  28. data/spec/mongoid_dummy/config/environments/test.rb +3 -1
  29. data/spec/mongoid_dummy/config/mongoid.yml +4 -112
  30. data/spec/shared_engine/app/controllers/shared_engine/plain_objects_controller.rb +1 -1
  31. data/spec/shared_engine/app/controllers/shared_engine/respond_with_users_controller.rb +6 -6
  32. data/spec/shared_engine/app/controllers/shared_engine/users_controller.rb +8 -4
  33. data/spec/shared_engine/dummy/config/application.rb +0 -6
  34. data/spec/shared_engine/dummy/config/environments/development.rb +4 -7
  35. data/spec/shared_engine/dummy/config/environments/production.rb +0 -4
  36. data/spec/shared_engine/dummy/config/environments/test.rb +3 -3
  37. data/spec/shared_engine/shared_engine.gemspec +1 -1
  38. data/spec/spec_helper.rb +7 -5
  39. data/spec/support/controller_examples.rb +23 -47
  40. data/spec/support/model_examples/associations.rb +59 -59
  41. metadata +4 -8
  42. data/lib/acts_as_api/array.rb +0 -21
  43. data/spec/shared_engine/lib/magic/rails/engine.rb +0 -69
  44. data/spec/support/routing.rb +0 -4
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acts_as_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 0.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christian Bäuerlein
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-31 00:00:00.000000000 Z
11
+ date: 2016-11-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -103,8 +103,8 @@ files:
103
103
  - lib/acts_as_api/adapters.rb
104
104
  - lib/acts_as_api/adapters/mongoid.rb
105
105
  - lib/acts_as_api/api_template.rb
106
- - lib/acts_as_api/array.rb
107
106
  - lib/acts_as_api/base.rb
107
+ - lib/acts_as_api/collection.rb
108
108
  - lib/acts_as_api/config.rb
109
109
  - lib/acts_as_api/exceptions.rb
110
110
  - lib/acts_as_api/rails_renderer.rb
@@ -264,7 +264,6 @@ files:
264
264
  - spec/shared_engine/dummy/public/500.html
265
265
  - spec/shared_engine/dummy/public/favicon.ico
266
266
  - spec/shared_engine/dummy/script/rails
267
- - spec/shared_engine/lib/magic/rails/engine.rb
268
267
  - spec/shared_engine/lib/shared_engine.rb
269
268
  - spec/shared_engine/lib/shared_engine/engine.rb
270
269
  - spec/shared_engine/lib/shared_engine/version.rb
@@ -290,7 +289,6 @@ files:
290
289
  - spec/support/model_examples/sub_nodes.rb
291
290
  - spec/support/model_examples/undefined.rb
292
291
  - spec/support/model_examples/untouched.rb
293
- - spec/support/routing.rb
294
292
  - spec/support/simple_fixtures.rb
295
293
  homepage: https://github.com/fabrik42/acts_as_api
296
294
  licenses: []
@@ -315,7 +313,7 @@ rubyforge_project:
315
313
  rubygems_version: 2.5.1
316
314
  signing_key:
317
315
  specification_version: 4
318
- summary: Makes creating XML/JSON responses in Rails 3 easy and fun.
316
+ summary: Makes creating XML/JSON responses in Rails 3, 4 and 5 easy and fun.
319
317
  test_files:
320
318
  - spec/README.md
321
319
  - spec/active_record_dummy/.gitignore
@@ -470,7 +468,6 @@ test_files:
470
468
  - spec/shared_engine/dummy/public/500.html
471
469
  - spec/shared_engine/dummy/public/favicon.ico
472
470
  - spec/shared_engine/dummy/script/rails
473
- - spec/shared_engine/lib/magic/rails/engine.rb
474
471
  - spec/shared_engine/lib/shared_engine.rb
475
472
  - spec/shared_engine/lib/shared_engine/engine.rb
476
473
  - spec/shared_engine/lib/shared_engine/version.rb
@@ -496,5 +493,4 @@ test_files:
496
493
  - spec/support/model_examples/sub_nodes.rb
497
494
  - spec/support/model_examples/undefined.rb
498
495
  - spec/support/model_examples/untouched.rb
499
- - spec/support/routing.rb
500
496
  - spec/support/simple_fixtures.rb
@@ -1,21 +0,0 @@
1
- # The standard ruby Array class is extended by one instance method.
2
- class Array
3
-
4
- # Neccessary to render an Array of models, e.g. the result of a search.
5
- #
6
- # The Array checks all its items if they respond to the +as_api_response+ method.
7
- # If they do, the result of this method will be collected.
8
- # If they don't, the item itself will be collected.
9
- def as_api_response(api_template, options = {})
10
-
11
- collect do |item|
12
- if item.respond_to?(:as_api_response)
13
- item.as_api_response(api_template,options)
14
- else
15
- item
16
- end
17
- end
18
-
19
- end
20
-
21
- end
@@ -1,69 +0,0 @@
1
- module Magic
2
- module Rails
3
- module Engine
4
- ##
5
- # Automatically append all of the current engine's routes to the main
6
- # application's route set. This needs to be done for ALL functional tests that
7
- # use engine routes, since the mounted routes don't work during tests.
8
- #
9
- # @param [Symbol] engine_symbol Optional; if provided, uses this symbol to
10
- # locate the engine class by name, otherwise uses the module of the calling
11
- # test case as the presumed name of the engine.
12
- #
13
- # @author Jason Hamilton (jhamilton@greatherorift.com)
14
- # @author Matthew Ratzloff (matt@urbaninfluence.com)
15
- # @author Xavier Dutreilh (xavier@dutreilh.fr)
16
- def load_engine_routes(engine_symbol = nil)
17
- if engine_symbol
18
- engine_name = engine_symbol.to_s.camelize
19
- else
20
- # No engine provided, so presume the current engine is the one to load
21
- engine_name = self.class.name.split("::").first.split("(").last
22
- end
23
- engine = ("#{engine_name}::Engine").constantize
24
-
25
- # Append the routes for this module to the existing routes
26
- ::Rails.application.routes.disable_clear_and_finalize = true
27
- ::Rails.application.routes.clear!
28
- ::Rails.application.routes_reloader.paths.each { |path| load(path) }
29
- ::Rails.application.routes.draw do
30
- resourced_routes = []
31
-
32
- named_routes = engine.routes.named_routes.routes
33
-
34
- engine.routes.routes.each do |route|
35
- # Call the method by hand based on the symbol
36
- path = "/#{engine_name.underscore}#{route.path.spec}"
37
- verb = route.verb.to_s.downcase.gsub(/^.+\^(.+)\$.+$/, '\1').to_sym
38
- requirements = route.requirements
39
- if path_helper = named_routes.key(route)
40
- requirements[:as] = path_helper
41
- elsif route.requirements[:controller].present?
42
- # Presume that all controllers referenced in routes should also be
43
- # resources and append that routing on the end so that *_path helpers
44
- # will still work
45
- resourced_routes << route.requirements[:controller].gsub("#{engine_name.underscore}/", "").to_sym
46
- end
47
- send(verb, path, requirements) if respond_to?(verb)
48
- end
49
-
50
- # Add each route, once, to the end under a scope to trick path helpers.
51
- # This will probably break as soon as there is route name overlap, but
52
- # we'll cross that bridge when we get to it.
53
- resourced_routes.uniq!
54
- scope engine_name.underscore do
55
- resourced_routes.each do |resource|
56
- resources resource
57
- end
58
- end
59
- end
60
-
61
- # Finalize the routes
62
- ::Rails.application.routes.finalize!
63
- ::Rails.application.routes.disable_clear_and_finalize = false
64
- end
65
- end
66
- end
67
- end
68
-
69
- Rails::Engine.send(:include, Magic::Rails::Engine)
@@ -1,4 +0,0 @@
1
- require 'magic/rails/engine'
2
-
3
- # Replace RspecRouting by the namespace used by your engine
4
- SharedEngine::Engine.load_engine_routes