fjson 0.1.0 → 0.1.1
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 +0 -3
- data/Rakefile +43 -41
- data/ext/extensions/array_ext/array_ext.c +13 -81
- data/ext/extensions/array_ext/array_ext.h +4 -8
- data/ext/extensions/array_ext/extconf.mkmf.rb +3 -0
- data/ext/extensions/enumerable/enumerable.c +70 -0
- data/ext/extensions/enumerable/enumerable.h +9 -0
- data/ext/extensions/hash_ext/extconf.mkmf.rb +3 -0
- data/ext/extensions/hash_ext/hash_ext.c +13 -81
- data/ext/extensions/hash_ext/hash_ext.h +3 -8
- data/ext/json_ext/json_ext.c +12 -13
- data/ext/json_ext/json_ext.h +2 -0
- data/ext/state_ext/state_ext.c +16 -85
- data/ext/state_ext/state_ext.h +3 -7
- data/ext/state_ext/state_lib.c +107 -0
- data/ext/state_ext/state_lib.h +15 -0
- data/hash_benchmark.rb +0 -2
- data/hash_benchmark_action_support.rb +4 -0
- data/hash_benchmark_fjson.rb +3 -0
- data/hash_benchmark_json.rb +4 -0
- data/lib/json/editor.rb +1 -1
- data/mkmf_tasks.rb +99 -0
- data/rake_helper.rb +1 -1
- data/spec/array_spec.rb +12 -2
- data/spec/false_class_spec.rb +1 -1
- data/spec/float_spec.rb +1 -1
- data/spec/hash_spec.rb +13 -0
- data/spec/integer_spec.rb +1 -1
- data/spec/mkmf_tasks_spec.rb +110 -0
- data/spec/nil_class_spec.rb +1 -1
- data/spec/object_spec.rb +1 -1
- data/spec/spec_helper.rb +10 -0
- data/spec/spec_suite.rb +3 -8
- data/spec/state_spec.rb +10 -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 +58 -53
- data/mkmf_rake_builder.rb +0 -170
- data/spec/mkmf_rake_builder_spec.rb +0 -217
- data/spec/rake_helper_spec.rb +0 -9
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.1.
|
7
|
-
date: 2007-
|
6
|
+
version: 0.1.1
|
7
|
+
date: 2007-04-30 00:00:00 -07: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,100 +29,105 @@ post_install_message:
|
|
29
29
|
authors:
|
30
30
|
- Brian Takita
|
31
31
|
files:
|
32
|
-
- CHANGES
|
33
|
-
- GPL
|
34
32
|
- Rakefile
|
35
|
-
-
|
33
|
+
- GPL
|
34
|
+
- CHANGES
|
36
35
|
- TODO
|
36
|
+
- README
|
37
37
|
- hash_benchmark.rb
|
38
|
-
- install.rb
|
39
|
-
- mkmf_rake_builder.rb
|
40
38
|
- rake_helper.rb
|
41
|
-
-
|
39
|
+
- install.rb
|
40
|
+
- hash_benchmark_action_support.rb
|
41
|
+
- hash_benchmark_json.rb
|
42
|
+
- hash_benchmark_fjson.rb
|
43
|
+
- mkmf_tasks.rb
|
42
44
|
- lib/parser.rb
|
43
|
-
- lib/
|
45
|
+
- lib/fjson.rb
|
44
46
|
- lib/extensions/kernel.rb
|
47
|
+
- lib/extensions/class.rb
|
45
48
|
- lib/extensions/string.rb
|
46
49
|
- lib/json/editor.rb
|
47
|
-
- ext/extensions/array_ext/array_ext.h
|
48
50
|
- ext/extensions/false_class_ext/false_class_ext.h
|
49
|
-
- ext/extensions/float_ext/float_ext.h
|
50
51
|
- ext/extensions/hash_ext/hash_ext.h
|
51
|
-
- ext/extensions/
|
52
|
-
- ext/extensions/
|
52
|
+
- ext/extensions/true_class_ext/true_class_ext.h
|
53
|
+
- ext/extensions/float_ext/float_ext.h
|
53
54
|
- ext/extensions/object_ext/object_ext.h
|
54
55
|
- ext/extensions/string_ext/string_ext.h
|
55
|
-
- ext/extensions/
|
56
|
-
- ext/
|
56
|
+
- ext/extensions/nil_class_ext/nil_class_ext.h
|
57
|
+
- ext/extensions/integer_ext/integer_ext.h
|
58
|
+
- ext/extensions/array_ext/array_ext.h
|
59
|
+
- ext/extensions/enumerable/enumerable.h
|
57
60
|
- ext/state_ext/state_ext.h
|
58
|
-
- ext/
|
61
|
+
- ext/state_ext/state_lib.h
|
62
|
+
- ext/json_ext/json_ext.h
|
59
63
|
- ext/extensions/false_class_ext/false_class_ext.c
|
60
|
-
- ext/extensions/float_ext/float_ext.c
|
61
64
|
- ext/extensions/hash_ext/hash_ext.c
|
62
|
-
- ext/extensions/
|
63
|
-
- ext/extensions/
|
65
|
+
- ext/extensions/true_class_ext/true_class_ext.c
|
66
|
+
- ext/extensions/float_ext/float_ext.c
|
64
67
|
- ext/extensions/object_ext/object_ext.c
|
65
68
|
- ext/extensions/string_ext/string_ext.c
|
66
|
-
- ext/extensions/
|
67
|
-
- ext/
|
69
|
+
- ext/extensions/nil_class_ext/nil_class_ext.c
|
70
|
+
- ext/extensions/integer_ext/integer_ext.c
|
71
|
+
- ext/extensions/array_ext/array_ext.c
|
72
|
+
- ext/extensions/enumerable/enumerable.c
|
68
73
|
- ext/state_ext/state_ext.c
|
69
|
-
- ext/
|
70
|
-
- ext/
|
74
|
+
- ext/state_ext/state_lib.c
|
75
|
+
- ext/json_ext/json_ext.c
|
71
76
|
- ext/extensions/false_class_ext/extconf.mkmf.rb
|
72
77
|
- ext/extensions/false_class_ext/extconf.rb
|
73
|
-
- ext/extensions/float_ext/extconf.mkmf.rb
|
74
|
-
- ext/extensions/float_ext/extconf.rb
|
75
78
|
- ext/extensions/hash_ext/extconf.mkmf.rb
|
76
79
|
- ext/extensions/hash_ext/extconf.rb
|
77
|
-
- ext/extensions/
|
78
|
-
- ext/extensions/
|
79
|
-
- ext/extensions/
|
80
|
-
- ext/extensions/
|
80
|
+
- ext/extensions/true_class_ext/extconf.mkmf.rb
|
81
|
+
- ext/extensions/true_class_ext/extconf.rb
|
82
|
+
- ext/extensions/float_ext/extconf.mkmf.rb
|
83
|
+
- ext/extensions/float_ext/extconf.rb
|
81
84
|
- ext/extensions/object_ext/extconf.mkmf.rb
|
82
85
|
- ext/extensions/object_ext/extconf.rb
|
83
86
|
- ext/extensions/string_ext/extconf.mkmf.rb
|
84
87
|
- ext/extensions/string_ext/extconf.rb
|
85
|
-
- ext/extensions/
|
86
|
-
- ext/extensions/
|
87
|
-
- ext/
|
88
|
-
- ext/
|
88
|
+
- ext/extensions/nil_class_ext/extconf.mkmf.rb
|
89
|
+
- ext/extensions/nil_class_ext/extconf.rb
|
90
|
+
- ext/extensions/integer_ext/extconf.mkmf.rb
|
91
|
+
- ext/extensions/integer_ext/extconf.rb
|
92
|
+
- ext/extensions/array_ext/extconf.mkmf.rb
|
93
|
+
- ext/extensions/array_ext/extconf.rb
|
89
94
|
- ext/state_ext/extconf.mkmf.rb
|
90
95
|
- ext/state_ext/extconf.rb
|
91
|
-
-
|
92
|
-
-
|
96
|
+
- ext/json_ext/extconf.mkmf.rb
|
97
|
+
- ext/json_ext/extconf.rb
|
98
|
+
- spec/mkmf_tasks_spec.rb
|
99
|
+
- spec/true_class_spec.rb
|
93
100
|
- spec/float_spec.rb
|
94
|
-
- spec/
|
95
|
-
- spec/integer_spec.rb
|
96
|
-
- spec/mkmf_rake_builder_spec.rb
|
97
|
-
- spec/nil_class_spec.rb
|
101
|
+
- spec/string_spec.rb
|
98
102
|
- spec/object_spec.rb
|
99
|
-
- spec/
|
103
|
+
- spec/nil_class_spec.rb
|
104
|
+
- spec/array_spec.rb
|
100
105
|
- spec/spec_helper.rb
|
101
|
-
- spec/
|
102
|
-
- spec/state_spec.rb
|
103
|
-
- spec/string_spec.rb
|
106
|
+
- spec/false_class_spec.rb
|
104
107
|
- spec/string_when_not_supporting_unicode_and_kcode_is_not_utf8_json_spec.rb
|
108
|
+
- spec/state_spec.rb
|
109
|
+
- spec/hash_spec.rb
|
110
|
+
- spec/spec_suite.rb
|
111
|
+
- spec/integer_spec.rb
|
105
112
|
- spec/string_when_supporting_unicode_and_kcode_is_not_utf8_json_spec.rb
|
106
113
|
- spec/string_with_latin1_character_set_json_spec.rb
|
107
114
|
- spec/string_with_utf8_values_when_supporting_unicode_json_spec.rb
|
108
|
-
- spec/true_class_spec.rb
|
109
115
|
test_files:
|
116
|
+
- spec/mkmf_tasks_spec.rb
|
117
|
+
- spec/true_class_spec.rb
|
118
|
+
- spec/float_spec.rb
|
119
|
+
- spec/string_spec.rb
|
120
|
+
- spec/object_spec.rb
|
121
|
+
- spec/nil_class_spec.rb
|
110
122
|
- spec/array_spec.rb
|
111
123
|
- spec/false_class_spec.rb
|
112
|
-
- spec/
|
124
|
+
- spec/string_when_not_supporting_unicode_and_kcode_is_not_utf8_json_spec.rb
|
125
|
+
- spec/state_spec.rb
|
113
126
|
- spec/hash_spec.rb
|
114
127
|
- spec/integer_spec.rb
|
115
|
-
- spec/mkmf_rake_builder_spec.rb
|
116
|
-
- spec/nil_class_spec.rb
|
117
|
-
- spec/object_spec.rb
|
118
|
-
- spec/rake_helper_spec.rb
|
119
|
-
- spec/state_spec.rb
|
120
|
-
- spec/string_spec.rb
|
121
|
-
- spec/string_when_not_supporting_unicode_and_kcode_is_not_utf8_json_spec.rb
|
122
128
|
- spec/string_when_supporting_unicode_and_kcode_is_not_utf8_json_spec.rb
|
123
129
|
- spec/string_with_latin1_character_set_json_spec.rb
|
124
130
|
- spec/string_with_utf8_values_when_supporting_unicode_json_spec.rb
|
125
|
-
- spec/true_class_spec.rb
|
126
131
|
rdoc_options: []
|
127
132
|
|
128
133
|
extra_rdoc_files:
|
data/mkmf_rake_builder.rb
DELETED
@@ -1,170 +0,0 @@
|
|
1
|
-
class MkmfRakeBuilder
|
2
|
-
attr_writer :project_dir,
|
3
|
-
:rake_application,
|
4
|
-
:rake_tasks,
|
5
|
-
:rake_file_tasks,
|
6
|
-
:dir_class,
|
7
|
-
:file_extension,
|
8
|
-
:extensions_to_build,
|
9
|
-
:file_class
|
10
|
-
|
11
|
-
def initialize
|
12
|
-
@extconf_file = "extconf.mkmf.rb"
|
13
|
-
end
|
14
|
-
|
15
|
-
def build_default_task
|
16
|
-
task(:extension => [ :compile, :install ]) do
|
17
|
-
end
|
18
|
-
task(:default => [ :extension ]) do
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def build_compile_task
|
23
|
-
task :compile => @extensions_to_build.collect {|ext| ext.first} do
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
def build_spec_task
|
28
|
-
task :spec => [:compile, :install] do
|
29
|
-
dir = @project_dir
|
30
|
-
require expand_path("#{dir}/spec/spec_suite")
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
def build_lib_task
|
35
|
-
task :lib do
|
36
|
-
directory "lib"
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
def build_extension_compile_tasks
|
41
|
-
@extensions_to_build.each do |data|
|
42
|
-
build_extension_compile_task(data[1])
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
def build_install_task
|
47
|
-
extension_paths = self.extension_paths
|
48
|
-
task :install do
|
49
|
-
extension_paths.each do |extension_path|
|
50
|
-
library_path = library_path(extension_path)
|
51
|
-
raise "Extension binary for #{extension_path} does not exist. Did you run rake compile?" unless library_path
|
52
|
-
build_path = build_path(extension_path)
|
53
|
-
raise "File #{build_path} does not exist" unless file_exists?(build_path)
|
54
|
-
cp build_path, library_path(extension_path)
|
55
|
-
end
|
56
|
-
end
|
57
|
-
extension_paths
|
58
|
-
end
|
59
|
-
|
60
|
-
def build_cleanup_task
|
61
|
-
extension_paths = self.extension_paths
|
62
|
-
task :cleanup do
|
63
|
-
extension_paths.each do |extension_path|
|
64
|
-
library_path = library_path(extension_path)
|
65
|
-
rm library_path if library_path && file_exists?(library_path)
|
66
|
-
|
67
|
-
build_file_path = build_path(extension_path)
|
68
|
-
rm build_file_path if build_file_path && file_exists?(build_file_path)
|
69
|
-
|
70
|
-
make_file_path = "#{build_dir(extension_path)}/Makefile"
|
71
|
-
rm make_file_path if make_file_path && file_exists?(make_file_path)
|
72
|
-
end
|
73
|
-
end
|
74
|
-
extension_paths
|
75
|
-
end
|
76
|
-
|
77
|
-
protected
|
78
|
-
def extension_paths
|
79
|
-
@extensions_to_build.collect {|data| data[1]}
|
80
|
-
end
|
81
|
-
|
82
|
-
def build_extension_compile_task(extension_path)
|
83
|
-
extension_dir = "ext/#{extension_path}"
|
84
|
-
extension = file_name(extension_path)
|
85
|
-
extension_path = "#{extension_dir}/#{extension}.#{@file_extension}"
|
86
|
-
|
87
|
-
desc "Builds the #{extension} extension"
|
88
|
-
task extension.to_sym => ["#{extension_dir}/Makefile", extension_path ]
|
89
|
-
|
90
|
-
file "#{extension_dir}/Makefile" => ["#{extension_dir}/#{@extconf_file}"] do
|
91
|
-
extconf extension_dir
|
92
|
-
end
|
93
|
-
|
94
|
-
ext_files = FileList[
|
95
|
-
"#{extension_dir}/*.c",
|
96
|
-
"#{extension_dir}/*.h",
|
97
|
-
"#{extension_dir}/#{@extconf_file}",
|
98
|
-
"#{extension_dir}/Makefile",
|
99
|
-
"lib"
|
100
|
-
]
|
101
|
-
file extension_path => ext_files do
|
102
|
-
make extension_dir
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
def extconf(dir)
|
107
|
-
chdir(dir) do
|
108
|
-
ruby @extconf_file
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
def ruby(file)
|
113
|
-
sh("ruby #{file}")
|
114
|
-
end
|
115
|
-
|
116
|
-
def make(makedir)
|
117
|
-
chdir(makedir) do
|
118
|
-
sh("make")
|
119
|
-
end
|
120
|
-
end
|
121
|
-
|
122
|
-
def chdir(dir, &block)
|
123
|
-
@dir_class.chdir(dir) do
|
124
|
-
yield
|
125
|
-
end
|
126
|
-
end
|
127
|
-
|
128
|
-
def desc(comment)
|
129
|
-
@rake_application.last_comment = comment
|
130
|
-
end
|
131
|
-
|
132
|
-
def task(*args, &block)
|
133
|
-
@rake_tasks.define_task(*args, &block)
|
134
|
-
end
|
135
|
-
|
136
|
-
def file(*args, &block)
|
137
|
-
@rake_file_tasks.define_task(*args, &block)
|
138
|
-
end
|
139
|
-
|
140
|
-
def build_dir(relative_extension_path)
|
141
|
-
"#{@project_dir}/ext/#{relative_extension_path}"
|
142
|
-
end
|
143
|
-
|
144
|
-
def build_path(relative_extension_path)
|
145
|
-
basename = "#{build_dir(relative_extension_path)}/#{file_name(relative_extension_path)}"
|
146
|
-
"#{basename}.#{@file_extension}"
|
147
|
-
end
|
148
|
-
|
149
|
-
def library_path(relative_extension_path)
|
150
|
-
library_directory_path = "#{@project_dir}/lib/#{file_directory(relative_extension_path)}"
|
151
|
-
binary_name = "#{file_name(relative_extension_path)}.#{@file_extension}"
|
152
|
-
"#{library_directory_path}/#{binary_name}"
|
153
|
-
end
|
154
|
-
|
155
|
-
def expand_path(path)
|
156
|
-
@file_class.expand_path path
|
157
|
-
end
|
158
|
-
|
159
|
-
def file_exists?(path)
|
160
|
-
@file_class.exists? path
|
161
|
-
end
|
162
|
-
|
163
|
-
def file_name(path)
|
164
|
-
@file_class.basename path
|
165
|
-
end
|
166
|
-
|
167
|
-
def file_directory(path)
|
168
|
-
@file_class.dirname path
|
169
|
-
end
|
170
|
-
end
|
@@ -1,217 +0,0 @@
|
|
1
|
-
dir = File.dirname(__FILE__)
|
2
|
-
require "#{dir}/spec_helper"
|
3
|
-
|
4
|
-
context "A MkmfRakeBuilder" do
|
5
|
-
setup do
|
6
|
-
@builder = MkmfRakeBuilder.new
|
7
|
-
|
8
|
-
dir = File.dirname(__FILE__)
|
9
|
-
@project_dir = @builder.project_dir = "/project/dir"
|
10
|
-
@rake_application = @builder.rake_application = mock("rake_application")
|
11
|
-
@rake_tasks = @builder.rake_tasks = mock("rake_tasks")
|
12
|
-
@rake_file_tasks = @builder.rake_file_tasks = mock("rake_file_tasks")
|
13
|
-
@dir_class = @builder.dir_class = mock("dir_class")
|
14
|
-
@file_class = @builder.file_class = File
|
15
|
-
end
|
16
|
-
|
17
|
-
specify "should build the default task" do
|
18
|
-
@rake_tasks.should_receive(:define_task).with({:extension => [ :compile, :install ]})
|
19
|
-
@rake_tasks.should_receive(:define_task).with({:default => [ :extension ]})
|
20
|
-
@builder.build_default_task
|
21
|
-
end
|
22
|
-
|
23
|
-
specify "should build the compile task" do
|
24
|
-
extensions_to_build = @builder.extensions_to_build = [[:foo, "foo"], [:bar, "bar"]]
|
25
|
-
@rake_tasks.should_receive(:define_task).with({:compile => [:foo, :bar]})
|
26
|
-
@builder.build_compile_task
|
27
|
-
end
|
28
|
-
|
29
|
-
specify "should build spec task to require spec suite" do
|
30
|
-
spec_task = nil
|
31
|
-
@rake_tasks.should_receive(:define_task).with({:spec => [:compile, :install]}).
|
32
|
-
and_return{|definition, spec_task| spec_task = spec_task}
|
33
|
-
@builder.build_spec_task
|
34
|
-
|
35
|
-
require_args = nil
|
36
|
-
@builder.define_instance_method :require do |*args|
|
37
|
-
require_args = args
|
38
|
-
end
|
39
|
-
spec_task.call
|
40
|
-
require_args.should == ["/project/dir/spec/spec_suite"]
|
41
|
-
end
|
42
|
-
|
43
|
-
specify "should build lib task to create the lib directory" do
|
44
|
-
spec_task = nil
|
45
|
-
@rake_tasks.should_receive(:define_task).with(:lib).
|
46
|
-
and_return{|definition, spec_task| spec_task = spec_task}
|
47
|
-
@builder.build_lib_task
|
48
|
-
|
49
|
-
directory_args = nil
|
50
|
-
@builder.define_instance_method :directory do |*args|
|
51
|
-
directory_args = args
|
52
|
-
end
|
53
|
-
spec_task.call
|
54
|
-
directory_args.should == ["lib"]
|
55
|
-
end
|
56
|
-
|
57
|
-
specify "should build all extension compile tasks" do
|
58
|
-
extensions_to_build = @builder.extensions_to_build = [[:foo, "foo"], [:bar, "bar"]]
|
59
|
-
specify_build_extension_compile_task("foo", "foo")
|
60
|
-
specify_build_extension_compile_task("bar", "bar")
|
61
|
-
@builder.build_extension_compile_tasks
|
62
|
-
end
|
63
|
-
|
64
|
-
specify "should build extension compile task that creates a makefile and executable" do
|
65
|
-
extension_path = "extension/path"
|
66
|
-
class << @builder
|
67
|
-
public :build_extension_compile_task
|
68
|
-
end
|
69
|
-
makefile_task, executable_task = specify_build_extension_compile_task(extension_path, "path") do
|
70
|
-
@builder.build_extension_compile_task(extension_path)
|
71
|
-
end
|
72
|
-
|
73
|
-
specify_makefile_task(makefile_task)
|
74
|
-
specify_executable_task(executable_task)
|
75
|
-
end
|
76
|
-
|
77
|
-
def specify_makefile_task(makefile_task)
|
78
|
-
dir_class = @builder.dir_class = mock("dir_class_for_makefile")
|
79
|
-
makefile_chdir_task = nil
|
80
|
-
dir_class.should_receive(:chdir).with("ext/extension/path").
|
81
|
-
and_return do |name, makefile_chdir_task|
|
82
|
-
makefile_chdir_task = makefile_chdir_task
|
83
|
-
end
|
84
|
-
makefile_task.call
|
85
|
-
|
86
|
-
sh_args = []
|
87
|
-
@builder.define_instance_method :sh do |*args|
|
88
|
-
sh_args << args
|
89
|
-
end
|
90
|
-
makefile_chdir_task.call
|
91
|
-
sh_args.should == [["ruby extconf.mkmf.rb"]]
|
92
|
-
end
|
93
|
-
|
94
|
-
def specify_executable_task(executable_task)
|
95
|
-
dir_class = @builder.dir_class = mock("dir_class_for_executable")
|
96
|
-
executable_chdir_task = nil
|
97
|
-
dir_class.should_receive(:chdir).with("ext/extension/path").
|
98
|
-
and_return do |name, executable_chdir_task|
|
99
|
-
executable_chdir_task = executable_chdir_task
|
100
|
-
end
|
101
|
-
executable_task.call
|
102
|
-
|
103
|
-
sh_args = []
|
104
|
-
@builder.define_instance_method :sh do |*args|
|
105
|
-
sh_args << args
|
106
|
-
end
|
107
|
-
executable_chdir_task.call
|
108
|
-
sh_args.should == [["make"]]
|
109
|
-
end
|
110
|
-
|
111
|
-
specify "should build install task to install all of the compiled extensions" do
|
112
|
-
extensions_to_build = @builder.extensions_to_build = [[:foo, "extensions/foo"], [:bar, "extensions/bar"]]
|
113
|
-
file_extension = @builder.file_extension = "file_extension"
|
114
|
-
rake_task = nil
|
115
|
-
@rake_tasks.should_receive(:define_task).with(:install).
|
116
|
-
and_return {|name, rake_task| rake_task = rake_task}
|
117
|
-
@builder.build_install_task.should == ["extensions/foo", "extensions/bar"]
|
118
|
-
|
119
|
-
file_class = @builder.file_class = mock("file_class")
|
120
|
-
file_class.should_receive(:dirname).at_least(1).with("extensions/foo").and_return("extensions")
|
121
|
-
file_class.should_receive(:dirname).at_least(1).with("extensions/bar").and_return("extensions")
|
122
|
-
file_class.should_receive(:basename).at_least(1).with("extensions/foo").and_return("foo")
|
123
|
-
file_class.should_receive(:basename).at_least(1).with("extensions/bar").and_return("bar")
|
124
|
-
file_class.should_receive(:exists?).at_least(1).
|
125
|
-
with("/project/dir/ext/extensions/foo/foo.file_extension").and_return(true)
|
126
|
-
file_class.should_receive(:exists?).at_least(1).
|
127
|
-
with("/project/dir/ext/extensions/bar/bar.file_extension").and_return(true)
|
128
|
-
|
129
|
-
cp_args = []
|
130
|
-
@builder.define_instance_method :cp do |*args|
|
131
|
-
cp_args << args
|
132
|
-
end
|
133
|
-
rake_task.call
|
134
|
-
|
135
|
-
cp_args.should == [
|
136
|
-
["/project/dir/ext/extensions/foo/foo.file_extension", "/project/dir/lib/extensions/foo.file_extension"],
|
137
|
-
["/project/dir/ext/extensions/bar/bar.file_extension", "/project/dir/lib/extensions/bar.file_extension"]
|
138
|
-
]
|
139
|
-
end
|
140
|
-
|
141
|
-
specify "should build cleanup task that removes all of the compiled files" do
|
142
|
-
extensions_to_build = @builder.extensions_to_build = [[:foo, "extensions/foo"], [:bar, "extensions/bar"]]
|
143
|
-
file_extension = @builder.file_extension = "file_extension"
|
144
|
-
cleanup_task = nil
|
145
|
-
@rake_tasks.should_receive(:define_task).with(:cleanup).
|
146
|
-
and_return do |name, cleanup_task|
|
147
|
-
cleanup_task = cleanup_task
|
148
|
-
end
|
149
|
-
@builder.build_cleanup_task.should == ["extensions/foo", "extensions/bar"]
|
150
|
-
|
151
|
-
file_class = @builder.file_class = mock("file_class")
|
152
|
-
file_class.should_receive(:dirname).at_least(1).with("extensions/foo").and_return("extensions")
|
153
|
-
file_class.should_receive(:dirname).at_least(1).with("extensions/bar").and_return("extensions")
|
154
|
-
file_class.should_receive(:basename).at_least(1).with("extensions/foo").and_return("foo")
|
155
|
-
file_class.should_receive(:basename).at_least(1).with("extensions/bar").and_return("bar")
|
156
|
-
file_class.should_receive(:exists?).at_least(1).
|
157
|
-
with("/project/dir/ext/extensions/foo/foo.file_extension").and_return(true)
|
158
|
-
file_class.should_receive(:exists?).at_least(1).
|
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/lib/extensions/foo.file_extension").and_return(true)
|
162
|
-
file_class.should_receive(:exists?).at_least(1).
|
163
|
-
with("/project/dir/lib/extensions/bar.file_extension").and_return(true)
|
164
|
-
file_class.should_receive(:exists?).at_least(1).
|
165
|
-
with("/project/dir/ext/extensions/foo/Makefile").and_return(true)
|
166
|
-
file_class.should_receive(:exists?).at_least(1).
|
167
|
-
with("/project/dir/ext/extensions/bar/Makefile").and_return(true)
|
168
|
-
|
169
|
-
|
170
|
-
rm_args = []
|
171
|
-
@builder.define_instance_method :rm do |*args|
|
172
|
-
rm_args << args
|
173
|
-
end
|
174
|
-
cleanup_task.call
|
175
|
-
|
176
|
-
rm_args.should == [
|
177
|
-
["/project/dir/lib/extensions/foo.file_extension"],
|
178
|
-
["/project/dir/ext/extensions/foo/foo.file_extension"],
|
179
|
-
["/project/dir/ext/extensions/foo/Makefile"],
|
180
|
-
["/project/dir/lib/extensions/bar.file_extension"],
|
181
|
-
["/project/dir/ext/extensions/bar/bar.file_extension"],
|
182
|
-
["/project/dir/ext/extensions/bar/Makefile"],
|
183
|
-
]
|
184
|
-
end
|
185
|
-
|
186
|
-
def specify_build_extension_compile_task(extension_path, extension)
|
187
|
-
file_extension = @builder.file_extension = "file_extension"
|
188
|
-
@rake_application.should_receive(:last_comment=).with("Builds the #{extension} extension")
|
189
|
-
expected_executable = "ext/#{extension_path}/#{extension}.file_extension"
|
190
|
-
@rake_tasks.should_receive(:define_task).with({extension.to_sym => ["ext/#{extension_path}/Makefile", expected_executable ]})
|
191
|
-
makefile_task = nil
|
192
|
-
@rake_file_tasks.should_receive(:define_task).
|
193
|
-
with({"ext/#{extension_path}/Makefile" => ["ext/#{extension_path}/extconf.mkmf.rb"]}).
|
194
|
-
and_return do |task_name, makefile_task|
|
195
|
-
makefile_task = makefile_task
|
196
|
-
end
|
197
|
-
|
198
|
-
file_list = FileList[
|
199
|
-
"ext/#{extension_path}/*.c",
|
200
|
-
"ext/#{extension_path}/*.h",
|
201
|
-
"ext/#{extension_path}/extconf.mkmf.rb",
|
202
|
-
"ext/#{extension_path}/Makefile",
|
203
|
-
"lib"
|
204
|
-
]
|
205
|
-
executable_task = nil
|
206
|
-
@rake_file_tasks.should_receive(:define_task).with({expected_executable => file_list}).
|
207
|
-
and_return do |task_name, executable_task|
|
208
|
-
executable_task = executable_task
|
209
|
-
end
|
210
|
-
|
211
|
-
yield if block_given?
|
212
|
-
[makefile_task, executable_task]
|
213
|
-
end
|
214
|
-
|
215
|
-
def specify_make_executable_task(expected_executable, extension_path)
|
216
|
-
end
|
217
|
-
end
|