acts_as_api 0.4.4 → 1.0.0

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 (161) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +4 -7
  3. data/History.txt +5 -0
  4. data/LICENSE.txt +20 -0
  5. data/README.md +0 -25
  6. data/Rakefile +5 -12
  7. data/acts_as_api.gemspec +14 -13
  8. data/{examples/introduction → docs}/docco.css +0 -0
  9. data/{examples/introduction → docs}/index.html +18 -21
  10. data/{examples/introduction → docs}/index.rb +0 -0
  11. data/{examples/introduction → docs}/layout.mustache +0 -0
  12. data/lib/acts_as_api.rb +9 -12
  13. data/lib/acts_as_api/adapters.rb +1 -1
  14. data/lib/acts_as_api/api_template.rb +23 -25
  15. data/lib/acts_as_api/base.rb +11 -20
  16. data/lib/acts_as_api/collection.rb +1 -2
  17. data/lib/acts_as_api/config.rb +0 -5
  18. data/lib/acts_as_api/exceptions.rb +2 -2
  19. data/lib/acts_as_api/rails_renderer.rb +0 -2
  20. data/lib/acts_as_api/rendering.rb +5 -12
  21. data/lib/acts_as_api/responder.rb +8 -13
  22. data/lib/acts_as_api/version.rb +1 -1
  23. data/spec/README.md +15 -6
  24. data/spec/active_record_dummy/Gemfile +2 -10
  25. data/spec/active_record_dummy/app/models/user.rb +31 -32
  26. data/spec/active_record_dummy/config.ru +1 -1
  27. data/spec/active_record_dummy/config/application.rb +2 -2
  28. data/spec/active_record_dummy/config/boot.rb +1 -1
  29. data/spec/active_record_dummy/config/environments/test.rb +2 -2
  30. data/spec/active_record_dummy/config/initializers/session_store.rb +1 -1
  31. data/spec/active_record_dummy/config/initializers/wrap_parameters.rb +1 -1
  32. data/spec/active_record_dummy/config/routes.rb +1 -57
  33. data/spec/active_record_dummy/db/migrate/20110214201640_create_tables.rb +25 -26
  34. data/spec/active_record_dummy/db/schema.rb +27 -29
  35. data/spec/active_record_dummy/script/rails +2 -2
  36. data/spec/controllers/plain_objects_controller_spec.rb +11 -12
  37. data/spec/controllers/respond_with_users_controller_spec.rb +46 -67
  38. data/spec/controllers/users_controller_spec.rb +2 -3
  39. data/spec/models/model_spec.rb +17 -19
  40. data/spec/mongoid_dummy/Gemfile +3 -12
  41. data/spec/mongoid_dummy/app/models/profile.rb +6 -6
  42. data/spec/mongoid_dummy/app/models/task.rb +10 -10
  43. data/spec/mongoid_dummy/app/models/untouched.rb +4 -4
  44. data/spec/mongoid_dummy/app/models/user.rb +12 -14
  45. data/spec/mongoid_dummy/config.ru +1 -1
  46. data/spec/mongoid_dummy/config/application.rb +7 -7
  47. data/spec/mongoid_dummy/config/boot.rb +1 -1
  48. data/spec/mongoid_dummy/config/environments/development.rb +0 -1
  49. data/spec/mongoid_dummy/config/environments/production.rb +0 -1
  50. data/spec/mongoid_dummy/config/environments/test.rb +2 -2
  51. data/spec/mongoid_dummy/config/initializers/include_acts_as_api.rb +1 -1
  52. data/spec/mongoid_dummy/config/initializers/session_store.rb +1 -1
  53. data/spec/mongoid_dummy/config/initializers/wrap_parameters.rb +1 -2
  54. data/spec/mongoid_dummy/config/routes.rb +1 -57
  55. data/spec/mongoid_dummy/script/rails +2 -2
  56. data/spec/shared_engine/Gemfile +1 -1
  57. data/spec/shared_engine/Rakefile +1 -4
  58. data/spec/shared_engine/app/controllers/shared_engine/plain_objects_controller.rb +2 -2
  59. data/spec/shared_engine/app/controllers/shared_engine/respond_with_users_controller.rb +13 -15
  60. data/spec/shared_engine/app/controllers/shared_engine/users_controller.rb +17 -19
  61. data/spec/shared_engine/app/models/plain_object.rb +3 -1
  62. data/spec/shared_engine/app/models/user_template.rb +28 -29
  63. data/spec/shared_engine/lib/shared_engine.rb +1 -1
  64. data/spec/shared_engine/lib/shared_engine/version.rb +1 -1
  65. data/spec/shared_engine/shared_engine.gemspec +10 -12
  66. data/spec/spec_helper.rb +5 -13
  67. data/spec/support/api_test_helpers.rb +0 -2
  68. data/spec/support/controller_examples.rb +128 -173
  69. data/spec/support/it_supports.rb +1 -1
  70. data/spec/support/model_examples/associations.rb +119 -128
  71. data/spec/support/model_examples/callbacks.rb +17 -27
  72. data/spec/support/model_examples/closures.rb +21 -29
  73. data/spec/support/model_examples/conditional_if.rb +71 -103
  74. data/spec/support/model_examples/conditional_unless.rb +71 -103
  75. data/spec/support/model_examples/enabled.rb +5 -6
  76. data/spec/support/model_examples/extending.rb +49 -56
  77. data/spec/support/model_examples/methods.rb +11 -15
  78. data/spec/support/model_examples/options.rb +19 -25
  79. data/spec/support/model_examples/renaming.rb +21 -30
  80. data/spec/support/model_examples/simple.rb +10 -14
  81. data/spec/support/model_examples/sub_nodes.rb +47 -59
  82. data/spec/support/model_examples/undefined.rb +4 -6
  83. data/spec/support/model_examples/untouched.rb +6 -8
  84. data/spec/support/simple_fixtures.rb +11 -38
  85. metadata +22 -159
  86. data/spec/active_record_dummy/app/assets/images/rails.png +0 -0
  87. data/spec/active_record_dummy/app/assets/javascripts/application.js +0 -15
  88. data/spec/active_record_dummy/app/assets/stylesheets/application.css +0 -13
  89. data/spec/active_record_dummy/app/controllers/application_controller.rb +0 -3
  90. data/spec/active_record_dummy/app/helpers/application_helper.rb +0 -2
  91. data/spec/active_record_dummy/app/mailers/.gitkeep +0 -0
  92. data/spec/active_record_dummy/app/views/layouts/application.html.erb +0 -14
  93. data/spec/active_record_dummy/doc/README_FOR_APP +0 -2
  94. data/spec/active_record_dummy/lib/assets/.gitkeep +0 -0
  95. data/spec/active_record_dummy/lib/tasks/.gitkeep +0 -0
  96. data/spec/active_record_dummy/public/404.html +0 -26
  97. data/spec/active_record_dummy/public/422.html +0 -26
  98. data/spec/active_record_dummy/public/500.html +0 -25
  99. data/spec/active_record_dummy/public/favicon.ico +0 -0
  100. data/spec/active_record_dummy/public/index.html +0 -241
  101. data/spec/active_record_dummy/public/robots.txt +0 -5
  102. data/spec/active_record_dummy/vendor/assets/javascripts/.gitkeep +0 -0
  103. data/spec/active_record_dummy/vendor/assets/stylesheets/.gitkeep +0 -0
  104. data/spec/active_record_dummy/vendor/plugins/.gitkeep +0 -0
  105. data/spec/mongoid_dummy/README.rdoc +0 -261
  106. data/spec/mongoid_dummy/app/assets/images/rails.png +0 -0
  107. data/spec/mongoid_dummy/app/assets/javascripts/application.js +0 -15
  108. data/spec/mongoid_dummy/app/assets/stylesheets/application.css +0 -13
  109. data/spec/mongoid_dummy/app/controllers/application_controller.rb +0 -3
  110. data/spec/mongoid_dummy/app/helpers/application_helper.rb +0 -2
  111. data/spec/mongoid_dummy/app/mailers/.gitkeep +0 -0
  112. data/spec/mongoid_dummy/app/views/layouts/application.html.erb +0 -14
  113. data/spec/mongoid_dummy/doc/README_FOR_APP +0 -2
  114. data/spec/mongoid_dummy/lib/assets/.gitkeep +0 -0
  115. data/spec/mongoid_dummy/lib/tasks/.gitkeep +0 -0
  116. data/spec/mongoid_dummy/public/404.html +0 -26
  117. data/spec/mongoid_dummy/public/422.html +0 -26
  118. data/spec/mongoid_dummy/public/500.html +0 -25
  119. data/spec/mongoid_dummy/public/favicon.ico +0 -0
  120. data/spec/mongoid_dummy/public/index.html +0 -241
  121. data/spec/mongoid_dummy/public/robots.txt +0 -5
  122. data/spec/mongoid_dummy/vendor/assets/javascripts/.gitkeep +0 -0
  123. data/spec/mongoid_dummy/vendor/assets/stylesheets/.gitkeep +0 -0
  124. data/spec/mongoid_dummy/vendor/plugins/.gitkeep +0 -0
  125. data/spec/shared_engine/app/assets/images/shared_engine/.gitkeep +0 -0
  126. data/spec/shared_engine/app/assets/javascripts/shared_engine/application.js +0 -15
  127. data/spec/shared_engine/app/assets/stylesheets/shared_engine/application.css +0 -13
  128. data/spec/shared_engine/app/helpers/shared_engine/application_helper.rb +0 -4
  129. data/spec/shared_engine/app/views/layouts/shared_engine/application.html.erb +0 -14
  130. data/spec/shared_engine/dummy/README.rdoc +0 -261
  131. data/spec/shared_engine/dummy/Rakefile +0 -7
  132. data/spec/shared_engine/dummy/app/assets/javascripts/application.js +0 -15
  133. data/spec/shared_engine/dummy/app/assets/stylesheets/application.css +0 -13
  134. data/spec/shared_engine/dummy/app/controllers/application_controller.rb +0 -3
  135. data/spec/shared_engine/dummy/app/helpers/application_helper.rb +0 -2
  136. data/spec/shared_engine/dummy/app/mailers/.gitkeep +0 -0
  137. data/spec/shared_engine/dummy/app/models/.gitkeep +0 -0
  138. data/spec/shared_engine/dummy/app/views/layouts/application.html.erb +0 -14
  139. data/spec/shared_engine/dummy/config.ru +0 -4
  140. data/spec/shared_engine/dummy/config/application.rb +0 -56
  141. data/spec/shared_engine/dummy/config/boot.rb +0 -10
  142. data/spec/shared_engine/dummy/config/database.yml +0 -25
  143. data/spec/shared_engine/dummy/config/environment.rb +0 -5
  144. data/spec/shared_engine/dummy/config/environments/development.rb +0 -34
  145. data/spec/shared_engine/dummy/config/environments/production.rb +0 -63
  146. data/spec/shared_engine/dummy/config/environments/test.rb +0 -37
  147. data/spec/shared_engine/dummy/config/initializers/backtrace_silencers.rb +0 -7
  148. data/spec/shared_engine/dummy/config/initializers/inflections.rb +0 -15
  149. data/spec/shared_engine/dummy/config/initializers/mime_types.rb +0 -5
  150. data/spec/shared_engine/dummy/config/initializers/secret_token.rb +0 -7
  151. data/spec/shared_engine/dummy/config/initializers/session_store.rb +0 -8
  152. data/spec/shared_engine/dummy/config/initializers/wrap_parameters.rb +0 -14
  153. data/spec/shared_engine/dummy/config/locales/en.yml +0 -5
  154. data/spec/shared_engine/dummy/config/routes.rb +0 -4
  155. data/spec/shared_engine/dummy/lib/assets/.gitkeep +0 -0
  156. data/spec/shared_engine/dummy/log/.gitkeep +0 -0
  157. data/spec/shared_engine/dummy/public/404.html +0 -26
  158. data/spec/shared_engine/dummy/public/422.html +0 -26
  159. data/spec/shared_engine/dummy/public/500.html +0 -25
  160. data/spec/shared_engine/dummy/public/favicon.ico +0 -0
  161. data/spec/shared_engine/dummy/script/rails +0 -6
@@ -1,15 +1,14 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe SharedEngine::UsersController, type: :controller do
4
-
5
4
  before(:each) do
6
5
  setup_models
7
6
  end
8
7
 
9
8
  after(:each) do
10
- clean_up_models
9
+ clean_up_models
11
10
  end
12
11
 
13
12
  # see spec/support/controller_examples.rb
14
- it_behaves_like "a controller with ActsAsApi responses"
13
+ it_behaves_like 'a controller with ActsAsApi responses'
15
14
  end
@@ -1,7 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe "Models" do
4
-
3
+ describe 'Models', type: :model do
5
4
  before(:each) do
6
5
  setup_models
7
6
  end
@@ -9,23 +8,22 @@ describe "Models" do
9
8
  after(:each) do
10
9
  clean_up_models
11
10
  end
12
-
11
+
13
12
  describe :act_as_api do
14
- it_supports "including an association in the api template"
15
- it_supports "calling a closure in the api template"
16
- it_supports "conditional if statements"
17
- it_supports "conditional unless statements"
18
- it_supports "acts_as_api is enabled"
19
- it_supports "extending a given api template"
20
- it_supports "calling a method in the api template"
21
- it_supports "renaming"
22
- it_supports "listing attributes in the api template"
23
- it_supports "creating a sub hash in the api template"
24
- it_supports "trying to render an api template that is not defined"
13
+ it_supports 'including an association in the api template'
14
+ it_supports 'calling a closure in the api template'
15
+ it_supports 'conditional if statements'
16
+ it_supports 'conditional unless statements'
17
+ it_supports 'acts_as_api is enabled'
18
+ it_supports 'extending a given api template'
19
+ it_supports 'calling a method in the api template'
20
+ it_supports 'renaming'
21
+ it_supports 'listing attributes in the api template'
22
+ it_supports 'creating a sub hash in the api template'
23
+ it_supports 'trying to render an api template that is not defined'
25
24
  # deactivated for vanilla ruby as acts_as_api won't get mixed into any class
26
- it_supports "untouched models"
27
- it_supports "defining a model callback"
28
- it_supports "options"
25
+ it_supports 'untouched models'
26
+ it_supports 'defining a model callback'
27
+ it_supports 'options'
29
28
  end
30
-
31
- end
29
+ end
@@ -2,17 +2,8 @@ source 'https://rubygems.org'
2
2
 
3
3
  gem 'rails', '5.0.0.1'
4
4
 
5
- # Bundle edge Rails instead:
6
- # gem 'rails', :git => 'git://github.com/rails/rails.git'
7
-
8
-
9
- gem "bson_ext"
5
+ gem 'bson_ext'
10
6
  gem 'mongoid', '>= 6.0.2'
11
7
 
12
- gem 'shared_engine', :path => '../shared_engine'
13
- gem 'acts_as_api', :path => '../../'
14
-
15
- group :test do
16
- gem 'rspec-rails', '>= 2.5.0'
17
- gem 'webrat'
18
- end
8
+ gem 'shared_engine', path: '../shared_engine'
9
+ gem 'acts_as_api', path: '../../'
@@ -1,10 +1,10 @@
1
1
  class Profile
2
2
  include Mongoid::Document
3
3
 
4
- field :avatar, :type => String
5
- field :homepage, :type => String
6
- field :created_at, :type => DateTime
7
- field :updated_at, :type => DateTime
4
+ field :avatar, type: String
5
+ field :homepage, type: String
6
+ field :created_at, type: DateTime
7
+ field :updated_at, type: DateTime
8
8
 
9
- embedded_in :user, :class_name => "User", :inverse_of => :profile
10
- end
9
+ embedded_in :user, class_name: 'User', inverse_of: :profile
10
+ end
@@ -1,12 +1,12 @@
1
1
  class Task
2
2
  include Mongoid::Document
3
-
4
- field :heading, :type => String
5
- field :description, :type => String
6
- field :time_spent, :type => Integer
7
- field :done, :type => Boolean
8
- field :created_at, :type => DateTime
9
- field :updated_at, :type => DateTime
10
-
11
- embedded_in :user, :class_name => "User", :inverse_of => :task
12
- end
3
+
4
+ field :heading, type: String
5
+ field :description, type: String
6
+ field :time_spent, type: Integer
7
+ field :done, type: Boolean
8
+ field :created_at, type: DateTime
9
+ field :updated_at, type: DateTime
10
+
11
+ embedded_in :user, class_name: 'User', inverse_of: :task
12
+ end
@@ -1,7 +1,7 @@
1
1
  class Untouched
2
2
  include Mongoid::Document
3
-
4
- field :nothing, :type => String
5
- field :created_at, :type => DateTime
6
- field :updated_at, :type => DateTime
3
+
4
+ field :nothing, type: String
5
+ field :created_at, type: DateTime
6
+ field :updated_at, type: DateTime
7
7
  end
@@ -1,18 +1,17 @@
1
1
  class User
2
-
3
2
  include Mongoid::Document
4
3
 
5
- field :first_name, :type => String
6
- field :last_name, :type => String
7
- field :age, :type => Integer
8
- field :active, :type => Boolean
9
- field :created_at, :type => DateTime
10
- field :updated_at, :type => DateTime
4
+ field :first_name, type: String
5
+ field :last_name, type: String
6
+ field :age, type: Integer
7
+ field :active, type: Boolean
8
+ field :created_at, type: DateTime
9
+ field :updated_at, type: DateTime
11
10
 
12
- embeds_one :profile, :class_name => "Profile", :inverse_of => :user
13
- embeds_many :tasks, :class_name => "Task", :inverse_of => :user
11
+ embeds_one :profile, class_name: 'Profile', inverse_of: :user
12
+ embeds_many :tasks, class_name: 'Task', inverse_of: :user
14
13
 
15
- validates :first_name, :last_name, :presence => true
14
+ validates :first_name, :last_name, presence: true
16
15
 
17
16
  acts_as_api
18
17
 
@@ -35,14 +34,13 @@ class User
35
34
  end
36
35
 
37
36
  def say_something
38
- "something"
37
+ 'something'
39
38
  end
40
39
 
41
40
  def sub_hash
42
41
  {
43
- :foo => "bar",
44
- :hello => "world"
42
+ foo: 'bar',
43
+ hello: 'world'
45
44
  }
46
45
  end
47
-
48
46
  end
@@ -1,4 +1,4 @@
1
1
  # This file is used by Rack-based servers to start the application.
2
2
 
3
- require ::File.expand_path('../config/environment', __FILE__)
3
+ require ::File.expand_path('../config/environment', __FILE__)
4
4
  run MongoidDummy::Application
@@ -1,15 +1,15 @@
1
1
  require File.expand_path('../boot', __FILE__)
2
2
 
3
3
  # Pick the frameworks you want:
4
- # require "active_record/railtie"
5
- require "action_controller/railtie"
6
- require "action_mailer/railtie"
7
- require "sprockets/railtie"
8
- require "rails/test_unit/railtie"
4
+ # require 'active_record/railtie'
5
+ require 'action_controller/railtie'
6
+ require 'action_mailer/railtie'
7
+ require 'sprockets/railtie'
8
+ require 'rails/test_unit/railtie'
9
9
 
10
10
  if defined?(Bundler)
11
11
  # If you precompile assets before deploying to production, use this line
12
- Bundler.require(*Rails.groups(:assets => %w(development test)))
12
+ Bundler.require(*Rails.groups(assets: %w(development test)))
13
13
  # If you want your assets lazily compiled in production, use this line
14
14
  # Bundler.require(:default, :assets, Rails.env)
15
15
  end
@@ -39,7 +39,7 @@ module MongoidDummy
39
39
  # config.i18n.default_locale = :de
40
40
 
41
41
  # Configure the default encoding used in templates for Ruby 1.9.
42
- config.encoding = "utf-8"
42
+ config.encoding = 'utf-8'
43
43
 
44
44
  # Configure sensitive parameters which will be filtered from the log file.
45
45
  config.filter_parameters += [:password]
@@ -3,4 +3,4 @@ require 'rubygems'
3
3
  # Set up gems listed in the Gemfile.
4
4
  ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
5
5
 
6
- require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
6
+ require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
@@ -22,7 +22,6 @@ MongoidDummy::Application.configure do
22
22
  # Only use best-standards-support built into browsers
23
23
  config.action_dispatch.best_standards_support = :builtin
24
24
 
25
-
26
25
  # Do not compress assets
27
26
  config.assets.compress = false
28
27
 
@@ -60,5 +60,4 @@ MongoidDummy::Application.configure do
60
60
 
61
61
  # Send deprecation notices to registered listeners
62
62
  config.active_support.deprecation = :notify
63
-
64
63
  end
@@ -14,14 +14,14 @@ MongoidDummy::Application.configure do
14
14
  config.whiny_nils = true
15
15
 
16
16
  # Show full error reports and disable caching
17
- config.consider_all_requests_local = true
17
+ config.consider_all_requests_local = true
18
18
  config.action_controller.perform_caching = false
19
19
 
20
20
  # Raise exceptions instead of rendering exception templates
21
21
  config.action_dispatch.show_exceptions = false
22
22
 
23
23
  # Disable request forgery protection in test environment
24
- config.action_controller.allow_forgery_protection = false
24
+ config.action_controller.allow_forgery_protection = false
25
25
 
26
26
  # Tell Action Mailer not to deliver emails to the real world.
27
27
  # The :test delivery method accumulates sent emails in the
@@ -1,3 +1,3 @@
1
1
  if defined?(Mongoid::Document)
2
2
  Mongoid::Document.send :include, ActsAsApi::Adapters::Mongoid
3
- end
3
+ end
@@ -1,6 +1,6 @@
1
1
  # Be sure to restart your server when you modify this file.
2
2
 
3
- MongoidDummy::Application.config.session_store :cookie_store, :key => '_mongoid_dummy_session'
3
+ MongoidDummy::Application.config.session_store :cookie_store, key: '_mongoid_dummy_session'
4
4
 
5
5
  # Use the database for sessions instead of the cookie-based default,
6
6
  # which shouldn't be used to store highly confidential information
@@ -5,6 +5,5 @@
5
5
 
6
6
  # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
7
7
  ActiveSupport.on_load(:action_controller) do
8
- wrap_parameters :format => [:json]
8
+ wrap_parameters format: [:json]
9
9
  end
10
-
@@ -1,59 +1,3 @@
1
1
  MongoidDummy::Application.routes.draw do
2
- mount SharedEngine::Engine => "/shared", :as => "shared"
3
- # The priority is based upon order of creation:
4
- # first created -> highest priority.
5
-
6
- # Sample of regular route:
7
- # match 'products/:id' => 'catalog#view'
8
- # Keep in mind you can assign values other than :controller and :action
9
-
10
- # Sample of named route:
11
- # match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase
12
- # This route can be invoked with purchase_url(:id => product.id)
13
-
14
- # Sample resource route (maps HTTP verbs to controller actions automatically):
15
- # resources :products
16
-
17
- # Sample resource route with options:
18
- # resources :products do
19
- # member do
20
- # get 'short'
21
- # post 'toggle'
22
- # end
23
- #
24
- # collection do
25
- # get 'sold'
26
- # end
27
- # end
28
-
29
- # Sample resource route with sub-resources:
30
- # resources :products do
31
- # resources :comments, :sales
32
- # resource :seller
33
- # end
34
-
35
- # Sample resource route with more complex sub-resources
36
- # resources :products do
37
- # resources :comments
38
- # resources :sales do
39
- # get 'recent', :on => :collection
40
- # end
41
- # end
42
-
43
- # Sample resource route within a namespace:
44
- # namespace :admin do
45
- # # Directs /admin/products/* to Admin::ProductsController
46
- # # (app/controllers/admin/products_controller.rb)
47
- # resources :products
48
- # end
49
-
50
- # You can have the root of your site routed with "root"
51
- # just remember to delete public/index.html.
52
- # root :to => 'welcome#index'
53
-
54
- # See how all your routes lay out with "rake routes"
55
-
56
- # This is a legacy wild controller route that's not recommended for RESTful applications.
57
- # Note: This route will make all actions in every controller accessible via GET requests.
58
- # match ':controller(/:action(/:id))(.:format)'
2
+ mount SharedEngine::Engine => '/shared', :as => 'shared'
59
3
  end
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
  # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
3
 
4
- APP_PATH = File.expand_path('../../config/application', __FILE__)
5
- require File.expand_path('../../config/boot', __FILE__)
4
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
5
+ require File.expand_path('../../config/boot', __FILE__)
6
6
  require 'rails/commands'
@@ -1,4 +1,4 @@
1
- source "http://rubygems.org"
1
+ source 'http://rubygems.org'
2
2
 
3
3
  # Declare your gem's dependencies in shared_engine.gemspec.
4
4
  # Bundler will treat runtime dependencies like base dependencies, and
@@ -20,10 +20,7 @@ RDoc::Task.new(:rdoc) do |rdoc|
20
20
  rdoc.rdoc_files.include('lib/**/*.rb')
21
21
  end
22
22
 
23
- APP_RAKEFILE = File.expand_path("../active_record_dummy/Rakefile", __FILE__)
23
+ APP_RAKEFILE = File.expand_path('../active_record_dummy/Rakefile', __FILE__)
24
24
  load 'rails/tasks/engine.rake'
25
25
 
26
-
27
-
28
26
  Bundler::GemHelper.install_tasks
29
-
@@ -6,8 +6,8 @@ module SharedEngine
6
6
  @users = [@han, @luke, @leia]
7
7
 
8
8
  respond_to do |format|
9
- format.xml { render_for_api params[:api_template].to_sym, :xml => @users }
10
- format.json { render_for_api params[:api_template].to_sym, :json => @users }
9
+ format.xml { render_for_api params[:api_template].to_sym, xml: @users }
10
+ format.json { render_for_api params[:api_template].to_sym, json: @users }
11
11
  end
12
12
  end
13
13
  end
@@ -1,42 +1,41 @@
1
1
  module SharedEngine
2
2
  class RespondWithUsersController < SharedEngine::ApplicationController
3
-
4
3
  respond_to :json, :xml
5
4
 
6
5
  self.responder = ActsAsApi::Responder
7
6
 
8
7
  def index
9
8
  @users = User.all.sort_by(&:first_name)
10
- respond_with @users, :api_template => params[:api_template].to_sym, :root => :users
9
+ respond_with @users, api_template: params[:api_template].to_sym, root: :users
11
10
  end
12
11
 
13
12
  def index_no_root_no_order
14
13
  @users = User.all.to_a
15
- respond_with @users, :api_template => params[:api_template].to_sym
14
+ respond_with @users, api_template: params[:api_template].to_sym
16
15
  end
17
16
 
18
17
  def index_meta
19
18
  @users = User.all.to_a
20
- meta_hash = { :page => 1, :total => 999 }
21
- respond_with @users, :api_template => params[:api_template].to_sym, :root => :users, :meta => meta_hash
19
+ meta_hash = { page: 1, total: 999 }
20
+ respond_with @users, api_template: params[:api_template].to_sym, root: :users, meta: meta_hash
22
21
  end
23
22
 
24
23
  def index_relation
25
24
  @users = User.limit(100).sort_by(&:first_name)
26
- respond_with @users, :api_template => params[:api_template].to_sym
25
+ respond_with @users, api_template: params[:api_template].to_sym
27
26
  end
28
27
 
29
28
  def show
30
29
  @user = User.find(params[:id])
31
- # :root => :user is only used here because we need it for the node name of the MongoUser model
32
- respond_with @user, :api_template => params[:api_template].to_sym, :root => :user
30
+ # root: :user is only used here because we need it for the node name of the MongoUser model
31
+ respond_with @user, api_template: params[:api_template].to_sym, root: :user
33
32
  end
34
33
 
35
34
  def show_meta
36
35
  @user = User.find(params[:id])
37
- meta_hash = { :page => 1, :total => 999 }
38
- # :root => :user is only used here because we need it for the node name of the MongoUser model
39
- respond_with @user, :api_template => params[:api_template].to_sym, :root => :user, :meta => meta_hash
36
+ meta_hash = { page: 1, total: 999 }
37
+ # root: :user is only used here because we need it for the node name of the MongoUser model
38
+ respond_with @user, api_template: params[:api_template].to_sym, root: :user, meta: meta_hash
40
39
  end
41
40
 
42
41
  def show_default
@@ -46,19 +45,18 @@ module SharedEngine
46
45
 
47
46
  def show_prefix_postfix
48
47
  @user = User.find(params[:id])
49
- # :root => :user is only used here because we need it for the node name of the MongoUser model
50
- respond_with @user, :api_template => {:template => params[:api_template], :prefix => params[:api_prefix], :postfix => params[:api_postfix]}, :root => :user
48
+ # root: :user is only used here because we need it for the node name of the MongoUser model
49
+ respond_with @user, api_template: { template: params[:api_template], prefix: params[:api_prefix], postfix: params[:api_postfix] }, root: :user
51
50
  end
52
51
 
53
52
  def create
54
53
  @user = User.new(params[:user].permit!)
55
54
 
56
55
  if @user.save
57
- respond_with @user, :api_template => params[:api_template]
56
+ respond_with @user, api_template: params[:api_template]
58
57
  else
59
58
  respond_with @user
60
59
  end
61
60
  end
62
-
63
61
  end
64
62
  end