rails-api 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Rails::API
2
2
 
3
- [![Build Status](https://secure.travis-ci.org/spastorino/rails-api.png?branch=master)](http://travis-ci.org/spastorino/rails-api)
3
+ [![Build Status](https://secure.travis-ci.org/rails-api/rails-api.png?branch=master)](http://travis-ci.org/rails-api/rails-api)
4
4
 
5
5
  **Rails::API** is a subset of a normal Rails application, created for applications that don't require all functionality that a complete Rails application provides. It is a bit more lightweight, and consequently a bit faster than a normal Rails application. The main example for its usage is in API applications only, where you usually don't need the entire Rails middleware stack nor template generation.
6
6
 
@@ -107,6 +107,8 @@ end
107
107
 
108
108
  And comment out the `protect_from_forgery` call if you are using it.
109
109
 
110
+ If you want to use the Rails default middleware stack (avoid the reduction that rails-api does), you can just add config.api_only = false to config/application.rb file.
111
+
110
112
  ### Choosing Middlewares
111
113
 
112
114
  An API application comes with the following middlewares by default.
@@ -206,7 +208,12 @@ The best place to add a module is in your *ApplicationController*. You can also
206
208
 
207
209
  * Santiago Pastorino (https://github.com/spastorino)
208
210
  * Carlos Antonio da Silva (https://github.com/carlosantoniodasilva)
211
+ * Steve Klabnik (https://github.com/steveklabnik)
209
212
 
210
213
  ## License
211
214
 
212
215
  MIT License.
216
+
217
+ ## Mailing List
218
+
219
+ https://groups.google.com/forum/?fromgroups#!forum/rails-api-core
@@ -95,7 +95,6 @@ module ActionController
95
95
  def asset_host=(*); end
96
96
  def relative_url_root=(*); end
97
97
  def perform_caching=(*); end
98
- def wrap_parameters(*); end
99
98
  def helpers_path=(*); end
100
99
  def allow_forgery_protection=(*); end
101
100
  def helper_method(*); end
@@ -1,17 +1,65 @@
1
1
  require 'rails/version'
2
2
  require 'rails/application'
3
+ require 'rails-api/public_exceptions'
3
4
 
4
5
  module Rails
5
6
  class Application < Engine
6
7
  def default_middleware_stack
8
+ if Rails.version =~ /4\..\../
9
+ rails_four_stack
10
+ else
11
+ rails_three_stack
12
+ end
13
+ end
14
+
15
+ private
16
+
17
+ def setup_generators!
18
+ generators = config.generators
19
+
20
+ generators.templates.unshift File::expand_path('../templates', __FILE__)
21
+ generators.resource_route = :api_resource_route
22
+
23
+ generators.hide_namespace "css"
24
+
25
+ generators.rails({
26
+ :helper => false,
27
+ :stylesheets => false,
28
+ :stylesheet_engine => nil,
29
+ :template_engine => nil
30
+ })
31
+ end
32
+
33
+ ActiveSupport.on_load(:before_configuration) do
34
+ config.api_only = true
35
+ setup_generators!
36
+ end
37
+
38
+ def rails_four_stack
7
39
  ActionDispatch::MiddlewareStack.new.tap do |middleware|
8
- if rack_cache = config.action_controller.perform_caching && config.action_dispatch.rack_cache
40
+ app = self
41
+ if rack_cache = config.action_dispatch.rack_cache
42
+ begin
43
+ require 'rack/cache'
44
+ rescue LoadError => error
45
+ error.message << ' Be sure to add rack-cache to your Gemfile'
46
+ raise
47
+ end
48
+
49
+ if rack_cache == true
50
+ rack_cache = {
51
+ metastore: "rails:/",
52
+ entitystore: "rails:/",
53
+ verbose: false
54
+ }
55
+ end
56
+
9
57
  require "action_dispatch/http/rack_cache"
10
58
  middleware.use ::Rack::Cache, rack_cache
11
59
  end
12
60
 
13
61
  if config.force_ssl
14
- middleware.use ssl_module, config.ssl_options
62
+ middleware.use ::ActionDispatch::SSL, config.ssl_options
15
63
  end
16
64
 
17
65
  if config.action_dispatch.x_sendfile_header.present?
@@ -22,82 +70,95 @@ module Rails
22
70
  middleware.use ::ActionDispatch::Static, paths["public"].first, config.static_cache_control
23
71
  end
24
72
 
25
- middleware.use ::Rack::Lock unless config.allow_concurrency
73
+ middleware.use ::Rack::Lock unless config.cache_classes
26
74
  middleware.use ::Rack::Runtime
75
+ middleware.use ::Rack::MethodOverride
27
76
  middleware.use ::ActionDispatch::RequestId
28
77
  middleware.use ::Rails::Rack::Logger, config.log_tags # must come after Rack::MethodOverride to properly log overridden methods
29
78
  middleware.use ::ActionDispatch::ShowExceptions, config.exceptions_app || ActionDispatch::PublicExceptions.new(Rails.public_path)
30
- middleware.use ::ActionDispatch::DebugExceptions
79
+ middleware.use ::ActionDispatch::DebugExceptions, app
31
80
  middleware.use ::ActionDispatch::RemoteIp, config.action_dispatch.ip_spoofing_check, config.action_dispatch.trusted_proxies
32
81
 
33
82
  unless config.cache_classes
34
- app = self
35
83
  middleware.use ::ActionDispatch::Reloader, lambda { app.reload_dependencies? }
36
84
  end
37
85
 
38
86
  middleware.use ::ActionDispatch::Callbacks
87
+ middleware.use ::ActionDispatch::Cookies
88
+
89
+ if config.session_store
90
+ if config.force_ssl && !config.session_options.key?(:secure)
91
+ config.session_options[:secure] = true
92
+ end
93
+ middleware.use config.session_store, config.session_options
94
+ middleware.use ::ActionDispatch::Flash
95
+ end
39
96
 
40
97
  middleware.use ::ActionDispatch::ParamsParser
41
- middleware.use ::ActionDispatch::Head
98
+ middleware.use ::Rack::Head
42
99
  middleware.use ::Rack::ConditionalGet
43
100
  middleware.use ::Rack::ETag, "no-cache"
44
- end
45
- end
46
101
 
47
- if Rails::VERSION::STRING <= "3.2.3"
48
- def load_generators(app=self)
49
- super
50
- require 'rails/generators/rails/resource/resource_generator'
51
- Rails::Generators::ResourceGenerator.class_eval do
52
- def add_resource_route
53
- return if options[:actions].present?
54
- route_config = regular_class_path.collect{|namespace| "namespace :#{namespace} do " }.join(" ")
55
- route_config << "resources :#{file_name.pluralize}"
56
- route_config << ", except: :edit"
57
- route_config << " end" * regular_class_path.size
58
- route route_config
59
- end
102
+ if config.action_dispatch.best_standards_support
103
+ middleware.use ::ActionDispatch::BestStandardsSupport, config.action_dispatch.best_standards_support
60
104
  end
61
- self
62
105
  end
63
106
  end
64
107
 
65
- private
108
+ def rails_three_stack
109
+ ActionDispatch::MiddlewareStack.new.tap do |middleware|
110
+ if rack_cache = config.action_controller.perform_caching && config.action_dispatch.rack_cache
111
+ require "action_dispatch/http/rack_cache"
112
+ middleware.use ::Rack::Cache, rack_cache
113
+ end
66
114
 
67
- def ssl_module
68
- if defined? ::ActionDispatch::SSL
69
- ::ActionDispatch::SSL
70
- else
71
- require 'rack/ssl'
72
- ::Rack::SSL
73
- end
74
- end
115
+ if config.force_ssl
116
+ require "rack/ssl"
117
+ middleware.use ::Rack::SSL, config.ssl_options
118
+ end
75
119
 
76
- def setup_generators!
77
- generators = config.generators
120
+ if config.action_dispatch.x_sendfile_header.present?
121
+ middleware.use ::Rack::Sendfile, config.action_dispatch.x_sendfile_header
122
+ end
78
123
 
79
- generators.templates.unshift File::expand_path('../templates', __FILE__)
80
- if Rails::VERSION::STRING > "3.2.3"
81
- generators.resource_route = :api_resource_route
82
- end
124
+ if config.serve_static_assets
125
+ middleware.use ::ActionDispatch::Static, paths["public"].first, config.static_cache_control
126
+ end
83
127
 
84
- %w(assets css js session_migration).each do |namespace|
85
- generators.hide_namespace namespace
86
- end
128
+ middleware.use ::Rack::Lock unless config.allow_concurrency
129
+ middleware.use ::Rack::Runtime
130
+ middleware.use ::Rack::MethodOverride unless config.api_only
131
+ middleware.use ::ActionDispatch::RequestId
132
+ middleware.use ::Rails::Rack::Logger, config.log_tags # must come after Rack::MethodOverride to properly log overridden methods
133
+ middleware.use ::ActionDispatch::ShowExceptions, config.exceptions_app || Rails::API::PublicExceptions.new(Rails.public_path)
134
+ middleware.use ::ActionDispatch::DebugExceptions
135
+ middleware.use ::ActionDispatch::RemoteIp, config.action_dispatch.ip_spoofing_check, config.action_dispatch.trusted_proxies
87
136
 
88
- generators.rails({
89
- :assets => false,
90
- :helper => false,
91
- :javascripts => false,
92
- :javascript_engine => nil,
93
- :stylesheets => false,
94
- :stylesheet_engine => nil,
95
- :template_engine => nil
96
- })
97
- end
137
+ unless config.cache_classes
138
+ app = self
139
+ middleware.use ::ActionDispatch::Reloader, lambda { app.reload_dependencies? }
140
+ end
98
141
 
99
- ActiveSupport.on_load(:before_configuration) do
100
- setup_generators!
142
+ middleware.use ::ActionDispatch::Callbacks
143
+ middleware.use ::ActionDispatch::Cookies unless config.api_only
144
+
145
+ if !config.api_only && config.session_store
146
+ if config.force_ssl && !config.session_options.key?(:secure)
147
+ config.session_options[:secure] = true
148
+ end
149
+ middleware.use config.session_store, config.session_options
150
+ middleware.use ::ActionDispatch::Flash
151
+ end
152
+
153
+ middleware.use ::ActionDispatch::ParamsParser
154
+ middleware.use ::ActionDispatch::Head
155
+ middleware.use ::Rack::ConditionalGet
156
+ middleware.use ::Rack::ETag, "no-cache"
157
+
158
+ if !config.api_only && config.action_dispatch.best_standards_support
159
+ middleware.use ::ActionDispatch::BestStandardsSupport, config.action_dispatch.best_standards_support
160
+ end
161
+ end
101
162
  end
102
163
  end
103
164
  end
@@ -0,0 +1,49 @@
1
+ module Rails
2
+ module API
3
+ class PublicExceptions
4
+ attr_accessor :public_path
5
+
6
+ def initialize(public_path)
7
+ @public_path = public_path
8
+ end
9
+
10
+ def call(env)
11
+ exception = env["action_dispatch.exception"]
12
+ status = env["PATH_INFO"][1..-1]
13
+ request = ActionDispatch::Request.new(env)
14
+ content_type = request.formats.first
15
+ body = { :status => status, :error => exception.message }
16
+
17
+ render(status, content_type, body)
18
+ end
19
+
20
+ private
21
+
22
+ def render(status, content_type, body)
23
+ format = content_type && "to_#{content_type.to_sym}"
24
+ if format && body.respond_to?(format)
25
+ render_format(status, content_type, body.public_send(format))
26
+ else
27
+ render_html(status)
28
+ end
29
+ end
30
+
31
+ def render_format(status, content_type, body)
32
+ [status, {'Content-Type' => "#{content_type}; charset=#{ActionDispatch::Response.default_charset}",
33
+ 'Content-Length' => body.bytesize.to_s}, [body]]
34
+ end
35
+
36
+ def render_html(status)
37
+ found = false
38
+ path = "#{public_path}/#{status}.#{I18n.locale}.html" if I18n.locale
39
+ path = "#{public_path}/#{status}.html" unless path && (found = File.exist?(path))
40
+
41
+ if found || File.exist?(path)
42
+ render_format(status, 'text/html', File.read(path))
43
+ else
44
+ [404, { "X-Cascade" => "pass" }, []]
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,15 @@
1
+ # Be sure to restart your server when you modify this file.
2
+ #
3
+ # This file contains settings for ActionController::ParamsWrapper
4
+
5
+ # Enable parameter wrapping for JSON.
6
+ # ActiveSupport.on_load(:action_controller) do
7
+ # wrap_parameters format: [:json] if respond_to?(:wrap_parameters)
8
+ # end
9
+
10
+ <%- unless options.skip_active_record? -%>
11
+ # To enable root element in JSON for ActiveRecord objects.
12
+ # ActiveSupport.on_load(:active_record) do
13
+ # self.include_root_in_json = true
14
+ # end
15
+ <%- end -%>
@@ -1,5 +1,5 @@
1
1
  module Rails
2
2
  module API
3
- VERSION = "0.0.2"
3
+ VERSION = "0.0.3"
4
4
  end
5
5
  end
@@ -2,6 +2,8 @@ require 'test_helper'
2
2
  require 'action_controller/railtie'
3
3
  require 'rack/test'
4
4
 
5
+ app.initialize!
6
+
5
7
  class OmgController < ActionController::API
6
8
  def index
7
9
  render :text => "OMG"
@@ -12,10 +14,62 @@ class ApiApplicationTest < ActiveSupport::TestCase
12
14
  include ::Rack::Test::Methods
13
15
 
14
16
  def test_boot_api_app
15
- app.initialize!
16
-
17
17
  get "/omg"
18
18
  assert_equal 200, last_response.status
19
19
  assert_equal "OMG", last_response.body
20
20
  end
21
+
22
+ def test_api_middleware_stack
23
+ expected_middleware_stack =
24
+ rails4? ? expected_middleware_stack_rails4 : expected_middleware_stack_rails3
25
+
26
+ assert_equal expected_middleware_stack, app.middleware.map(&:klass).map(&:name)
27
+ end
28
+
29
+ private
30
+
31
+ def expected_middleware_stack_rails3
32
+ [
33
+ "ActionDispatch::Static",
34
+ "Rack::Lock",
35
+ "ActiveSupport::Cache::Strategy::LocalCache",
36
+ "Rack::Runtime",
37
+ "ActionDispatch::RequestId",
38
+ "Rails::Rack::Logger",
39
+ "ActionDispatch::ShowExceptions",
40
+ "ActionDispatch::DebugExceptions",
41
+ "ActionDispatch::RemoteIp",
42
+ "ActionDispatch::Reloader",
43
+ "ActionDispatch::Callbacks",
44
+ "ActionDispatch::ParamsParser",
45
+ "ActionDispatch::Head",
46
+ "Rack::ConditionalGet",
47
+ "Rack::ETag"
48
+ ]
49
+ end
50
+
51
+ def expected_middleware_stack_rails4
52
+ [
53
+ "ActionDispatch::Static",
54
+ "Rack::Lock",
55
+ "ActiveSupport::Cache::Strategy::LocalCache",
56
+ "Rack::Runtime",
57
+ "Rack::MethodOverride",
58
+ "ActionDispatch::RequestId",
59
+ "Rails::Rack::Logger",
60
+ "ActionDispatch::ShowExceptions",
61
+ "ActionDispatch::DebugExceptions",
62
+ "ActionDispatch::RemoteIp",
63
+ "ActionDispatch::Reloader",
64
+ "ActionDispatch::Callbacks",
65
+ "ActionDispatch::Cookies",
66
+ "ActionDispatch::Session::CookieStore",
67
+ "ActionDispatch::Flash",
68
+ "ActionDispatch::ParamsParser",
69
+ "Rack::Head",
70
+ "Rack::ConditionalGet",
71
+ "Rack::ETag",
72
+ "ActionDispatch::BestStandardsSupport"
73
+ ]
74
+ end
21
75
  end
@@ -12,6 +12,8 @@ class Model
12
12
  end
13
13
 
14
14
  class RenderersApiController < ActionController::API
15
+ use ActionDispatch::ShowExceptions, Rails::API::PublicExceptions.new(Rails.public_path)
16
+
15
17
  def one
16
18
  render :json => Model.new
17
19
  end
@@ -19,6 +21,10 @@ class RenderersApiController < ActionController::API
19
21
  def two
20
22
  render :xml => Model.new
21
23
  end
24
+
25
+ def boom
26
+ raise "boom"
27
+ end
22
28
  end
23
29
 
24
30
  class RenderersApiTest < ActionController::TestCase
@@ -36,3 +42,29 @@ class RenderersApiTest < ActionController::TestCase
36
42
  assert_equal({ :a => 'b' }.to_xml, @response.body)
37
43
  end
38
44
  end
45
+
46
+ class RenderExceptionsTest < ActionDispatch::IntegrationTest
47
+ def setup
48
+ @app = RenderersApiController.action(:boom)
49
+ end
50
+
51
+ def test_render_json_exception
52
+ get "/fake", {}, 'HTTP_ACCEPT' => 'application/json'
53
+ assert_response :internal_server_error
54
+ assert_equal 'application/json', response.content_type.to_s
55
+ assert_equal({ :status => '500', :error => 'boom' }.to_json, response.body)
56
+ end
57
+
58
+ def test_render_xml_exception
59
+ get "/fake", {}, 'HTTP_ACCEPT' => 'application/xml'
60
+ assert_response :internal_server_error
61
+ assert_equal 'application/xml', response.content_type.to_s
62
+ assert_equal({ :status => '500', :error => 'boom' }.to_xml, response.body)
63
+ end
64
+
65
+ def test_render_fallback_exception
66
+ get "/fake", {}, 'HTTP_ACCEPT' => 'text/csv'
67
+ assert_response :internal_server_error
68
+ assert_equal 'text/html', response.content_type.to_s
69
+ end
70
+ end
@@ -2,7 +2,7 @@ require 'generators/generators_test_helper'
2
2
  require 'rails-api/generators/rails/app/app_generator'
3
3
 
4
4
  class AppGeneratorTest < Rails::Generators::TestCase
5
- tests Rails::Generators::AppGenerator
5
+ include GeneratorsTestHelper
6
6
 
7
7
  arguments [destination_root]
8
8
 
@@ -28,7 +28,7 @@ class AppGeneratorTest < Rails::Generators::TestCase
28
28
  private
29
29
 
30
30
  def default_files
31
- %w(.gitignore
31
+ %W(.gitignore
32
32
  Gemfile
33
33
  Rakefile
34
34
  config.ru
@@ -46,10 +46,10 @@ class AppGeneratorTest < Rails::Generators::TestCase
46
46
  log
47
47
  script/rails
48
48
  test/fixtures
49
- test/functional
49
+ test/#{generated_test_funcional_dir}
50
50
  test/integration
51
51
  test/performance
52
- test/unit)
52
+ test/#{generated_test_unit_dir})
53
53
  end
54
54
 
55
55
  def skipped_files
@@ -1,15 +1,18 @@
1
1
  require 'test_helper'
2
- require 'rails/generators/test_case'
2
+ require 'rails/generators'
3
3
 
4
- class Rails::Generators::TestCase
5
- destination File.expand_path("../../tmp", __FILE__)
4
+ module GeneratorsTestHelper
5
+ def self.included(base)
6
+ base.class_eval do
7
+ destination File.expand_path("../../tmp", __FILE__)
8
+ setup :prepare_destination
9
+ teardown :remove_destination
6
10
 
7
- def setup
8
- mkdir_p destination_root
9
- end
10
-
11
- def teardown
12
- rm_rf destination_root
11
+ begin
12
+ base.tests Rails::Generators.const_get(base.name.sub(/Test$/, ''))
13
+ rescue
14
+ end
15
+ end
13
16
  end
14
17
 
15
18
  private
@@ -20,4 +23,16 @@ class Rails::Generators::TestCase
20
23
  FileUtils.mkdir_p(destination)
21
24
  FileUtils.cp routes, destination
22
25
  end
26
+
27
+ def generated_test_unit_dir
28
+ rails4? ? 'models' : 'unit'
29
+ end
30
+
31
+ def generated_test_funcional_dir
32
+ rails4? ? 'controllers' : 'functional'
33
+ end
34
+
35
+ def remove_destination
36
+ rm_rf destination_root
37
+ end
23
38
  end
@@ -2,14 +2,10 @@ require 'generators/generators_test_helper'
2
2
  require 'rails/generators/rails/resource/resource_generator'
3
3
 
4
4
  class ResourceGeneratorTest < Rails::Generators::TestCase
5
- tests Rails::Generators::ResourceGenerator
5
+ include GeneratorsTestHelper
6
6
 
7
7
  arguments %w(account)
8
-
9
- def setup
10
- super
11
- copy_routes
12
- end
8
+ setup :copy_routes
13
9
 
14
10
  def test_resource_routes_are_added
15
11
  run_generator
@@ -2,27 +2,30 @@ require 'generators/generators_test_helper'
2
2
  require 'rails/generators/rails/scaffold/scaffold_generator'
3
3
 
4
4
  class ScaffoldGeneratorTest < Rails::Generators::TestCase
5
- tests Rails::Generators::ScaffoldGenerator
5
+ include GeneratorsTestHelper
6
6
 
7
7
  arguments %w(product_line title:string product:belongs_to user:references)
8
-
9
- def setup
10
- super
11
- copy_routes
12
- end
8
+ setup :copy_routes
13
9
 
14
10
  def test_scaffold_on_invoke
15
11
  run_generator
16
12
 
17
13
  # Model
18
14
  assert_file "app/models/product_line.rb", /class ProductLine < ActiveRecord::Base/
19
- assert_file "test/unit/product_line_test.rb", /class ProductLineTest < ActiveSupport::TestCase/
15
+ assert_file "test/#{generated_test_unit_dir}/product_line_test.rb", /class ProductLineTest < ActiveSupport::TestCase/
20
16
  assert_file "test/fixtures/product_lines.yml"
21
- assert_migration "db/migrate/create_product_lines.rb",
22
- /belongs_to :product/,
23
- /add_index :product_lines, :product_id/,
24
- /references :user/,
25
- /add_index :product_lines, :user_id/
17
+
18
+ if rails4?
19
+ assert_migration "db/migrate/create_product_lines.rb",
20
+ /belongs_to :product, index: true/,
21
+ /references :user, index: true/
22
+ else
23
+ assert_migration "db/migrate/create_product_lines.rb",
24
+ /belongs_to :product/,
25
+ /add_index :product_lines, :product_id/,
26
+ /references :user/,
27
+ /add_index :product_lines, :user_id/
28
+ end
26
29
 
27
30
  # Route
28
31
  assert_file "config/routes.rb" do |content|
@@ -65,7 +68,7 @@ class ScaffoldGeneratorTest < Rails::Generators::TestCase
65
68
  end
66
69
  end
67
70
 
68
- assert_file "test/functional/product_lines_controller_test.rb" do |test|
71
+ assert_file "test/#{generated_test_funcional_dir}/product_lines_controller_test.rb" do |test|
69
72
  assert_match(/class ProductLinesControllerTest < ActionController::TestCase/, test)
70
73
  assert_match(/post :create, product_line: \{ title: @product_line.title \}/, test)
71
74
  assert_match(/put :update, id: @product_line, product_line: \{ title: @product_line.title \}/, test)
@@ -80,11 +83,10 @@ class ScaffoldGeneratorTest < Rails::Generators::TestCase
80
83
 
81
84
  # Helpers
82
85
  assert_no_file "app/helpers/product_lines_helper.rb"
83
- assert_no_file "test/unit/helpers/product_lines_helper_test.rb"
86
+ assert_no_file "test/#{generated_test_unit_dir}/helpers/product_lines_helper_test.rb"
84
87
 
85
88
  # Assets
86
89
  assert_no_file "app/assets/stylesheets/scaffold.css"
87
- assert_no_file "app/assets/javascripts/product_lines.js"
88
90
  assert_no_file "app/assets/stylesheets/product_lines.css"
89
91
  end
90
92
  end
@@ -5,6 +5,10 @@ require 'rails'
5
5
  require 'rails/test_help'
6
6
  require 'rails-api'
7
7
 
8
+ def rails4?
9
+ Rails.version.start_with? '4'
10
+ end
11
+
8
12
  def app
9
13
  @@app ||= Class.new(Rails::Application) do
10
14
  config.active_support.deprecation = :stderr
@@ -19,6 +23,11 @@ def app
19
23
  c.performance_tool :test_unit
20
24
  end
21
25
 
26
+ if rails4?
27
+ config.eager_load = false
28
+ config.secret_key_base = 'abc123'
29
+ end
30
+
22
31
  def self.name
23
32
  'TestApp'
24
33
  end
@@ -26,7 +35,7 @@ def app
26
35
  end
27
36
 
28
37
  app.routes.append do
29
- match ':controller(/:action)'
38
+ get ':controller(/:action)'
30
39
  end
31
40
  app.routes.finalize!
32
41
 
metadata CHANGED
@@ -1,108 +1,100 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: rails-api
3
- version: !ruby/object:Gem::Version
4
- hash: 27
5
- prerelease: false
6
- segments:
7
- - 0
8
- - 0
9
- - 2
10
- version: 0.0.2
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.3
5
+ prerelease:
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Santiago Pastorino and Carlos Antonio da Silva
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2012-06-06 00:00:00 -03:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
12
+ date: 2012-12-18 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
22
15
  name: actionpack
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
25
17
  none: false
26
- requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- hash: 15
30
- segments:
31
- - 3
32
- - 2
33
- - 0
34
- version: 3.2.0
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 3.2.6
35
22
  type: :runtime
36
- version_requirements: *id001
37
- - !ruby/object:Gem::Dependency
38
- name: railties
39
23
  prerelease: false
40
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 3.2.6
30
+ - !ruby/object:Gem::Dependency
31
+ name: railties
32
+ requirement: !ruby/object:Gem::Requirement
41
33
  none: false
42
- requirements:
43
- - - ">="
44
- - !ruby/object:Gem::Version
45
- hash: 15
46
- segments:
47
- - 3
48
- - 2
49
- - 0
50
- version: 3.2.0
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: 3.2.6
51
38
  type: :runtime
52
- version_requirements: *id002
53
- - !ruby/object:Gem::Dependency
54
- name: tzinfo
55
39
  prerelease: false
56
- requirement: &id003 !ruby/object:Gem::Requirement
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: 3.2.6
46
+ - !ruby/object:Gem::Dependency
47
+ name: tzinfo
48
+ requirement: !ruby/object:Gem::Requirement
57
49
  none: false
58
- requirements:
50
+ requirements:
59
51
  - - ~>
60
- - !ruby/object:Gem::Version
61
- hash: 45
62
- segments:
63
- - 0
64
- - 3
65
- - 31
52
+ - !ruby/object:Gem::Version
66
53
  version: 0.3.31
67
54
  type: :runtime
68
- version_requirements: *id003
69
- - !ruby/object:Gem::Dependency
70
- name: rails
71
55
  prerelease: false
72
- requirement: &id004 !ruby/object:Gem::Requirement
56
+ version_requirements: !ruby/object:Gem::Requirement
73
57
  none: false
74
- requirements:
75
- - - ">="
76
- - !ruby/object:Gem::Version
77
- hash: 15
78
- segments:
79
- - 3
80
- - 2
81
- - 0
82
- version: 3.2.0
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 0.3.31
62
+ - !ruby/object:Gem::Dependency
63
+ name: rails
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: 3.2.6
83
70
  type: :development
84
- version_requirements: *id004
85
- description: |-
86
- Rails::API is a subset of a normal Rails application,
87
- created for applications that don't require all
88
- functionality that a complete Rails application provides
89
- email:
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: 3.2.6
78
+ description: ! "Rails::API is a subset of a normal Rails application,\n created
79
+ for applications that don't require all\n functionality
80
+ that a complete Rails application provides"
81
+ email:
90
82
  - <santiago@wyeworks.com>
91
83
  - <carlosantoniodasilva@gmail.com>
92
- executables:
84
+ executables:
93
85
  - rails-api
94
86
  extensions: []
95
-
96
87
  extra_rdoc_files: []
97
-
98
- files:
88
+ files:
99
89
  - README.md
100
90
  - bin/rails-api
101
91
  - lib/generators/rails/api_resource_route/api_resource_route_generator.rb
102
92
  - lib/rails-api/action_controller/api.rb
103
93
  - lib/rails-api/application.rb
104
94
  - lib/rails-api/generators/rails/app/app_generator.rb
95
+ - lib/rails-api/public_exceptions.rb
105
96
  - lib/rails-api/templates/rails/app/app/controllers/application_controller.rb.tt
97
+ - lib/rails-api/templates/rails/app/config/initializers/wrap_parameters.rb.tt
106
98
  - lib/rails-api/templates/rails/app/Gemfile
107
99
  - lib/rails-api/templates/rails/scaffold_controller/controller.rb
108
100
  - lib/rails-api/templates/test_unit/scaffold/functional_test.rb
@@ -122,43 +114,32 @@ files:
122
114
  - test/generators/resource_generator_test.rb
123
115
  - test/generators/scaffold_generator_test.rb
124
116
  - test/test_helper.rb
125
- has_rdoc: true
126
117
  homepage: https://github.com/spastorino/rails-api
127
- licenses:
118
+ licenses:
128
119
  - MIT
129
120
  post_install_message:
130
121
  rdoc_options: []
131
-
132
- require_paths:
122
+ require_paths:
133
123
  - lib
134
- required_ruby_version: !ruby/object:Gem::Requirement
124
+ required_ruby_version: !ruby/object:Gem::Requirement
135
125
  none: false
136
- requirements:
137
- - - ">="
138
- - !ruby/object:Gem::Version
139
- hash: 3
140
- segments:
141
- - 0
142
- version: "0"
143
- required_rubygems_version: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - ! '>='
128
+ - !ruby/object:Gem::Version
129
+ version: '0'
130
+ required_rubygems_version: !ruby/object:Gem::Requirement
144
131
  none: false
145
- requirements:
146
- - - ">="
147
- - !ruby/object:Gem::Version
148
- hash: 23
149
- segments:
150
- - 1
151
- - 3
152
- - 6
132
+ requirements:
133
+ - - ! '>='
134
+ - !ruby/object:Gem::Version
153
135
  version: 1.3.6
154
136
  requirements: []
155
-
156
137
  rubyforge_project:
157
- rubygems_version: 1.3.7
138
+ rubygems_version: 1.8.23
158
139
  signing_key:
159
140
  specification_version: 3
160
141
  summary: Rails for API only Applications
161
- test_files:
142
+ test_files:
162
143
  - test/api_application/api_application_test.rb
163
144
  - test/api_controller/action_methods_test.rb
164
145
  - test/api_controller/conditional_get_test.rb
@@ -173,3 +154,4 @@ test_files:
173
154
  - test/generators/resource_generator_test.rb
174
155
  - test/generators/scaffold_generator_test.rb
175
156
  - test/test_helper.rb
157
+ has_rdoc: