mustang 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. data/README.md +11 -1
  2. data/Rakefile +1 -1
  3. data/TODO.md +2 -1
  4. data/ext/v8/extconf.rb +3 -1
  5. data/ext/v8/v8_array.cpp +2 -0
  6. data/ext/v8/v8_context.cpp +32 -5
  7. data/ext/v8/v8_date.cpp +1 -0
  8. data/ext/v8/v8_external.cpp +1 -0
  9. data/ext/v8/v8_function.cpp +3 -0
  10. data/ext/v8/v8_integer.cpp +1 -0
  11. data/ext/v8/v8_macros.h +6 -0
  12. data/ext/v8/v8_main.cpp +3 -1
  13. data/ext/v8/v8_number.cpp +1 -0
  14. data/ext/v8/v8_object.cpp +2 -0
  15. data/ext/v8/v8_regexp.cpp +1 -0
  16. data/ext/v8/v8_string.cpp +1 -0
  17. data/ext/v8/v8_value.cpp +2 -0
  18. data/lib/mustang.rb +20 -27
  19. data/lib/mustang/context.rb +0 -26
  20. data/lib/{core_ext → mustang/core_ext}/class.rb +1 -1
  21. data/lib/{core_ext → mustang/core_ext}/object.rb +2 -4
  22. data/lib/{core_ext → mustang/core_ext}/symbol.rb +0 -0
  23. data/lib/{support → mustang/support}/delegated.rb +0 -0
  24. data/lib/mustang/v8/array.rb +21 -0
  25. data/lib/mustang/v8/context.rb +15 -0
  26. data/lib/mustang/v8/date.rb +20 -0
  27. data/lib/mustang/v8/error.rb +17 -0
  28. data/lib/mustang/v8/external.rb +16 -0
  29. data/lib/mustang/v8/function.rb +13 -0
  30. data/lib/mustang/v8/integer.rb +16 -0
  31. data/lib/mustang/v8/number.rb +16 -0
  32. data/lib/mustang/v8/object.rb +66 -0
  33. data/lib/mustang/v8/regexp.rb +23 -0
  34. data/lib/mustang/v8/string.rb +27 -0
  35. data/mustang.gemspec +1 -1
  36. data/spec/{core_ext → mustang/core_ext}/class_spec.rb +3 -3
  37. data/spec/{core_ext → mustang/core_ext}/object_spec.rb +3 -3
  38. data/spec/{core_ext → mustang/core_ext}/symbol_spec.rb +1 -1
  39. data/spec/{v8 → mustang/v8}/array_spec.rb +12 -5
  40. data/spec/{v8 → mustang/v8}/cast_spec.rb +10 -10
  41. data/spec/{v8 → mustang/v8}/context_spec.rb +52 -6
  42. data/spec/{v8 → mustang/v8}/data_spec.rb +4 -4
  43. data/spec/{v8 → mustang/v8}/date_spec.rb +12 -5
  44. data/spec/{v8 → mustang/v8}/empty_spec.rb +4 -4
  45. data/spec/{v8 → mustang/v8}/errors_spec.rb +9 -9
  46. data/spec/{v8 → mustang/v8}/external_spec.rb +14 -7
  47. data/spec/{v8 → mustang/v8}/function_spec.rb +20 -13
  48. data/spec/{v8 → mustang/v8}/integer_spec.rb +13 -6
  49. data/spec/{v8 → mustang/v8}/main_spec.rb +2 -2
  50. data/spec/{v8 → mustang/v8}/null_spec.rb +4 -4
  51. data/spec/{v8 → mustang/v8}/number_spec.rb +5 -5
  52. data/spec/{v8 → mustang/v8}/object_spec.rb +13 -6
  53. data/spec/mustang/v8/primitive_spec.rb +9 -0
  54. data/spec/{v8 → mustang/v8}/regexp_spec.rb +12 -5
  55. data/spec/{v8 → mustang/v8}/string_spec.rb +12 -5
  56. data/spec/{v8 → mustang/v8}/undefined_spec.rb +4 -4
  57. data/spec/mustang/v8/value_spec.rb +222 -0
  58. data/spec/spec_helper.rb +1 -1
  59. metadata +91 -62
  60. data/lib/v8/array.rb +0 -21
  61. data/lib/v8/context.rb +0 -13
  62. data/lib/v8/date.rb +0 -20
  63. data/lib/v8/error.rb +0 -15
  64. data/lib/v8/external.rb +0 -16
  65. data/lib/v8/function.rb +0 -11
  66. data/lib/v8/integer.rb +0 -16
  67. data/lib/v8/number.rb +0 -16
  68. data/lib/v8/object.rb +0 -66
  69. data/lib/v8/regexp.rb +0 -23
  70. data/lib/v8/string.rb +0 -27
  71. data/spec/v8/primitive_spec.rb +0 -9
  72. data/spec/v8/value_spec.rb +0 -215
@@ -1,23 +0,0 @@
1
- require 'support/delegated'
2
-
3
- module V8
4
- class Regexp
5
- include Delegated
6
-
7
- def ==(other)
8
- to_regexp == other
9
- end
10
-
11
- def ===(other)
12
- to_regexp == other
13
- end
14
-
15
- def delegate
16
- to_regexp
17
- end
18
-
19
- def to_regexp
20
- ::Regexp.new(source, options)
21
- end
22
- end # Regexp
23
- end # V8
@@ -1,27 +0,0 @@
1
- require 'support/delegated'
2
-
3
- module V8
4
- class String
5
- # On ruby 1.9+ we have to force UTF-8 encoding here...
6
- if RUBY_VERSION > "1.9"
7
- alias_method :native_to_utf8, :to_utf8
8
-
9
- def to_utf8
10
- native_to_utf8.force_encoding("UTF-8")
11
- end
12
- end
13
-
14
- alias_method :to_s, :to_utf8
15
-
16
- include Comparable
17
- include Delegated
18
-
19
- def <=>(other)
20
- to_s <=> other
21
- end
22
-
23
- def delegate
24
- to_s
25
- end
26
- end # String
27
- end # V8
@@ -1,9 +0,0 @@
1
- require File.dirname(__FILE__) + '/../spec_helper'
2
-
3
- describe V8::Primitive do
4
- setup_context
5
-
6
- it "inherits V8::Value" do
7
- V8::Primitive.new(0).should be_kind_of(V8::Value)
8
- end
9
- end
@@ -1,215 +0,0 @@
1
- require File.dirname(__FILE__) + '/../spec_helper'
2
-
3
- describe V8::Value do
4
- subject { V8::Value }
5
- setup_context
6
-
7
- it "inherits V8::Data" do
8
- subject.new(Object.new).should be_kind_of(V8::Data)
9
- end
10
-
11
- describe ".new" do
12
- it "creates new v8 value" do
13
- subject.new(Object.new).should be_kind_of(V8::Value)
14
- end
15
- end
16
-
17
- describe "#object?" do
18
- it "returns true when value is an instance of V8::Object" do
19
- V8::Object.new.should be_object
20
- end
21
-
22
- it "returns false when value is not an instance of V8::Object" do
23
- V8::External.new(Object.new).should_not be_object
24
- end
25
-
26
- it "is aliased with #obj?" do
27
- V8::Object.new.should be_obj
28
- end
29
- end
30
-
31
- describe "#integer?" do
32
- it "returns true when value is an instance of V8::Integer" do
33
- V8::Integer.new(10).should be_integer
34
- end
35
-
36
- it "returns false when value is not an instance of V8::Integer" do
37
- subject.new(Object.new).should_not be_integer
38
- end
39
-
40
- it "is aliased with #int?" do
41
- V8::Integer.new(10).should be_int
42
- end
43
- end
44
-
45
- describe "#number?" do
46
- it "returns true when value is an instance of V8::Number" do
47
- V8::Number.new(10).should be_number
48
- end
49
-
50
- it "returns false when value is not an instance of V8::Number" do
51
- subject.new(Object.new).should_not be_number
52
- end
53
-
54
- it "is aliased with #num?" do
55
- V8::Number.new(10).should be_num
56
- end
57
- end
58
-
59
- describe "#string?" do
60
- it "returns true when value is an instance of V8::String" do
61
- V8::String.new("foo").should be_string
62
- end
63
-
64
- it "returns false when value is not an instance of V8::String" do
65
- subject.new(Object.new).should_not be_string
66
- end
67
-
68
- it "is aliased with #str?" do
69
- V8::String.new("foo").should be_str
70
- end
71
- end
72
-
73
- describe "#external?" do
74
- it "returns true when value is an instance of V8::External" do
75
- V8::External.new(Object.new).should be_external
76
- end
77
-
78
- it "returns false when value is not an instance of V8::External" do
79
- V8::Integer.new(10).should_not be_external
80
- end
81
- end
82
-
83
- describe "#array?" do
84
- it "returns true when value is an instance of V8::Array" do
85
- V8::Array.new(1,2,3).should be_array
86
- end
87
-
88
- it "returns false when value is not an instance of V8::Array" do
89
- subject.new(Object.new).should_not be_array
90
- end
91
-
92
- it "is aliased with #ary?" do
93
- V8::Array.new.should be_ary
94
- end
95
- end
96
-
97
- describe "#function?" do
98
- it "returns true when value is an instance of V8::Function" do
99
- V8::Function.new(proc {}).should be_function
100
- end
101
-
102
- it "returns false when value is not an instance of V8::Function" do
103
- V8::Integer.new(1).should_not be_function
104
- end
105
-
106
- it "is aliased with #func?" do
107
- V8::Function.new(proc {}).should be_func
108
- end
109
- end
110
-
111
- describe "#regexp?" do
112
- it "returns true when value is an instance of V8::Regexp" do
113
- V8::Regexp.new(/foo/).should be_regexp
114
- end
115
-
116
- it "returns false when value is not an instance of V8::Regexp" do
117
- V8::Integer.new(1).should_not be_regexp
118
- end
119
-
120
- it "is aliased with #regex?" do
121
- V8::Regexp.new(/foo/).should be_regex
122
- end
123
- end
124
-
125
- describe "#date?" do
126
- it "returns true when value is an instance of V8::Date" do
127
- V8::Date.new(Time.now).should be_date
128
- end
129
-
130
- it "returns false when value is not an instance of V8::Date" do
131
- V8::Integer.new(1).should_not be_date
132
- end
133
- end
134
-
135
- describe "#to_integer" do
136
- it "returns V8 integer representation of value" do
137
- val = V8::Integer.new(10)
138
- subject.new(val).to_integer.should == val
139
- end
140
- end
141
-
142
- describe "#to_string" do
143
- it "returns V8 string representation of value" do
144
- val = V8::String.new("foo")
145
- subject.new(val).to_string.should == val
146
- end
147
- end
148
-
149
- describe "#to_number" do
150
- it "returns V8 number representation of value" do
151
- val = V8::Number.new(10.5)
152
- subject.new(val).to_number.should == val
153
- end
154
- end
155
-
156
- describe "#to_object" do
157
- it "returns V8 object representation of value" do
158
- val = V8::Object.new(:foo => 1)
159
- subject.new(val).to_object.should == val
160
- end
161
- end
162
-
163
- describe "#to_boolean" do
164
- it "return V8 boolean representation of value" do
165
- V8::Object.new(:foo => 1).to_boolean.should be_true
166
- V8::Integer.new(0).to_boolean.should be_false
167
- end
168
- end
169
-
170
- describe "#===" do
171
- it "returns true when compared objects are strictly the same" do
172
- obj = V8::Object.new(:foo => 1)
173
- val = subject.new(obj)
174
- val.should === obj
175
- end
176
-
177
- it "returns false when compared objects are strictly different" do
178
- obj = V8::Object.new(:foo => 1)
179
- val = subject.new(V8::Array.new)
180
- val.should_not === obj
181
- end
182
- end
183
-
184
- describe "#==" do
185
- it "returns true when compared objects are the same" do
186
- obj1 = V8::Integer.new(1)
187
- obj2 = V8::Integer.new(1)
188
- subject.new(obj1).should == obj2
189
- end
190
-
191
- it "returns false when compared objects are different" do
192
- obj1 = V8::Object.new(:foo => 1)
193
- obj2 = V8::Object.new(:bar => 1)
194
- subject.new(obj1).should_not == obj2
195
- end
196
- end
197
-
198
- describe "null?" do
199
- it "returns true when object is not null" do
200
- V8::Object.new.should_not be_null
201
- end
202
- end
203
-
204
- describe "undefined?" do
205
- it "returns true when object is not undefined" do
206
- V8::Object.new.should_not be_undefined
207
- end
208
- end
209
-
210
- describe "empty?" do
211
- it "returns true when object is not empty" do
212
- V8::Object.new.should_not be_empty
213
- end
214
- end
215
- end