opal 0.3.17 → 0.3.18

Sign up to get free protection for your applications and to get access to all the features.
Files changed (184) hide show
  1. data/.gitignore +0 -1
  2. data/Gemfile +0 -5
  3. data/Rakefile +11 -8
  4. data/bin/opal +8 -36
  5. data/core/hash.rb +5 -5
  6. data/core/match_data.rb +1 -1
  7. data/core/module.rb +0 -2
  8. data/core/runtime.js +1 -1
  9. data/{spec → core/spec}/core/array/allocate_spec.rb +0 -0
  10. data/{spec → core/spec}/core/array/append_spec.rb +0 -0
  11. data/{spec → core/spec}/core/array/assoc_spec.rb +0 -0
  12. data/{spec → core/spec}/core/array/at_spec.rb +0 -0
  13. data/{spec → core/spec}/core/array/clear_spec.rb +0 -0
  14. data/{spec → core/spec}/core/array/clone_spec.rb +0 -0
  15. data/{spec → core/spec}/core/array/collect_spec.rb +0 -0
  16. data/{spec → core/spec}/core/array/compact_spec.rb +0 -0
  17. data/{spec → core/spec}/core/array/concat_spec.rb +0 -0
  18. data/{spec → core/spec}/core/array/constructor_spec.rb +0 -0
  19. data/{spec → core/spec}/core/array/count_spec.rb +0 -0
  20. data/{spec → core/spec}/core/array/delete_at_spec.rb +0 -0
  21. data/{spec → core/spec}/core/array/delete_if_spec.rb +0 -0
  22. data/{spec → core/spec}/core/array/delete_spec.rb +0 -0
  23. data/{spec → core/spec}/core/array/each_index_spec.rb +0 -0
  24. data/{spec → core/spec}/core/array/each_spec.rb +0 -0
  25. data/{spec → core/spec}/core/array/element_reference_spec.rb +0 -0
  26. data/{spec → core/spec}/core/array/empty_spec.rb +0 -0
  27. data/{spec → core/spec}/core/array/eql_spec.rb +0 -0
  28. data/{spec → core/spec}/core/array/fetch_spec.rb +0 -0
  29. data/{spec → core/spec}/core/array/first_spec.rb +0 -0
  30. data/{spec → core/spec}/core/array/flatten_spec.rb +0 -0
  31. data/{spec → core/spec}/core/array/include_spec.rb +0 -0
  32. data/{spec → core/spec}/core/array/insert_spec.rb +0 -0
  33. data/{spec → core/spec}/core/array/last_spec.rb +0 -0
  34. data/{spec → core/spec}/core/array/length_spec.rb +0 -0
  35. data/{spec → core/spec}/core/array/map_spec.rb +0 -0
  36. data/{spec → core/spec}/core/array/plus_spec.rb +0 -0
  37. data/{spec → core/spec}/core/array/pop_spec.rb +0 -0
  38. data/{spec → core/spec}/core/array/push_spec.rb +0 -0
  39. data/{spec → core/spec}/core/array/rassoc_spec.rb +0 -0
  40. data/{spec → core/spec}/core/array/reject_spec.rb +0 -0
  41. data/{spec → core/spec}/core/array/replace_spec.rb +0 -0
  42. data/{spec → core/spec}/core/array/reverse_each_spec.rb +0 -0
  43. data/{spec → core/spec}/core/array/reverse_spec.rb +0 -0
  44. data/{spec → core/spec}/core/array/size_spec.rb +0 -0
  45. data/{spec → core/spec}/core/array/to_ary_spec.rb +0 -0
  46. data/{spec → core/spec}/core/array/uniq_spec.rb +0 -0
  47. data/{spec → core/spec}/core/array/zip_spec.rb +0 -0
  48. data/{spec → core/spec}/core/class/new_spec.rb +0 -0
  49. data/{spec → core/spec}/core/enumerable/all_spec.rb +0 -0
  50. data/{spec → core/spec}/core/enumerable/any_spec.rb +0 -0
  51. data/{spec → core/spec}/core/enumerable/collect_spec.rb +0 -0
  52. data/{spec → core/spec}/core/enumerable/count_spec.rb +0 -0
  53. data/{spec → core/spec}/core/enumerable/fixtures/classes.rb +0 -0
  54. data/{spec → core/spec}/core/false/and_spec.rb +0 -0
  55. data/{spec → core/spec}/core/false/inspect_spec.rb +0 -0
  56. data/{spec → core/spec}/core/false/or_spec.rb +0 -0
  57. data/{spec → core/spec}/core/false/to_s_spec.rb +0 -0
  58. data/{spec → core/spec}/core/false/xor_spec.rb +0 -0
  59. data/{spec → core/spec}/core/hash/allocate_spec.rb +0 -0
  60. data/{spec → core/spec}/core/hash/assoc_spec.rb +0 -0
  61. data/{spec → core/spec}/core/hash/clear_spec.rb +0 -0
  62. data/{spec → core/spec}/core/hash/clone_spec.rb +0 -0
  63. data/{spec → core/spec}/core/hash/default_spec.rb +0 -0
  64. data/{spec → core/spec}/core/hash/delete_if_spec.rb +0 -0
  65. data/{spec → core/spec}/core/hash/element_reference_spec.rb +0 -0
  66. data/{spec → core/spec}/core/hash/element_set_spec.rb +0 -0
  67. data/{spec → core/spec}/core/hash/merge_spec.rb +4 -4
  68. data/{spec → core/spec}/core/hash/new_spec.rb +0 -0
  69. data/{spec → core/spec}/core/matchdata/to_a_spec.rb +0 -0
  70. data/{spec → core/spec}/core/nil/and_spec.rb +0 -0
  71. data/{spec → core/spec}/core/nil/inspect_spec.rb +0 -0
  72. data/{spec → core/spec}/core/nil/nil_spec.rb +0 -0
  73. data/{spec → core/spec}/core/nil/or_spec.rb +0 -0
  74. data/{spec → core/spec}/core/nil/to_a_spec.rb +0 -0
  75. data/{spec → core/spec}/core/nil/to_f_spec.rb +0 -0
  76. data/{spec → core/spec}/core/nil/to_i_spec.rb +0 -0
  77. data/{spec → core/spec}/core/nil/to_s_spec.rb +0 -0
  78. data/{spec → core/spec}/core/nil/xor_spec.rb +0 -0
  79. data/{spec → core/spec}/core/numeric/equal_value_spec.rb +0 -0
  80. data/{spec → core/spec}/core/regexp/match_spec.rb +0 -0
  81. data/{spec → core/spec}/core/symbol/to_proc_spec.rb +0 -0
  82. data/{spec → core/spec}/core/true/and_spec.rb +0 -0
  83. data/{spec → core/spec}/core/true/inspect_spec.rb +0 -0
  84. data/{spec → core/spec}/core/true/or_spec.rb +0 -0
  85. data/{spec → core/spec}/core/true/to_s_spec.rb +0 -0
  86. data/{spec → core/spec}/core/true/xor_spec.rb +0 -0
  87. data/core/spec/index.html +11 -0
  88. data/{spec → core/spec}/language/alias_spec.rb +0 -0
  89. data/{spec → core/spec}/language/and_spec.rb +0 -0
  90. data/{spec → core/spec}/language/array_spec.rb +0 -0
  91. data/{spec → core/spec}/language/block_spec.rb +0 -0
  92. data/{spec → core/spec}/language/break_spec.rb +0 -0
  93. data/{spec → core/spec}/language/case_spec.rb +0 -0
  94. data/{spec → core/spec}/language/defined_spec.rb +0 -0
  95. data/{spec → core/spec}/language/ensure_spec.rb +0 -0
  96. data/{spec → core/spec}/language/hash_spec.rb +0 -0
  97. data/{spec → core/spec}/language/if_spec.rb +0 -0
  98. data/{spec → core/spec}/language/loop_spec.rb +0 -0
  99. data/{spec → core/spec}/language/metaclass_spec.rb +0 -0
  100. data/{spec → core/spec}/language/next_spec.rb +0 -0
  101. data/{spec → core/spec}/language/or_spec.rb +0 -0
  102. data/{spec → core/spec}/language/predefined_spec.rb +0 -0
  103. data/{spec → core/spec}/language/regexp_spec.rb +0 -0
  104. data/{spec → core/spec}/language/send_spec.rb +0 -0
  105. data/{spec → core/spec}/language/singleton_class_spec.rb +0 -0
  106. data/{spec → core/spec}/language/super_spec.rb +0 -0
  107. data/{spec → core/spec}/language/symbol_spec.rb +0 -0
  108. data/{spec → core/spec}/language/undef_spec.rb +0 -0
  109. data/{spec → core/spec}/language/unless_spec.rb +0 -0
  110. data/{spec → core/spec}/language/until_spec.rb +0 -0
  111. data/{spec → core/spec}/language/variables_spec.rb +0 -0
  112. data/{spec → core/spec}/language/while_spec.rb +0 -0
  113. data/examples/dependencies/.gitignore +1 -0
  114. data/examples/dependencies/Gemfile +6 -0
  115. data/examples/dependencies/README.md +41 -0
  116. data/examples/dependencies/Rakefile +10 -0
  117. data/examples/dependencies/app.rb +16 -0
  118. data/{test/builder/fixtures/build_source/adam.rb → examples/dependencies/build/.gitkeep} +0 -0
  119. data/examples/dependencies/index.html +13 -0
  120. data/examples/hello_world/.gitignore +1 -0
  121. data/examples/hello_world/Gemfile +3 -0
  122. data/examples/hello_world/README.md +27 -0
  123. data/examples/hello_world/Rakefile +23 -0
  124. data/examples/hello_world/app.rb +7 -0
  125. data/examples/hello_world/index.html +12 -0
  126. data/lib/opal/builder_task.rb +10 -3
  127. data/lib/opal/parser.rb +3 -2
  128. data/lib/opal/version.rb +1 -1
  129. data/{test → spec}/builder/build_source_spec.rb +0 -0
  130. data/{test/builder/fixtures/build_source/bar/a.rb → spec/builder/fixtures/build_source/adam.rb} +0 -0
  131. data/{test/builder/fixtures/build_source/foo → spec/builder/fixtures/build_source/bar}/a.rb +0 -0
  132. data/{test → spec}/builder/fixtures/build_source/bar/wow/b.rb +0 -0
  133. data/{test → spec}/builder/fixtures/build_source/bar/wow/cow/c.rb +0 -0
  134. data/{test → spec}/builder/fixtures/build_source/beynon.rb +0 -0
  135. data/{test → spec}/builder/fixtures/build_source/charles.js +0 -0
  136. data/{test/builder/fixtures/build_source/foo/b.rb → spec/builder/fixtures/build_source/foo/a.rb} +0 -0
  137. data/{test/builder/fixtures/build_source/foo/x.js → spec/builder/fixtures/build_source/foo/b.rb} +0 -0
  138. data/{test/builder/fixtures/build_source/foo/y.js → spec/builder/fixtures/build_source/foo/x.js} +0 -0
  139. data/spec/builder/fixtures/build_source/foo/y.js +0 -0
  140. data/{test → spec}/grammar/alias_spec.rb +0 -0
  141. data/{test → spec}/grammar/and_spec.rb +0 -0
  142. data/{test → spec}/grammar/array_spec.rb +0 -0
  143. data/{test → spec}/grammar/attrasgn_spec.rb +0 -0
  144. data/{test → spec}/grammar/begin_spec.rb +0 -0
  145. data/{test → spec}/grammar/block_spec.rb +0 -0
  146. data/{test → spec}/grammar/break_spec.rb +0 -0
  147. data/{test → spec}/grammar/call_spec.rb +0 -0
  148. data/{test → spec}/grammar/class_spec.rb +0 -0
  149. data/{test → spec}/grammar/const_spec.rb +0 -0
  150. data/{test → spec}/grammar/cvar_spec.rb +0 -0
  151. data/{test → spec}/grammar/def_spec.rb +0 -0
  152. data/{test → spec}/grammar/false_spec.rb +0 -0
  153. data/{test → spec}/grammar/file_spec.rb +0 -0
  154. data/{test → spec}/grammar/gvar_spec.rb +0 -0
  155. data/{test → spec}/grammar/hash_spec.rb +0 -0
  156. data/{test → spec}/grammar/iasgn_spec.rb +0 -0
  157. data/{test → spec}/grammar/if_spec.rb +0 -0
  158. data/{test → spec}/grammar/iter_spec.rb +0 -0
  159. data/{test → spec}/grammar/ivar_spec.rb +0 -0
  160. data/{test → spec}/grammar/lasgn_spec.rb +0 -0
  161. data/{test → spec}/grammar/line_spec.rb +0 -0
  162. data/{test → spec}/grammar/lvar_spec.rb +0 -0
  163. data/{test → spec}/grammar/masgn_spec.rb +0 -0
  164. data/{test → spec}/grammar/module_spec.rb +0 -0
  165. data/{test → spec}/grammar/nil_spec.rb +0 -0
  166. data/{test → spec}/grammar/not_spec.rb +0 -0
  167. data/{test → spec}/grammar/op_asgn1_spec.rb +0 -0
  168. data/{test → spec}/grammar/op_asgn2_spec.rb +0 -0
  169. data/{test → spec}/grammar/or_spec.rb +0 -0
  170. data/{test → spec}/grammar/return_spec.rb +0 -0
  171. data/{test → spec}/grammar/sclass_spec.rb +0 -0
  172. data/{test → spec}/grammar/self_spec.rb +0 -0
  173. data/{test → spec}/grammar/str_spec.rb +0 -0
  174. data/{test → spec}/grammar/super_spec.rb +0 -0
  175. data/{test → spec}/grammar/true_spec.rb +0 -0
  176. data/{test → spec}/grammar/undef_spec.rb +0 -0
  177. data/{test → spec}/grammar/unless_spec.rb +0 -0
  178. data/{test → spec}/grammar/while_spec.rb +0 -0
  179. data/{test → spec}/grammar/xstr_spec.rb +0 -0
  180. data/{test → spec}/grammar/yield_spec.rb +0 -0
  181. data/{test → spec}/spec_helper.rb +0 -0
  182. metadata +228 -320
  183. data/CHANGELOG.md +0 -12
  184. data/spec/index.html +0 -11
data/.gitignore CHANGED
@@ -9,7 +9,6 @@ Gemfile.lock
9
9
  pkg/*
10
10
  /runtime/*.js
11
11
  /*.js
12
- /docs
13
12
  /gh-pages
14
13
  /examples/**/*.js
15
14
  /build
data/Gemfile CHANGED
@@ -9,9 +9,4 @@ group :browser do
9
9
  gem "opal-racc"
10
10
  gem "opal-spec"
11
11
  gem "opal-strscan"
12
- end
13
-
14
- group :documentation do
15
- gem "redcarpet"
16
- gem "albino"
17
12
  end
data/Rakefile CHANGED
@@ -13,8 +13,9 @@ task :opal do
13
13
  end
14
14
 
15
15
  Opal::BuilderTask.new do |t|
16
- t.name = 'opal'
17
- t.files = []
16
+ t.name = 'opal'
17
+ t.files = []
18
+ t.specs_dir = './core/spec'
18
19
  t.dependencies = %w[opal-spec opal-racc opal-strscan]
19
20
  end
20
21
 
@@ -78,7 +79,7 @@ namespace :docs do
78
79
  end
79
80
  end
80
81
 
81
- task :index do
82
+ task :build do
82
83
  require 'redcarpet'
83
84
  require 'albino'
84
85
 
@@ -89,12 +90,14 @@ namespace :docs do
89
90
  end
90
91
 
91
92
  markdown = Redcarpet::Markdown.new(klass, :fenced_code_blocks => true)
93
+ sources = %w[index]
92
94
 
93
- File.open('gh-pages/index.html', 'w+') do |o|
94
- o.write File.read('docs/pre.html')
95
- o.write markdown.render(File.read 'docs/index.md')
96
- o.write markdown.render(File.read 'CHANGELOG.md')
97
- o.write File.read('docs/post.html')
95
+ sources.each do |s|
96
+ File.open(File.join('gh-pages', "#{s}.html"), 'w+') do |o|
97
+ o.write File.read('docs/pre.html')
98
+ o.write markdown.render(File.read "docs/#{s}.md")
99
+ o.write File.read('docs/post.html')
100
+ end
98
101
  end
99
102
  end
100
103
 
data/bin/opal CHANGED
@@ -1,43 +1,15 @@
1
1
  #! /usr/bin/env ruby
2
2
 
3
- require 'optparse'
4
3
  require 'opal'
5
4
 
6
- options = {}
7
-
8
- OptionParser.new do |opts|
9
- opts.on('-c', '--compile', 'Compile ruby') do
10
- options[:compile] = true
11
- end
12
-
13
- opts.on('-o', '--out FILE', 'Output file') do |o|
14
- options[:out] = o
15
- end
16
-
17
- opts.on('-p', '--print', 'Print result') do
18
- options[:print] = true
19
- end
20
-
21
- opts.on_tail("-v", "--version", "Show version") do
22
- puts Opal::VERSION
23
- exit
24
- end
25
- end.parse! rescue abort("See `opal --help' for usage information.")
26
-
27
- if options[:compile]
28
- puts "No sources given" if ARGV.empty?
29
-
30
- ARGV.each do |s|
31
- puts "need to compile #{s}"
32
- end
33
-
34
- elsif options[:print]
35
- puts "No sources given" if ARGV.empty?
36
-
37
- ARGV.each do |s|
38
- puts Opal.parse s
39
- end
5
+ first = ARGV.first
40
6
 
7
+ if first.nil?
8
+ puts "Usage: opal path/to/file.rb"
9
+ elsif first == '-v' or first == '--version'
10
+ puts Opal::VERSION
11
+ elsif File.exist? first
12
+ puts Opal.parse File.read(first)
41
13
  else
42
- puts "No sources given"
14
+ puts Opal.parse(first)
43
15
  end
data/core/hash.rb CHANGED
@@ -186,11 +186,11 @@ class Hash
186
186
  var bucket = map[assoc],
187
187
  value;
188
188
 
189
- if ((value = block.call($context, null, bucket[0], bucket[1])) === $breaker) {
190
- return $breaker.$v;
189
+ if ((value = block.call(__context, bucket[0], bucket[1])) === __breaker) {
190
+ return __breaker.$v;
191
191
  }
192
192
 
193
- if (value !== false && value !== null) {
193
+ if (value !== false && value !== nil) {
194
194
  delete map[assoc];
195
195
  }
196
196
  }
@@ -452,7 +452,7 @@ class Hash
452
452
  var map = this.map,
453
453
  map2 = other.map;
454
454
 
455
- if (block === null) {
455
+ if (block == null || block === nil) {
456
456
  for (var assoc in map2) {
457
457
  var bucket = map2[assoc];
458
458
 
@@ -464,7 +464,7 @@ class Hash
464
464
  var bucket = map2[assoc], key = bucket[0], val = bucket[1];
465
465
 
466
466
  if (map.hasOwnProperty(assoc)) {
467
- val = block.call($context, null, key, map[assoc][1], val);
467
+ val = block.call(__context, key, map[assoc][1], val);
468
468
  }
469
469
 
470
470
  map[assoc] = [key, val];
data/core/match_data.rb CHANGED
@@ -26,7 +26,7 @@ class MatchData
26
26
  alias size length
27
27
 
28
28
  def to_a
29
- `$slice.call(this.$data)`
29
+ `__slice.call(this.$data)`
30
30
  end
31
31
 
32
32
  def to_s
data/core/module.rb CHANGED
@@ -181,11 +181,9 @@ class Module
181
181
 
182
182
  def include(*mods)
183
183
  %x{
184
- console.log("including " + this._name);
185
184
  var i = mods.length - 1, mod;
186
185
  while (i >= 0) {
187
186
  #{mod = `mods[i]`};
188
- console.log("include: " + mod._name);
189
187
 
190
188
  define_iclass(this, mod);
191
189
 
data/core/runtime.js CHANGED
@@ -165,7 +165,7 @@ Opal.undef = function(klass) {
165
165
  for (var i = 0, length = args.length; i < length; i++) {
166
166
  var mid = args[i], id = mid_to_jsid[mid];
167
167
 
168
- delete klass.$m_tbl[id];
168
+ delete klass._proto[id];
169
169
  }
170
170
  };
171
171
 
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -18,20 +18,20 @@ describe "Hash#merge" do
18
18
  end
19
19
  end
20
20
 
21
- describe "Hash#merge" do
21
+ describe "Hash#merge!" do
22
22
  it "adds the entries from other, overwriting duplicate keys. Returns self" do
23
23
  h = {:_1 => 'a', :_2 => '3'}
24
- h.merge(:_1 => '9', :_9 => 2).should equal(h)
24
+ h.merge!(:_1 => '9', :_9 => 2).should equal(h)
25
25
  h.should == {:_1 => "9", :_2 => "3", :_9 => 2}
26
26
  end
27
27
 
28
28
  it "sets any duplicate key to the value of block if passed a block" do
29
29
  h1 = {:a => 2, :b => -1}
30
30
  h2 = {:a => -2, :c => 1}
31
- h1.merge(h2) { |k,x,y| 3.14 }.should equal(h1)
31
+ h1.merge!(h2) { |k,x,y| 3.14 }.should equal(h1)
32
32
  h1.should == {:c => 1, :b => -1, :a => 3.14}
33
33
 
34
- h1.merge(h1) { nil }
34
+ h1.merge!(h1) { nil }
35
35
  h1.should == {:a => nil, :b => nil, :c => nil}
36
36
  end
37
37
  end
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,11 @@
1
+ <!doctype html>
2
+ <html>
3
+ <head>
4
+ <title></title>
5
+ </head>
6
+ <body>
7
+ <script type="text/javascript" src="../../build/opal.js"></script>
8
+ <script type="text/javascript" src="../../build/opal-spec.js"></script>
9
+ <script type="text/javascript" src="../../build/opal.specs.js"></script>
10
+ </body>
11
+ </html>
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes