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
@@ -14,7 +14,7 @@ def debug
14
14
  end
15
15
 
16
16
  def setup_context
17
- let(:cxt) { V8::Context.new }
17
+ let(:cxt) { Mustang::V8::Context.new }
18
18
  before { cxt.enter }
19
19
  after { cxt.exit }
20
20
  end
metadata CHANGED
@@ -1,8 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mustang
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 23
4
5
  prerelease:
5
- version: 0.1.1
6
+ segments:
7
+ - 0
8
+ - 2
9
+ - 0
10
+ version: 0.2.0
6
11
  platform: ruby
7
12
  authors:
8
13
  - Chris Kowalik
@@ -11,7 +16,8 @@ autorequire:
11
16
  bindir: bin
12
17
  cert_chain: []
13
18
 
14
- date: 2011-04-05 00:00:00 Z
19
+ date: 2011-04-06 00:00:00 -03:00
20
+ default_executable:
15
21
  dependencies:
16
22
  - !ruby/object:Gem::Dependency
17
23
  name: ore-tasks
@@ -21,6 +27,10 @@ dependencies:
21
27
  requirements:
22
28
  - - ~>
23
29
  - !ruby/object:Gem::Version
30
+ hash: 3
31
+ segments:
32
+ - 0
33
+ - 4
24
34
  version: "0.4"
25
35
  type: :development
26
36
  version_requirements: *id001
@@ -32,6 +42,10 @@ dependencies:
32
42
  requirements:
33
43
  - - ~>
34
44
  - !ruby/object:Gem::Version
45
+ hash: 3
46
+ segments:
47
+ - 2
48
+ - 0
35
49
  version: "2.0"
36
50
  type: :development
37
51
  version_requirements: *id002
@@ -43,6 +57,10 @@ dependencies:
43
57
  requirements:
44
58
  - - ~>
45
59
  - !ruby/object:Gem::Version
60
+ hash: 25
61
+ segments:
62
+ - 0
63
+ - 9
46
64
  version: "0.9"
47
65
  type: :development
48
66
  version_requirements: *id003
@@ -54,6 +72,10 @@ dependencies:
54
72
  requirements:
55
73
  - - ~>
56
74
  - !ruby/object:Gem::Version
75
+ hash: 5
76
+ segments:
77
+ - 0
78
+ - 7
57
79
  version: "0.7"
58
80
  type: :development
59
81
  version_requirements: *id004
@@ -107,50 +129,50 @@ files:
107
129
  - ext/v8/v8_string.h
108
130
  - ext/v8/v8_value.cpp
109
131
  - ext/v8/v8_value.h
110
- - lib/core_ext/class.rb
111
- - lib/core_ext/object.rb
112
- - lib/core_ext/symbol.rb
113
132
  - lib/mustang.rb
114
133
  - lib/mustang/context.rb
134
+ - lib/mustang/core_ext/class.rb
135
+ - lib/mustang/core_ext/object.rb
136
+ - lib/mustang/core_ext/symbol.rb
115
137
  - lib/mustang/errors.rb
116
- - lib/support/delegated.rb
117
- - lib/v8/array.rb
118
- - lib/v8/context.rb
119
- - lib/v8/date.rb
120
- - lib/v8/error.rb
121
- - lib/v8/external.rb
122
- - lib/v8/function.rb
123
- - lib/v8/integer.rb
124
- - lib/v8/number.rb
125
- - lib/v8/object.rb
126
- - lib/v8/regexp.rb
127
- - lib/v8/string.rb
138
+ - lib/mustang/support/delegated.rb
139
+ - lib/mustang/v8/array.rb
140
+ - lib/mustang/v8/context.rb
141
+ - lib/mustang/v8/date.rb
142
+ - lib/mustang/v8/error.rb
143
+ - lib/mustang/v8/external.rb
144
+ - lib/mustang/v8/function.rb
145
+ - lib/mustang/v8/integer.rb
146
+ - lib/mustang/v8/number.rb
147
+ - lib/mustang/v8/object.rb
148
+ - lib/mustang/v8/regexp.rb
149
+ - lib/mustang/v8/string.rb
128
150
  - mustang.gemspec
129
- - spec/core_ext/class_spec.rb
130
- - spec/core_ext/object_spec.rb
131
- - spec/core_ext/symbol_spec.rb
132
151
  - spec/fixtures/test1.js
133
152
  - spec/fixtures/test2.js
153
+ - spec/mustang/core_ext/class_spec.rb
154
+ - spec/mustang/core_ext/object_spec.rb
155
+ - spec/mustang/core_ext/symbol_spec.rb
156
+ - spec/mustang/v8/array_spec.rb
157
+ - spec/mustang/v8/cast_spec.rb
158
+ - spec/mustang/v8/context_spec.rb
159
+ - spec/mustang/v8/data_spec.rb
160
+ - spec/mustang/v8/date_spec.rb
161
+ - spec/mustang/v8/empty_spec.rb
162
+ - spec/mustang/v8/errors_spec.rb
163
+ - spec/mustang/v8/external_spec.rb
164
+ - spec/mustang/v8/function_spec.rb
165
+ - spec/mustang/v8/integer_spec.rb
166
+ - spec/mustang/v8/main_spec.rb
167
+ - spec/mustang/v8/null_spec.rb
168
+ - spec/mustang/v8/number_spec.rb
169
+ - spec/mustang/v8/object_spec.rb
170
+ - spec/mustang/v8/primitive_spec.rb
171
+ - spec/mustang/v8/regexp_spec.rb
172
+ - spec/mustang/v8/string_spec.rb
173
+ - spec/mustang/v8/undefined_spec.rb
174
+ - spec/mustang/v8/value_spec.rb
134
175
  - spec/spec_helper.rb
135
- - spec/v8/array_spec.rb
136
- - spec/v8/cast_spec.rb
137
- - spec/v8/context_spec.rb
138
- - spec/v8/data_spec.rb
139
- - spec/v8/date_spec.rb
140
- - spec/v8/empty_spec.rb
141
- - spec/v8/errors_spec.rb
142
- - spec/v8/external_spec.rb
143
- - spec/v8/function_spec.rb
144
- - spec/v8/integer_spec.rb
145
- - spec/v8/main_spec.rb
146
- - spec/v8/null_spec.rb
147
- - spec/v8/number_spec.rb
148
- - spec/v8/object_spec.rb
149
- - spec/v8/primitive_spec.rb
150
- - spec/v8/regexp_spec.rb
151
- - spec/v8/string_spec.rb
152
- - spec/v8/undefined_spec.rb
153
- - spec/v8/value_spec.rb
154
176
  - vendor/v8/.gitignore
155
177
  - vendor/v8/AUTHORS
156
178
  - vendor/v8/ChangeLog
@@ -1577,6 +1599,7 @@ files:
1577
1599
  - vendor/v8/tools/visual_studio/v8_x64.vcproj
1578
1600
  - vendor/v8/tools/visual_studio/x64.vsprops
1579
1601
  - vendor/v8/tools/windows-tick-processor.bat
1602
+ has_rdoc: true
1580
1603
  homepage: http://github.com/nu7hatch/mustang
1581
1604
  licenses:
1582
1605
  - MIT
@@ -1591,43 +1614,49 @@ required_ruby_version: !ruby/object:Gem::Requirement
1591
1614
  requirements:
1592
1615
  - - ">="
1593
1616
  - !ruby/object:Gem::Version
1617
+ hash: 3
1618
+ segments:
1619
+ - 0
1594
1620
  version: "0"
1595
1621
  required_rubygems_version: !ruby/object:Gem::Requirement
1596
1622
  none: false
1597
1623
  requirements:
1598
1624
  - - ">="
1599
1625
  - !ruby/object:Gem::Version
1626
+ hash: 3
1627
+ segments:
1628
+ - 0
1600
1629
  version: "0"
1601
1630
  requirements: []
1602
1631
 
1603
1632
  rubyforge_project:
1604
- rubygems_version: 1.7.1
1633
+ rubygems_version: 1.4.1
1605
1634
  signing_key:
1606
1635
  specification_version: 3
1607
1636
  summary: Awesome V8 JavaScript engine embedded into the Ruby's shiny body
1608
1637
  test_files:
1609
- - spec/core_ext/class_spec.rb
1610
- - spec/core_ext/object_spec.rb
1611
- - spec/core_ext/symbol_spec.rb
1612
1638
  - spec/fixtures/test1.js
1613
1639
  - spec/fixtures/test2.js
1640
+ - spec/mustang/core_ext/class_spec.rb
1641
+ - spec/mustang/core_ext/object_spec.rb
1642
+ - spec/mustang/core_ext/symbol_spec.rb
1643
+ - spec/mustang/v8/array_spec.rb
1644
+ - spec/mustang/v8/cast_spec.rb
1645
+ - spec/mustang/v8/context_spec.rb
1646
+ - spec/mustang/v8/data_spec.rb
1647
+ - spec/mustang/v8/date_spec.rb
1648
+ - spec/mustang/v8/empty_spec.rb
1649
+ - spec/mustang/v8/errors_spec.rb
1650
+ - spec/mustang/v8/external_spec.rb
1651
+ - spec/mustang/v8/function_spec.rb
1652
+ - spec/mustang/v8/integer_spec.rb
1653
+ - spec/mustang/v8/main_spec.rb
1654
+ - spec/mustang/v8/null_spec.rb
1655
+ - spec/mustang/v8/number_spec.rb
1656
+ - spec/mustang/v8/object_spec.rb
1657
+ - spec/mustang/v8/primitive_spec.rb
1658
+ - spec/mustang/v8/regexp_spec.rb
1659
+ - spec/mustang/v8/string_spec.rb
1660
+ - spec/mustang/v8/undefined_spec.rb
1661
+ - spec/mustang/v8/value_spec.rb
1614
1662
  - spec/spec_helper.rb
1615
- - spec/v8/array_spec.rb
1616
- - spec/v8/cast_spec.rb
1617
- - spec/v8/context_spec.rb
1618
- - spec/v8/data_spec.rb
1619
- - spec/v8/date_spec.rb
1620
- - spec/v8/empty_spec.rb
1621
- - spec/v8/errors_spec.rb
1622
- - spec/v8/external_spec.rb
1623
- - spec/v8/function_spec.rb
1624
- - spec/v8/integer_spec.rb
1625
- - spec/v8/main_spec.rb
1626
- - spec/v8/null_spec.rb
1627
- - spec/v8/number_spec.rb
1628
- - spec/v8/object_spec.rb
1629
- - spec/v8/primitive_spec.rb
1630
- - spec/v8/regexp_spec.rb
1631
- - spec/v8/string_spec.rb
1632
- - spec/v8/undefined_spec.rb
1633
- - spec/v8/value_spec.rb
@@ -1,21 +0,0 @@
1
- require 'support/delegated'
2
-
3
- module V8
4
- class Array
5
- include Comparable
6
- include Enumerable
7
- include Delegated
8
-
9
- def <=>(other)
10
- to_a <=> other
11
- end
12
-
13
- def each(*args, &block)
14
- to_a.each(*args, &block)
15
- end
16
-
17
- def delegate
18
- to_a
19
- end
20
- end # Array
21
- end # V8
@@ -1,13 +0,0 @@
1
- module V8
2
- class Context
3
- def get(key)
4
- prototype[key]
5
- end
6
- alias_method :[], :get
7
-
8
- def set(key, value)
9
- prototype[key] = value
10
- end
11
- alias_method :[]=, :set
12
- end # Context
13
- end # V8
@@ -1,20 +0,0 @@
1
- require 'support/delegated'
2
-
3
- module V8
4
- class Date
5
- include Comparable
6
- include Delegated
7
-
8
- def to_time
9
- Time.at(to_i);
10
- end
11
-
12
- def <=>(other)
13
- to_time <=> other
14
- end
15
-
16
- def delegate
17
- to_time
18
- end
19
- end # Date
20
- end # V8
@@ -1,15 +0,0 @@
1
- module V8
2
- class Error
3
- def inspect
4
- "#{name}: #{message}"
5
- end
6
-
7
- def to_s
8
- message
9
- end
10
-
11
- def name
12
- self.class.name.delete("V8::")
13
- end
14
- end # Error
15
- end # V8
@@ -1,16 +0,0 @@
1
- require 'support/delegated'
2
-
3
- module V8
4
- class External
5
- include Comparable
6
- include Delegated
7
-
8
- def <=>(other)
9
- to_obj <=> other
10
- end
11
-
12
- def delegate
13
- to_obj
14
- end
15
- end # External
16
- end # V8
@@ -1,11 +0,0 @@
1
- module V8
2
- class Function
3
- def call(*args, &block)
4
- call_on(@receiver, *args, &block);
5
- end
6
-
7
- def to_proc
8
- origin.to_proc if origin
9
- end
10
- end # Function
11
- end # V8
@@ -1,16 +0,0 @@
1
- require 'support/delegated'
2
-
3
- module V8
4
- class Integer
5
- include Comparable
6
- include Delegated
7
-
8
- def <=>(other)
9
- to_i <=> other
10
- end
11
-
12
- def delegate
13
- to_i
14
- end
15
- end # Integer
16
- end # V8
@@ -1,16 +0,0 @@
1
- require 'support/delegated'
2
-
3
- module V8
4
- class Number
5
- include Comparable
6
- include Delegated
7
-
8
- def <=>(other)
9
- to_f <=> other
10
- end
11
-
12
- def delegate
13
- to_f
14
- end
15
- end # Number
16
- end # V8
@@ -1,66 +0,0 @@
1
- require 'support/delegated'
2
-
3
- module V8
4
- class Object
5
- class << self
6
- alias_method :native_new, :new
7
-
8
- def new(*args, &block)
9
- res = native_new(*args)
10
- res.send(:reflect_from, args.first)
11
- end
12
- end
13
-
14
- def respond_to?(meth)
15
- !self[meth].undefined? or super
16
- end
17
-
18
- def method_missing(meth, *args, &block)
19
- if respond_to?(meth)
20
- property = self[meth]
21
-
22
- if property.is_a?(V8::Function)
23
- return property.call_on(self, *args, &block)
24
- else
25
- return property
26
- end
27
- end
28
-
29
- super
30
- end
31
-
32
- include Comparable
33
- include Enumerable
34
- include Delegated
35
-
36
- def to_hash
37
- Hash[*keys.map {|key| [key.to_s, get(key)] }.flatten(1)]
38
- end
39
-
40
- def <=>(other)
41
- to_hash <=> other
42
- end
43
-
44
- def each(*args, &block)
45
- to_hash.each(*args, &block)
46
- end
47
-
48
- def delegate
49
- to_hash
50
- end
51
-
52
- private
53
-
54
- def reflect_from(obj)
55
- if !obj.nil? and !obj.v8? and !obj.is_a?(Hash)
56
- obj.class.declared_methods.each { |meth|
57
- if func_name = meth.to_sym.to_js_func_name
58
- func = set(func_name, obj.method(meth))
59
- func.bind(obj)
60
- end
61
- }
62
- end
63
- self
64
- end
65
- end # Object
66
- end # V8