fjson 0.0.8 → 0.0.9
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.
- data/CHANGES +3 -0
- data/Rakefile +17 -12
- data/lib/json/editor.rb +1 -1
- data/mkmf_rake_builder.rb +7 -14
- data/spec/array_spec.rb +2 -2
- data/spec/false_class_spec.rb +1 -1
- data/spec/float_spec.rb +1 -1
- data/spec/integer_spec.rb +1 -1
- data/spec/mkmf_rake_builder_spec.rb +11 -17
- data/spec/nil_class_spec.rb +1 -1
- data/spec/object_spec.rb +1 -1
- data/spec/spec_suite.rb +1 -1
- data/spec/state_spec.rb +11 -11
- data/spec/string_spec.rb +1 -1
- data/spec/string_when_not_supporting_unicode_and_kcode_is_not_utf8_json_spec.rb +1 -1
- data/spec/string_when_supporting_unicode_and_kcode_is_not_utf8_json_spec.rb +1 -1
- data/spec/string_with_latin1_character_set_json_spec.rb +15 -15
- data/spec/string_with_utf8_values_when_supporting_unicode_json_spec.rb +12 -12
- data/spec/true_class_spec.rb +1 -1
- metadata +30 -38
data/CHANGES
CHANGED
data/Rakefile
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
dir = File.dirname(__FILE__)
|
|
2
2
|
require File.expand_path("#{dir}/rake_helper")
|
|
3
|
-
def win32?
|
|
4
|
-
ENV["target_platform"] == "win32"
|
|
5
|
-
end
|
|
6
|
-
|
|
7
3
|
rake_builder = MkmfRakeBuilder.new
|
|
8
4
|
rake_builder.project_dir = File.dirname(__FILE__)
|
|
9
5
|
rake_builder.rake_application = Rake.application
|
|
@@ -11,7 +7,8 @@ rake_builder.rake_tasks = Rake::Task
|
|
|
11
7
|
rake_builder.rake_file_tasks = Rake::FileTask
|
|
12
8
|
rake_builder.dir_class = Dir
|
|
13
9
|
rake_builder.file_class = File
|
|
14
|
-
|
|
10
|
+
file_extension = (RUBY_PLATFORM =~ /darwin/) ? "bundle" : "so"
|
|
11
|
+
rake_builder.file_extension = file_extension
|
|
15
12
|
fjson_extensions = rake_builder.extensions_to_build = [
|
|
16
13
|
[:json_ext, "json_ext"],
|
|
17
14
|
[:state_ext, "state_ext"],
|
|
@@ -25,7 +22,6 @@ fjson_extensions = rake_builder.extensions_to_build = [
|
|
|
25
22
|
[:array_ext, "extensions/array_ext"],
|
|
26
23
|
[:hash_ext, "extensions/hash_ext"]
|
|
27
24
|
]
|
|
28
|
-
rake_builder.extconf_arguments = "-I /usr/local/lib/ruby-mingw32/lib/ruby/1.8/i386-mingw32" if win32?
|
|
29
25
|
|
|
30
26
|
rake_builder.build_default_task
|
|
31
27
|
rake_builder.build_compile_task
|
|
@@ -35,17 +31,24 @@ rake_builder.build_extension_compile_tasks
|
|
|
35
31
|
rake_builder.build_install_task
|
|
36
32
|
rake_builder.build_cleanup_task
|
|
37
33
|
|
|
34
|
+
def win32?
|
|
35
|
+
ENV["target_platform"] == "win32"
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
if win32?
|
|
39
|
+
#Rake::Task[].invoke
|
|
40
|
+
end
|
|
41
|
+
|
|
38
42
|
PKG_NAME = "fjson"
|
|
39
|
-
PKG_VERSION = "0.0.
|
|
43
|
+
PKG_VERSION = "0.0.9"
|
|
40
44
|
PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
|
|
41
45
|
PKG_FILES = FileList[
|
|
42
46
|
'[A-Z]*',
|
|
43
47
|
'*.rb',
|
|
44
48
|
'lib/**/*.rb',
|
|
49
|
+
'ext/**/*.{h,c,rb}',
|
|
45
50
|
'spec/**/*.rb'
|
|
46
51
|
]
|
|
47
|
-
executable_extensions = (win32?) ? 'lib/**/*.so' : 'ext/**/*.{h,c,rb}'
|
|
48
|
-
PKG_FILES.include(executable_extensions)
|
|
49
52
|
|
|
50
53
|
spec = Gem::Specification.new do |s|
|
|
51
54
|
s.name = PKG_NAME
|
|
@@ -57,7 +60,6 @@ spec = Gem::Specification.new do |s|
|
|
|
57
60
|
EOF
|
|
58
61
|
s.test_files = Dir.glob('spec/*_spec.rb')
|
|
59
62
|
s.description = s.summary
|
|
60
|
-
s.platform = (win32?) ? Gem::Platform::WIN32 : Gem::Platform::RUBY
|
|
61
63
|
|
|
62
64
|
s.files = PKG_FILES.to_a
|
|
63
65
|
s.require_path = 'lib'
|
|
@@ -73,10 +75,13 @@ spec = Gem::Specification.new do |s|
|
|
|
73
75
|
s.homepage = "http://fjson.rubyforge.org"
|
|
74
76
|
s.rubyforge_project = "fjson"
|
|
75
77
|
|
|
76
|
-
s.extensions = ["Rakefile"]
|
|
78
|
+
s.extensions = ["Rakefile"]
|
|
77
79
|
|
|
78
|
-
s.add_dependency "rspec", ">=0.6.4"
|
|
79
80
|
#s.add_dependency "mkrf", ">=0.1.2"
|
|
81
|
+
|
|
82
|
+
if win32?
|
|
83
|
+
|
|
84
|
+
end
|
|
80
85
|
end
|
|
81
86
|
|
|
82
87
|
Rake::GemPackageTask.new(spec) do |pkg|
|
data/lib/json/editor.rb
CHANGED
data/mkmf_rake_builder.rb
CHANGED
|
@@ -6,15 +6,16 @@ class MkmfRakeBuilder
|
|
|
6
6
|
:dir_class,
|
|
7
7
|
:file_extension,
|
|
8
8
|
:extensions_to_build,
|
|
9
|
-
:file_class
|
|
10
|
-
:extconf_arguments
|
|
9
|
+
:file_class
|
|
11
10
|
|
|
12
11
|
def initialize
|
|
13
12
|
@extconf_file = "extconf.mkmf.rb"
|
|
14
13
|
end
|
|
15
14
|
|
|
16
15
|
def build_default_task
|
|
17
|
-
task(:
|
|
16
|
+
task(:extension => [ :compile ]) do
|
|
17
|
+
end
|
|
18
|
+
task(:default => [ :extension ]) do
|
|
18
19
|
end
|
|
19
20
|
end
|
|
20
21
|
|
|
@@ -66,11 +67,7 @@ class MkmfRakeBuilder
|
|
|
66
67
|
build_file_path = build_path(extension_path)
|
|
67
68
|
rm build_file_path if build_file_path && file_exists?(build_file_path)
|
|
68
69
|
|
|
69
|
-
|
|
70
|
-
rm build_object_path if build_object_path && file_exists?(build_object_path)
|
|
71
|
-
|
|
72
|
-
build_dir = build_dir(extension_path)
|
|
73
|
-
make_file_path = "#{build_dir}/Makefile"
|
|
70
|
+
make_file_path = "#{build_dir(extension_path)}/Makefile"
|
|
74
71
|
rm make_file_path if make_file_path && file_exists?(make_file_path)
|
|
75
72
|
end
|
|
76
73
|
end
|
|
@@ -108,7 +105,7 @@ class MkmfRakeBuilder
|
|
|
108
105
|
|
|
109
106
|
def extconf(dir)
|
|
110
107
|
chdir(dir) do
|
|
111
|
-
ruby
|
|
108
|
+
ruby @extconf_file
|
|
112
109
|
end
|
|
113
110
|
end
|
|
114
111
|
|
|
@@ -145,14 +142,10 @@ class MkmfRakeBuilder
|
|
|
145
142
|
end
|
|
146
143
|
|
|
147
144
|
def build_path(relative_extension_path)
|
|
148
|
-
basename =
|
|
145
|
+
basename = "#{build_dir(relative_extension_path)}/#{file_name(relative_extension_path)}"
|
|
149
146
|
"#{basename}.#{@file_extension}"
|
|
150
147
|
end
|
|
151
148
|
|
|
152
|
-
def build_path_without_file_extension(relative_extension_path)
|
|
153
|
-
"#{build_dir(relative_extension_path)}/#{file_name(relative_extension_path)}"
|
|
154
|
-
end
|
|
155
|
-
|
|
156
149
|
def library_path(relative_extension_path)
|
|
157
150
|
library_directory_path = "#{@project_dir}/lib/#{file_directory(relative_extension_path)}"
|
|
158
151
|
binary_name = "#{file_name(relative_extension_path)}.#{@file_extension}"
|
data/spec/array_spec.rb
CHANGED
|
@@ -7,14 +7,14 @@ require File.expand_path("#{dir}/../lib/fjson")
|
|
|
7
7
|
context "A one dimensional Array" do
|
|
8
8
|
specify "should create json" do
|
|
9
9
|
array = [1, 'hello', :hello]
|
|
10
|
-
array.to_json.
|
|
10
|
+
array.to_json.should == '[1,"hello","hello"]'
|
|
11
11
|
end
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
context "A multi-dimensional Array" do
|
|
15
15
|
specify "should create json" do
|
|
16
16
|
array = [1, ['hello', [:hello]]]
|
|
17
|
-
array.to_json.
|
|
17
|
+
array.to_json.should == '[1,["hello",["hello"]]]'
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
specify "should not support circular dependencies" do
|
data/spec/false_class_spec.rb
CHANGED
data/spec/float_spec.rb
CHANGED
data/spec/integer_spec.rb
CHANGED
|
@@ -15,7 +15,8 @@ context "A MkmfRakeBuilder" do
|
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
specify "should build the default task" do
|
|
18
|
-
@rake_tasks.should_receive(:define_task).with({:
|
|
18
|
+
@rake_tasks.should_receive(:define_task).with({:extension => [ :compile ]})
|
|
19
|
+
@rake_tasks.should_receive(:define_task).with({:default => [ :extension ]})
|
|
19
20
|
@builder.build_default_task
|
|
20
21
|
end
|
|
21
22
|
|
|
@@ -36,7 +37,7 @@ context "A MkmfRakeBuilder" do
|
|
|
36
37
|
require_args = args
|
|
37
38
|
end
|
|
38
39
|
spec_task.call
|
|
39
|
-
require_args.
|
|
40
|
+
require_args.should == ["/project/dir/spec/spec_suite"]
|
|
40
41
|
end
|
|
41
42
|
|
|
42
43
|
specify "should build lib task to create the lib directory" do
|
|
@@ -50,7 +51,7 @@ context "A MkmfRakeBuilder" do
|
|
|
50
51
|
directory_args = args
|
|
51
52
|
end
|
|
52
53
|
spec_task.call
|
|
53
|
-
directory_args.
|
|
54
|
+
directory_args.should == ["lib"]
|
|
54
55
|
end
|
|
55
56
|
|
|
56
57
|
specify "should build all extension compile tasks" do
|
|
@@ -75,7 +76,6 @@ context "A MkmfRakeBuilder" do
|
|
|
75
76
|
|
|
76
77
|
def specify_makefile_task(makefile_task)
|
|
77
78
|
dir_class = @builder.dir_class = mock("dir_class_for_makefile")
|
|
78
|
-
@builder.extconf_arguments = "extconf_arguments"
|
|
79
79
|
makefile_chdir_task = nil
|
|
80
80
|
dir_class.should_receive(:chdir).with("ext/extension/path").
|
|
81
81
|
and_return do |name, makefile_chdir_task|
|
|
@@ -88,7 +88,7 @@ context "A MkmfRakeBuilder" do
|
|
|
88
88
|
sh_args << args
|
|
89
89
|
end
|
|
90
90
|
makefile_chdir_task.call
|
|
91
|
-
sh_args.
|
|
91
|
+
sh_args.should == [["ruby extconf.mkmf.rb"]]
|
|
92
92
|
end
|
|
93
93
|
|
|
94
94
|
def specify_executable_task(executable_task)
|
|
@@ -105,7 +105,7 @@ context "A MkmfRakeBuilder" do
|
|
|
105
105
|
sh_args << args
|
|
106
106
|
end
|
|
107
107
|
executable_chdir_task.call
|
|
108
|
-
sh_args.
|
|
108
|
+
sh_args.should == [["make"]]
|
|
109
109
|
end
|
|
110
110
|
|
|
111
111
|
specify "should build install task to install all of the compiled extensions" do
|
|
@@ -114,7 +114,7 @@ context "A MkmfRakeBuilder" do
|
|
|
114
114
|
rake_task = nil
|
|
115
115
|
@rake_tasks.should_receive(:define_task).with(:install).
|
|
116
116
|
and_return {|name, rake_task| rake_task = rake_task}
|
|
117
|
-
@builder.build_install_task.
|
|
117
|
+
@builder.build_install_task.should == ["extensions/foo", "extensions/bar"]
|
|
118
118
|
|
|
119
119
|
file_class = @builder.file_class = mock("file_class")
|
|
120
120
|
file_class.should_receive(:dirname).at_least(1).with("extensions/foo").and_return("extensions")
|
|
@@ -132,7 +132,7 @@ context "A MkmfRakeBuilder" do
|
|
|
132
132
|
end
|
|
133
133
|
rake_task.call
|
|
134
134
|
|
|
135
|
-
cp_args.
|
|
135
|
+
cp_args.should == [
|
|
136
136
|
["/project/dir/ext/extensions/foo/foo.file_extension", "/project/dir/lib/extensions/foo.file_extension"],
|
|
137
137
|
["/project/dir/ext/extensions/bar/bar.file_extension", "/project/dir/lib/extensions/bar.file_extension"]
|
|
138
138
|
]
|
|
@@ -146,7 +146,7 @@ context "A MkmfRakeBuilder" do
|
|
|
146
146
|
and_return do |name, cleanup_task|
|
|
147
147
|
cleanup_task = cleanup_task
|
|
148
148
|
end
|
|
149
|
-
@builder.build_cleanup_task.
|
|
149
|
+
@builder.build_cleanup_task.should == ["extensions/foo", "extensions/bar"]
|
|
150
150
|
|
|
151
151
|
file_class = @builder.file_class = mock("file_class")
|
|
152
152
|
file_class.should_receive(:dirname).at_least(1).with("extensions/foo").and_return("extensions")
|
|
@@ -157,10 +157,6 @@ context "A MkmfRakeBuilder" do
|
|
|
157
157
|
with("/project/dir/ext/extensions/foo/foo.file_extension").and_return(true)
|
|
158
158
|
file_class.should_receive(:exists?).at_least(1).
|
|
159
159
|
with("/project/dir/ext/extensions/bar/bar.file_extension").and_return(true)
|
|
160
|
-
file_class.should_receive(:exists?).at_least(1).
|
|
161
|
-
with("/project/dir/ext/extensions/foo/foo.o").and_return(true)
|
|
162
|
-
file_class.should_receive(:exists?).at_least(1).
|
|
163
|
-
with("/project/dir/ext/extensions/bar/bar.o").and_return(true)
|
|
164
160
|
file_class.should_receive(:exists?).at_least(1).
|
|
165
161
|
with("/project/dir/lib/extensions/foo.file_extension").and_return(true)
|
|
166
162
|
file_class.should_receive(:exists?).at_least(1).
|
|
@@ -177,18 +173,16 @@ context "A MkmfRakeBuilder" do
|
|
|
177
173
|
end
|
|
178
174
|
cleanup_task.call
|
|
179
175
|
|
|
180
|
-
rm_args.
|
|
176
|
+
rm_args.should == [
|
|
181
177
|
["/project/dir/lib/extensions/foo.file_extension"],
|
|
182
178
|
["/project/dir/ext/extensions/foo/foo.file_extension"],
|
|
183
|
-
["/project/dir/ext/extensions/foo/foo.o"],
|
|
184
179
|
["/project/dir/ext/extensions/foo/Makefile"],
|
|
185
180
|
["/project/dir/lib/extensions/bar.file_extension"],
|
|
186
181
|
["/project/dir/ext/extensions/bar/bar.file_extension"],
|
|
187
|
-
["/project/dir/ext/extensions/bar/bar.o"],
|
|
188
182
|
["/project/dir/ext/extensions/bar/Makefile"],
|
|
189
183
|
]
|
|
190
184
|
end
|
|
191
|
-
|
|
185
|
+
|
|
192
186
|
def specify_build_extension_compile_task(extension_path, extension)
|
|
193
187
|
file_extension = @builder.file_extension = "file_extension"
|
|
194
188
|
@rake_application.should_receive(:last_comment=).with("Builds the #{extension} extension")
|
data/spec/nil_class_spec.rb
CHANGED
data/spec/object_spec.rb
CHANGED
|
@@ -8,7 +8,7 @@ context "An object" do
|
|
|
8
8
|
specify "should convert its string representation to json" do
|
|
9
9
|
obj = Object.new
|
|
10
10
|
obj_str = obj.to_s
|
|
11
|
-
obj.to_json.
|
|
11
|
+
obj.to_json.should == '"' + obj_str + '"'
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
specify "to_json should accept any number of arguments" do
|
data/spec/spec_suite.rb
CHANGED
|
@@ -8,7 +8,7 @@ unless args.include?("-f") || args.include?("--format")
|
|
|
8
8
|
end
|
|
9
9
|
args << $0
|
|
10
10
|
|
|
11
|
-
$context_runner = ::Spec::Runner::OptionParser.create_context_runner(args, false, STDERR, STDOUT)
|
|
11
|
+
$context_runner = ::Spec::Runner::OptionParser.new.create_context_runner(args, false, STDERR, STDOUT)
|
|
12
12
|
|
|
13
13
|
at_exit do
|
|
14
14
|
unless context_runner.instance_eval {@reporter}.instance_eval {@start_time}
|
data/spec/state_spec.rb
CHANGED
|
@@ -7,7 +7,7 @@ require File.expand_path("#{dir}/../lib/fjson")
|
|
|
7
7
|
context "A JSON state" do
|
|
8
8
|
specify "method from_state should return the passed in object when a state is passed in" do
|
|
9
9
|
state = JSON::State.new
|
|
10
|
-
JSON::State.from_state(state).
|
|
10
|
+
JSON::State.from_state(state).should == state
|
|
11
11
|
end
|
|
12
12
|
|
|
13
13
|
specify "method from_state should return a new state with hash values when a hash is passed in" do
|
|
@@ -18,7 +18,7 @@ context "A JSON state" do
|
|
|
18
18
|
|
|
19
19
|
args = {}
|
|
20
20
|
shim_state_class.from_state(args)
|
|
21
|
-
passed_params.
|
|
21
|
+
passed_params.should == args
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
specify "method from_state should return a new state with default parameters when an object that is not " +
|
|
@@ -29,11 +29,11 @@ context "A JSON state" do
|
|
|
29
29
|
|
|
30
30
|
specify "should initialize its attributes to their defaults" do
|
|
31
31
|
state = JSON::State.new
|
|
32
|
-
state.indent.
|
|
33
|
-
state.space.
|
|
34
|
-
state.object_nl.
|
|
35
|
-
state.array_nl.
|
|
36
|
-
state.instance_eval {@seen}.
|
|
32
|
+
state.indent.should == ""
|
|
33
|
+
state.space.should == ""
|
|
34
|
+
state.object_nl.should == ""
|
|
35
|
+
state.array_nl.should == ""
|
|
36
|
+
state.instance_eval {@seen}.should ==({})
|
|
37
37
|
end
|
|
38
38
|
|
|
39
39
|
specify "should initialize its attributes with passed in values" do
|
|
@@ -44,10 +44,10 @@ context "A JSON state" do
|
|
|
44
44
|
:array_nl => Object.new
|
|
45
45
|
}
|
|
46
46
|
state = JSON::State.new(params)
|
|
47
|
-
state.indent.
|
|
48
|
-
state.space.
|
|
49
|
-
state.object_nl.
|
|
50
|
-
state.array_nl.
|
|
47
|
+
state.indent.should == params[:indent]
|
|
48
|
+
state.space.should == params[:space]
|
|
49
|
+
state.object_nl.should == params[:object_nl]
|
|
50
|
+
state.array_nl.should == params[:array_nl]
|
|
51
51
|
end
|
|
52
52
|
|
|
53
53
|
specify "should remember objects" do
|
data/spec/string_spec.rb
CHANGED
|
@@ -13,6 +13,6 @@ context "String when not supporting unicode and KCODE is not UTF8 json" do
|
|
|
13
13
|
specify "should let high values pass through when " +
|
|
14
14
|
"not supporting unicode and KCODE is not UTF8" do
|
|
15
15
|
val = [0xcf].pack("U")
|
|
16
|
-
JSON.utf8_to_json(val).
|
|
16
|
+
JSON.utf8_to_json(val).should == "\303\217"
|
|
17
17
|
end
|
|
18
18
|
end
|
|
@@ -13,6 +13,6 @@ context "String when supporting unicode and KCODE is not utf8 json" do
|
|
|
13
13
|
specify "should let high values pass through when " +
|
|
14
14
|
"supporting unicode and KCODE is not UTF8" do
|
|
15
15
|
val = [0xcf].pack("U")
|
|
16
|
-
JSON.utf8_to_json(val).
|
|
16
|
+
JSON.utf8_to_json(val).should == "\303\217"
|
|
17
17
|
end
|
|
18
18
|
end
|
|
@@ -7,61 +7,61 @@ require File.expand_path("#{dir}/../lib/fjson")
|
|
|
7
7
|
context "String with latin1 character set Json" do
|
|
8
8
|
specify 'should format \b' do
|
|
9
9
|
utf_8_val = [?\b].pack("U")
|
|
10
|
-
JSON.utf8_to_json(utf_8_val).
|
|
10
|
+
JSON.utf8_to_json(utf_8_val).should == '\b'
|
|
11
11
|
end
|
|
12
12
|
|
|
13
13
|
specify 'should format \t' do
|
|
14
14
|
utf_8_val = [?\t].pack("U")
|
|
15
|
-
JSON.utf8_to_json(utf_8_val).
|
|
15
|
+
JSON.utf8_to_json(utf_8_val).should == '\t'
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
specify 'should format \n' do
|
|
19
19
|
utf_8_val = [?\n].pack("U")
|
|
20
|
-
JSON.utf8_to_json(utf_8_val).
|
|
20
|
+
JSON.utf8_to_json(utf_8_val).should == '\n'
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
specify 'should format \f' do
|
|
24
24
|
utf_8_val = [?\f].pack("U")
|
|
25
|
-
JSON.utf8_to_json(utf_8_val).
|
|
25
|
+
JSON.utf8_to_json(utf_8_val).should == '\f'
|
|
26
26
|
end
|
|
27
27
|
|
|
28
28
|
specify 'should format \r' do
|
|
29
29
|
utf_8_val = [?\r].pack("U")
|
|
30
|
-
JSON.utf8_to_json(utf_8_val).
|
|
30
|
+
JSON.utf8_to_json(utf_8_val).should == '\r'
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
specify 'should format ?"' do
|
|
34
34
|
utf_8_val = [?"].pack("U")
|
|
35
|
-
JSON.utf8_to_json(utf_8_val).
|
|
35
|
+
JSON.utf8_to_json(utf_8_val).should == '\"'
|
|
36
36
|
end
|
|
37
37
|
|
|
38
38
|
specify 'should format ?\\' do
|
|
39
39
|
utf_8_val = [?\\].pack("U")
|
|
40
|
-
JSON.utf8_to_json(utf_8_val).
|
|
40
|
+
JSON.utf8_to_json(utf_8_val).should == '\\\\'
|
|
41
41
|
end
|
|
42
42
|
|
|
43
43
|
specify "should format values between 0x00 and 0x1f" do
|
|
44
44
|
utf_8_val = [0x0f].pack("U")
|
|
45
|
-
JSON.utf8_to_json(utf_8_val).
|
|
45
|
+
JSON.utf8_to_json(utf_8_val).should == '\\u000f'
|
|
46
46
|
utf_8_val = [0x1e].pack("U")
|
|
47
|
-
JSON.utf8_to_json(utf_8_val).
|
|
47
|
+
JSON.utf8_to_json(utf_8_val).should == '\\u001e'
|
|
48
48
|
end
|
|
49
49
|
|
|
50
50
|
specify "should let ordinary text pass through" do
|
|
51
|
-
JSON.utf8_to_json("test").
|
|
52
|
-
JSON.utf8_to_json('1').
|
|
51
|
+
JSON.utf8_to_json("test").should == "test"
|
|
52
|
+
JSON.utf8_to_json('1').should == '1'
|
|
53
53
|
end
|
|
54
54
|
|
|
55
55
|
specify "should support backslashes" do
|
|
56
56
|
json = '"\\\\.(?i:gif|jpe?g|png)$"'
|
|
57
57
|
data = JSON.parse(json)
|
|
58
|
-
JSON.unparse(data).
|
|
58
|
+
JSON.unparse(data).should == json
|
|
59
59
|
json = '"\\""'
|
|
60
60
|
data = JSON.parse(json)
|
|
61
|
-
JSON.unparse(data).
|
|
61
|
+
JSON.unparse(data).should == json
|
|
62
62
|
json = '"\/"'
|
|
63
63
|
data = JSON.parse(json)
|
|
64
|
-
data.
|
|
65
|
-
JSON.unparse(data).
|
|
64
|
+
data.should == '/'
|
|
65
|
+
JSON.unparse(data).should == json
|
|
66
66
|
end
|
|
67
67
|
end
|
|
@@ -12,42 +12,42 @@ context "String with UTF8 values when supporting unicode Json" do
|
|
|
12
12
|
|
|
13
13
|
specify "should format values between 0x00000080 and 0x000007ff" do
|
|
14
14
|
val = [0x0080].pack("U")
|
|
15
|
-
JSON.utf8_to_json(val).
|
|
15
|
+
JSON.utf8_to_json(val).should == "\\u0080"
|
|
16
16
|
|
|
17
17
|
val = [0x07ff].pack("U")
|
|
18
|
-
JSON.utf8_to_json(val).
|
|
18
|
+
JSON.utf8_to_json(val).should == "\\u07ff"
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
specify "should format values between 0x00001000 and 0x0000ffff" do
|
|
22
22
|
val = [0x1000].pack("U")
|
|
23
|
-
JSON.utf8_to_json(val).
|
|
23
|
+
JSON.utf8_to_json(val).should == "\\u1000"
|
|
24
24
|
|
|
25
25
|
val = [0xffff].pack("U")
|
|
26
|
-
JSON.utf8_to_json(val).
|
|
26
|
+
JSON.utf8_to_json(val).should == "\\uffff"
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
specify "should format values between 0x00010000 and 0x0010ffff" do
|
|
30
30
|
val = [0x010000].pack("U")
|
|
31
|
-
JSON.utf8_to_json(val).
|
|
31
|
+
JSON.utf8_to_json(val).should == "\\ud800dc00"
|
|
32
32
|
|
|
33
33
|
val = [0x10ffff].pack("U")
|
|
34
|
-
JSON.utf8_to_json(val).
|
|
34
|
+
JSON.utf8_to_json(val).should == "\\udbffdfff"
|
|
35
35
|
end
|
|
36
36
|
|
|
37
37
|
specify "should parse unicode values" do
|
|
38
38
|
utf8 = '© ≠ €!'
|
|
39
39
|
json = '"\u00a9 \u2260 \u20ac!"'
|
|
40
|
-
utf8.to_json.
|
|
41
|
-
JSON.parse(json).
|
|
40
|
+
utf8.to_json.should == json
|
|
41
|
+
JSON.parse(json).should == utf8
|
|
42
42
|
|
|
43
43
|
utf8 = "\343\201\202\343\201\204\343\201\206\343\201\210\343\201\212"
|
|
44
44
|
json = '"\u3042\u3044\u3046\u3048\u304a"'
|
|
45
|
-
utf8.to_json.
|
|
46
|
-
JSON.parse(json).
|
|
45
|
+
utf8.to_json.should == json
|
|
46
|
+
JSON.parse(json).should == utf8
|
|
47
47
|
|
|
48
48
|
utf8 = 'საქართველო'
|
|
49
49
|
json = '"\u10e1\u10d0\u10e5\u10d0\u10e0\u10d7\u10d5\u10d4\u10da\u10dd"'
|
|
50
|
-
utf8.to_json.
|
|
51
|
-
JSON.parse(json).
|
|
50
|
+
utf8.to_json.should == json
|
|
51
|
+
JSON.parse(json).should == utf8
|
|
52
52
|
end
|
|
53
53
|
end
|
data/spec/true_class_spec.rb
CHANGED
metadata
CHANGED
|
@@ -3,8 +3,8 @@ rubygems_version: 0.9.0
|
|
|
3
3
|
specification_version: 1
|
|
4
4
|
name: fjson
|
|
5
5
|
version: !ruby/object:Gem::Version
|
|
6
|
-
version: 0.0.
|
|
7
|
-
date:
|
|
6
|
+
version: 0.0.9
|
|
7
|
+
date: 2007-02-02 00:00:00 -08:00
|
|
8
8
|
summary: This library is for parsing JSON strings and unparsing ruby data structures. This library is a fork of Florian Frank's JSON library with key parts implemented in C for performance improvements.
|
|
9
9
|
require_paths:
|
|
10
10
|
- lib
|
|
@@ -29,39 +29,21 @@ post_install_message:
|
|
|
29
29
|
authors:
|
|
30
30
|
- Brian Takita
|
|
31
31
|
files:
|
|
32
|
-
- Rakefile
|
|
33
32
|
- GPL
|
|
34
|
-
-
|
|
33
|
+
- Rakefile
|
|
35
34
|
- TODO
|
|
35
|
+
- CHANGES
|
|
36
36
|
- README
|
|
37
37
|
- hash_benchmark.rb
|
|
38
38
|
- rake_helper.rb
|
|
39
|
-
- install.rb
|
|
40
39
|
- mkmf_rake_builder.rb
|
|
41
|
-
-
|
|
40
|
+
- install.rb
|
|
42
41
|
- lib/fjson.rb
|
|
42
|
+
- lib/parser.rb
|
|
43
43
|
- lib/extensions/kernel.rb
|
|
44
44
|
- lib/extensions/class.rb
|
|
45
45
|
- lib/extensions/string.rb
|
|
46
46
|
- lib/json/editor.rb
|
|
47
|
-
- spec/rake_helper_spec.rb
|
|
48
|
-
- spec/true_class_spec.rb
|
|
49
|
-
- spec/float_spec.rb
|
|
50
|
-
- spec/string_spec.rb
|
|
51
|
-
- spec/object_spec.rb
|
|
52
|
-
- spec/nil_class_spec.rb
|
|
53
|
-
- spec/array_spec.rb
|
|
54
|
-
- spec/spec_helper.rb
|
|
55
|
-
- spec/false_class_spec.rb
|
|
56
|
-
- spec/string_when_not_supporting_unicode_and_kcode_is_not_utf8_json_spec.rb
|
|
57
|
-
- spec/state_spec.rb
|
|
58
|
-
- spec/hash_spec.rb
|
|
59
|
-
- spec/spec_suite.rb
|
|
60
|
-
- spec/integer_spec.rb
|
|
61
|
-
- spec/string_when_supporting_unicode_and_kcode_is_not_utf8_json_spec.rb
|
|
62
|
-
- spec/string_with_latin1_character_set_json_spec.rb
|
|
63
|
-
- spec/mkmf_rake_builder_spec.rb
|
|
64
|
-
- spec/string_with_utf8_values_when_supporting_unicode_json_spec.rb
|
|
65
47
|
- ext/extensions/false_class_ext/false_class_ext.h
|
|
66
48
|
- ext/extensions/hash_ext/hash_ext.h
|
|
67
49
|
- ext/extensions/true_class_ext/true_class_ext.h
|
|
@@ -106,23 +88,41 @@ files:
|
|
|
106
88
|
- ext/state_ext/extconf.rb
|
|
107
89
|
- ext/json_ext/extconf.mkmf.rb
|
|
108
90
|
- ext/json_ext/extconf.rb
|
|
109
|
-
test_files:
|
|
110
|
-
- spec/rake_helper_spec.rb
|
|
111
91
|
- spec/true_class_spec.rb
|
|
112
92
|
- spec/float_spec.rb
|
|
113
93
|
- spec/string_spec.rb
|
|
114
94
|
- spec/object_spec.rb
|
|
115
95
|
- spec/nil_class_spec.rb
|
|
96
|
+
- spec/string_when_not_supporting_unicode_and_kcode_is_not_utf8_json_spec.rb
|
|
116
97
|
- spec/array_spec.rb
|
|
98
|
+
- spec/spec_helper.rb
|
|
117
99
|
- spec/false_class_spec.rb
|
|
118
|
-
- spec/string_when_not_supporting_unicode_and_kcode_is_not_utf8_json_spec.rb
|
|
119
100
|
- spec/state_spec.rb
|
|
101
|
+
- spec/rake_helper_spec.rb
|
|
120
102
|
- spec/hash_spec.rb
|
|
121
|
-
- spec/integer_spec.rb
|
|
122
103
|
- spec/string_when_supporting_unicode_and_kcode_is_not_utf8_json_spec.rb
|
|
123
104
|
- spec/string_with_latin1_character_set_json_spec.rb
|
|
105
|
+
- spec/spec_suite.rb
|
|
106
|
+
- spec/integer_spec.rb
|
|
107
|
+
- spec/string_with_utf8_values_when_supporting_unicode_json_spec.rb
|
|
124
108
|
- spec/mkmf_rake_builder_spec.rb
|
|
109
|
+
test_files:
|
|
110
|
+
- spec/true_class_spec.rb
|
|
111
|
+
- spec/float_spec.rb
|
|
112
|
+
- spec/string_spec.rb
|
|
113
|
+
- spec/object_spec.rb
|
|
114
|
+
- spec/nil_class_spec.rb
|
|
115
|
+
- spec/string_when_not_supporting_unicode_and_kcode_is_not_utf8_json_spec.rb
|
|
116
|
+
- spec/array_spec.rb
|
|
117
|
+
- spec/false_class_spec.rb
|
|
118
|
+
- spec/state_spec.rb
|
|
119
|
+
- spec/rake_helper_spec.rb
|
|
120
|
+
- spec/hash_spec.rb
|
|
121
|
+
- spec/string_when_supporting_unicode_and_kcode_is_not_utf8_json_spec.rb
|
|
122
|
+
- spec/string_with_latin1_character_set_json_spec.rb
|
|
123
|
+
- spec/integer_spec.rb
|
|
125
124
|
- spec/string_with_utf8_values_when_supporting_unicode_json_spec.rb
|
|
125
|
+
- spec/mkmf_rake_builder_spec.rb
|
|
126
126
|
rdoc_options: []
|
|
127
127
|
|
|
128
128
|
extra_rdoc_files:
|
|
@@ -133,13 +133,5 @@ extensions:
|
|
|
133
133
|
- Rakefile
|
|
134
134
|
requirements: []
|
|
135
135
|
|
|
136
|
-
dependencies:
|
|
137
|
-
|
|
138
|
-
name: rspec
|
|
139
|
-
version_requirement:
|
|
140
|
-
version_requirements: !ruby/object:Gem::Version::Requirement
|
|
141
|
-
requirements:
|
|
142
|
-
- - ">="
|
|
143
|
-
- !ruby/object:Gem::Version
|
|
144
|
-
version: 0.6.4
|
|
145
|
-
version:
|
|
136
|
+
dependencies: []
|
|
137
|
+
|