Permalink
Browse files

Remove ActiveSupport::JSON support

  • Loading branch information...
1 parent fdad79f commit c2f4140141d785a24b3f56e58811b0e561b37f6a @sstephenson sstephenson committed Apr 13, 2011
Showing with 7 additions and 43 deletions.
  1. +6 −6 README.rdoc
  2. +0 −3 lib/multi_json.rb
  3. +0 −32 lib/multi_json/engines/active_support.rb
  4. +0 −1 multi_json.gemspec
  5. +1 −1 spec/multi_json_spec.rb
View
@@ -3,20 +3,20 @@
Lots of Ruby libraries utilize JSON parsing in some form, and everyone has their favorite JSON library. In order to best support multiple JSON parsers and libraries, <tt>multi_json</tt> is a general-purpose swappable JSON backend library. You use it like so:
require 'multi_json'
-
+
MultiJson.engine = :yajl
MultiJson.decode('{"abc":"def"}') # decoded using Yajl
-
+
MultiJson.engine = :json_gem
MultiJson.engine = MultiJson::Engines::JsonGem # equivalent to previous line
MultiJson.encode({:abc => 'def'}) # encoded using the JSON gem
-
+
The <tt>engine</tt> setter takes either a symbol or a class (to allow for custom JSON parsers) that responds to both <tt>.decode</tt> and <tt>.encode</tt> at the class level.
-MultiJSON tries to have intelligent defaulting. That is, if you have any of the supported engines already loaded, it will utilize them before attempting to load any. When loading, libraries are ordered by speed. First Yajl-Ruby, then the JSON gem, then ActiveSupport, then JSON pure.
+MultiJSON tries to have intelligent defaulting. That is, if you have any of the supported engines already loaded, it will utilize them before attempting to load any. When loading, libraries are ordered by speed. First Yajl-Ruby, then the JSON gem, then JSON pure.
== Note on Patches/Pull Requests
-
+
* Fork the project.
* Make your feature addition or bug fix.
* Add tests for it. This is important so I don't break it in a
@@ -27,4 +27,4 @@ MultiJSON tries to have intelligent defaulting. That is, if you have any of the
== Copyright
-Copyright (c) 2010 Michael Bleigh and Intridea, Inc. See LICENSE for details.
+Copyright (c) 2010 Michael Bleigh and Intridea, Inc. See LICENSE for details.
View
@@ -12,7 +12,6 @@ def engine
REQUIREMENT_MAP = [
["yajl", :yajl],
["json", :json_gem],
- ["active_support", :active_support],
["json/pure", :json_pure]
]
@@ -23,7 +22,6 @@ def engine
def default_engine
return :yajl if defined?(::Yajl)
return :json_gem if defined?(::JSON)
- return :active_support if defined?(::ActiveSupport::JSON)
REQUIREMENT_MAP.each do |(library, engine)|
begin
@@ -40,7 +38,6 @@ def default_engine
#
# * <tt>:json_gem</tt>
# * <tt>:json_pure</tt>
- # * <tt>:active_support</tt> (useful for inside Rails apps)
# * <tt>:yajl</tt>
def engine=(new_engine)
case new_engine
@@ -1,32 +0,0 @@
-require 'active_support' unless defined?(::ActiveSupport::JSON)
-
-module MultiJson
- module Engines
- # Use ActiveSupport to encode/decode JSON.
- class ActiveSupport
- def self.decode(string, options = {}) #:nodoc:
- hash = ::ActiveSupport::JSON.decode(string)
- options[:symbolize_keys] ? symbolize_keys(hash) : hash
- end
-
- def self.encode(object) #:nodoc:
- ::ActiveSupport::JSON.encode(object)
- end
-
- def self.symbolize_keys(hash) #:nodoc:
- hash.inject({}){|result, (key, value)|
- new_key = case key
- when String then key.to_sym
- else key
- end
- new_value = case value
- when Hash then symbolize_keys(value)
- else value
- end
- result[new_key] = new_value
- result
- }
- end
- end
- end
-end
View
@@ -19,7 +19,6 @@ Gem::Specification.new do |s|
s.add_development_dependency("rake", "~> 0.8")
s.add_development_dependency("rcov", "~> 0.9")
s.add_development_dependency("rspec", "~> 2.0")
- s.add_development_dependency("activesupport", "~> 3.0")
s.add_development_dependency("json", "~> 1.4")
s.add_development_dependency("json_pure", "~> 1.4")
s.add_development_dependency("yajl-ruby", "~> 0.7")
View
@@ -28,7 +28,7 @@ def self.encode(string)
end
end
- %w(active_support json_gem json_pure yajl).each do |engine|
+ %w(json_gem json_pure yajl).each do |engine|
context engine do
before do
begin

0 comments on commit c2f4140

Please sign in to comment.