Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Rails Dependency #2

Merged
merged 4 commits into from
Dec 6, 2011
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ Rake::TestTask.new(:test) do |t|
t.pattern = 'test/**/*_test.rb'
t.verbose = true
end

task :default => :test
6 changes: 4 additions & 2 deletions active_model_serializers.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ Gem::Specification.new do |gem|
gem.name = "active_model_serializers"
gem.require_paths = ["lib"]
gem.version = "0.0.1"

gem.add_dependency "rails", "~> 3.0"

gem.add_dependency 'activemodel', '~> 3.0'

gem.add_development_dependency "rails", "~> 3.0"
end
4 changes: 2 additions & 2 deletions lib/action_controller/serialization.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module ActionController
#
# class ApplicationController < ActionController::Base
# private
#
#
# def serialization_scope
# current_user
# end
Expand Down Expand Up @@ -48,4 +48,4 @@ def serialization_scope(scope)
end
end
end
end
end
16 changes: 9 additions & 7 deletions lib/active_model_serializers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@ def active_model_serializer
end
end

require "action_controller"
begin
require 'action_controller'
require 'action_controller/serialization'

module ActionController
autoload :Serialization, "action_controller/serialization"
ActiveSupport.on_load(:action_controller) do
include ::ActionController::Serialization
end
rescue LoadError => ex
puts ex

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you remove this puts?

# rails on installed, continuing
end

ActiveSupport.on_load(:action_controller) do
include ::ActionController::Serialization
end
2 changes: 1 addition & 1 deletion test/generators_test.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'rails'
require 'test_helper'

class Foo < Rails::Application
end
Expand Down
2 changes: 1 addition & 1 deletion test/serialization_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -169,4 +169,4 @@ def test_render_json_with_serializer_api_but_without_serializer
get :render_json_with_serializer_api_but_without_serializer
assert_match '{"serializable_object":true}', @response.body
end
end
end
4 changes: 3 additions & 1 deletion test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
require "active_support/json"
require "test/unit"

require 'rails'

module TestHelper
Routes = ActionDispatch::Routing::RouteSet.new
Routes.draw do
Expand All @@ -21,4 +23,4 @@ module TestHelper
setup do
@routes = ::TestHelper::Routes
end
end
end