multi_json 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +4 -2
- data/lib/multi_json.rb +10 -9
- data/lib/multi_json/version.rb +1 -1
- data/multi_json.gemspec +1 -1
- data/spec/multi_json_spec.rb +14 -0
- metadata +8 -7
data/.travis.yml
CHANGED
data/lib/multi_json.rb
CHANGED
@@ -14,8 +14,7 @@ module MultiJson
|
|
14
14
|
REQUIREMENT_MAP = [
|
15
15
|
["yajl", :yajl],
|
16
16
|
["json", :json_gem],
|
17
|
-
["json/pure", :json_pure]
|
18
|
-
["ok_json", :ok_json]
|
17
|
+
["json/pure", :json_pure]
|
19
18
|
]
|
20
19
|
|
21
20
|
# The default engine based on what you currently
|
@@ -34,6 +33,8 @@ module MultiJson
|
|
34
33
|
next
|
35
34
|
end
|
36
35
|
end
|
36
|
+
|
37
|
+
:ok_json
|
37
38
|
end
|
38
39
|
|
39
40
|
# Set the JSON parser utilizing a symbol, string, or class.
|
@@ -45,13 +46,13 @@ module MultiJson
|
|
45
46
|
# * <tt>:yajl</tt>
|
46
47
|
def engine=(new_engine)
|
47
48
|
case new_engine
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
49
|
+
when String, Symbol
|
50
|
+
require "multi_json/engines/#{new_engine}"
|
51
|
+
@engine = MultiJson::Engines.const_get("#{new_engine.to_s.split('_').map{|s| s.capitalize}.join('')}")
|
52
|
+
when Class
|
53
|
+
@engine = new_engine
|
54
|
+
else
|
55
|
+
raise "Did not recognize your engine specification. Please specify either a symbol or a class."
|
55
56
|
end
|
56
57
|
end
|
57
58
|
|
data/lib/multi_json/version.rb
CHANGED
data/multi_json.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |s|
|
|
10
10
|
s.authors = ["Michael Bleigh"]
|
11
11
|
s.email = ["michael@intridea.com"]
|
12
12
|
s.summary = %q{A gem to provide swappable JSON backends.}
|
13
|
-
s.description = %q{A gem to provide swappable JSON backends utilizing Yajl::Ruby, the JSON gem,
|
13
|
+
s.description = %q{A gem to provide swappable JSON backends utilizing Yajl::Ruby, the JSON gem, JSON pure, or a vendored version of okjson.}
|
14
14
|
s.homepage = "http://github.com/intridea/multi_json"
|
15
15
|
|
16
16
|
s.extra_rdoc_files = ["LICENSE", "README.rdoc"]
|
data/spec/multi_json_spec.rb
CHANGED
@@ -13,6 +13,20 @@ end
|
|
13
13
|
|
14
14
|
describe "MultiJson" do
|
15
15
|
context 'engines' do
|
16
|
+
it 'defaults to ok_json if no other json implementions are available' do
|
17
|
+
old_map = MultiJson::REQUIREMENT_MAP
|
18
|
+
begin
|
19
|
+
MultiJson::REQUIREMENT_MAP.each_with_index do |(library, engine), index|
|
20
|
+
MultiJson::REQUIREMENT_MAP[index] = ["foo/#{library}", engine]
|
21
|
+
end
|
22
|
+
MultiJson.default_engine.should == :ok_json
|
23
|
+
ensure
|
24
|
+
old_map.each_with_index do |(library, engine), index|
|
25
|
+
MultiJson::REQUIREMENT_MAP[index] = [library, engine]
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
16
30
|
it 'defaults to the best available gem' do
|
17
31
|
# the yajl-ruby gem does not work on jruby, so the best engine is the JsonGem engine
|
18
32
|
if jruby?
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: multi_json
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 1
|
10
|
+
version: 1.0.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Michael Bleigh
|
@@ -15,10 +15,11 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-04
|
18
|
+
date: 2011-05-04 00:00:00 +02:00
|
19
|
+
default_executable:
|
19
20
|
dependencies: []
|
20
21
|
|
21
|
-
description: A gem to provide swappable JSON backends utilizing Yajl::Ruby, the JSON gem,
|
22
|
+
description: A gem to provide swappable JSON backends utilizing Yajl::Ruby, the JSON gem, JSON pure, or a vendored version of okjson.
|
22
23
|
email:
|
23
24
|
- michael@intridea.com
|
24
25
|
executables: []
|
@@ -48,6 +49,7 @@ files:
|
|
48
49
|
- spec/multi_json_spec.rb
|
49
50
|
- spec/spec.opts
|
50
51
|
- spec/spec_helper.rb
|
52
|
+
has_rdoc: true
|
51
53
|
homepage: http://github.com/intridea/multi_json
|
52
54
|
licenses: []
|
53
55
|
|
@@ -79,7 +81,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
79
81
|
requirements: []
|
80
82
|
|
81
83
|
rubyforge_project:
|
82
|
-
rubygems_version: 1.
|
84
|
+
rubygems_version: 1.5.2
|
83
85
|
signing_key:
|
84
86
|
specification_version: 3
|
85
87
|
summary: A gem to provide swappable JSON backends.
|
@@ -87,4 +89,3 @@ test_files:
|
|
87
89
|
- spec/multi_json_spec.rb
|
88
90
|
- spec/spec.opts
|
89
91
|
- spec/spec_helper.rb
|
90
|
-
has_rdoc:
|