opal 0.3.17 → 0.3.18
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/.gitignore +0 -1
- data/Gemfile +0 -5
- data/Rakefile +11 -8
- data/bin/opal +8 -36
- data/core/hash.rb +5 -5
- data/core/match_data.rb +1 -1
- data/core/module.rb +0 -2
- data/core/runtime.js +1 -1
- data/{spec → core/spec}/core/array/allocate_spec.rb +0 -0
- data/{spec → core/spec}/core/array/append_spec.rb +0 -0
- data/{spec → core/spec}/core/array/assoc_spec.rb +0 -0
- data/{spec → core/spec}/core/array/at_spec.rb +0 -0
- data/{spec → core/spec}/core/array/clear_spec.rb +0 -0
- data/{spec → core/spec}/core/array/clone_spec.rb +0 -0
- data/{spec → core/spec}/core/array/collect_spec.rb +0 -0
- data/{spec → core/spec}/core/array/compact_spec.rb +0 -0
- data/{spec → core/spec}/core/array/concat_spec.rb +0 -0
- data/{spec → core/spec}/core/array/constructor_spec.rb +0 -0
- data/{spec → core/spec}/core/array/count_spec.rb +0 -0
- data/{spec → core/spec}/core/array/delete_at_spec.rb +0 -0
- data/{spec → core/spec}/core/array/delete_if_spec.rb +0 -0
- data/{spec → core/spec}/core/array/delete_spec.rb +0 -0
- data/{spec → core/spec}/core/array/each_index_spec.rb +0 -0
- data/{spec → core/spec}/core/array/each_spec.rb +0 -0
- data/{spec → core/spec}/core/array/element_reference_spec.rb +0 -0
- data/{spec → core/spec}/core/array/empty_spec.rb +0 -0
- data/{spec → core/spec}/core/array/eql_spec.rb +0 -0
- data/{spec → core/spec}/core/array/fetch_spec.rb +0 -0
- data/{spec → core/spec}/core/array/first_spec.rb +0 -0
- data/{spec → core/spec}/core/array/flatten_spec.rb +0 -0
- data/{spec → core/spec}/core/array/include_spec.rb +0 -0
- data/{spec → core/spec}/core/array/insert_spec.rb +0 -0
- data/{spec → core/spec}/core/array/last_spec.rb +0 -0
- data/{spec → core/spec}/core/array/length_spec.rb +0 -0
- data/{spec → core/spec}/core/array/map_spec.rb +0 -0
- data/{spec → core/spec}/core/array/plus_spec.rb +0 -0
- data/{spec → core/spec}/core/array/pop_spec.rb +0 -0
- data/{spec → core/spec}/core/array/push_spec.rb +0 -0
- data/{spec → core/spec}/core/array/rassoc_spec.rb +0 -0
- data/{spec → core/spec}/core/array/reject_spec.rb +0 -0
- data/{spec → core/spec}/core/array/replace_spec.rb +0 -0
- data/{spec → core/spec}/core/array/reverse_each_spec.rb +0 -0
- data/{spec → core/spec}/core/array/reverse_spec.rb +0 -0
- data/{spec → core/spec}/core/array/size_spec.rb +0 -0
- data/{spec → core/spec}/core/array/to_ary_spec.rb +0 -0
- data/{spec → core/spec}/core/array/uniq_spec.rb +0 -0
- data/{spec → core/spec}/core/array/zip_spec.rb +0 -0
- data/{spec → core/spec}/core/class/new_spec.rb +0 -0
- data/{spec → core/spec}/core/enumerable/all_spec.rb +0 -0
- data/{spec → core/spec}/core/enumerable/any_spec.rb +0 -0
- data/{spec → core/spec}/core/enumerable/collect_spec.rb +0 -0
- data/{spec → core/spec}/core/enumerable/count_spec.rb +0 -0
- data/{spec → core/spec}/core/enumerable/fixtures/classes.rb +0 -0
- data/{spec → core/spec}/core/false/and_spec.rb +0 -0
- data/{spec → core/spec}/core/false/inspect_spec.rb +0 -0
- data/{spec → core/spec}/core/false/or_spec.rb +0 -0
- data/{spec → core/spec}/core/false/to_s_spec.rb +0 -0
- data/{spec → core/spec}/core/false/xor_spec.rb +0 -0
- data/{spec → core/spec}/core/hash/allocate_spec.rb +0 -0
- data/{spec → core/spec}/core/hash/assoc_spec.rb +0 -0
- data/{spec → core/spec}/core/hash/clear_spec.rb +0 -0
- data/{spec → core/spec}/core/hash/clone_spec.rb +0 -0
- data/{spec → core/spec}/core/hash/default_spec.rb +0 -0
- data/{spec → core/spec}/core/hash/delete_if_spec.rb +0 -0
- data/{spec → core/spec}/core/hash/element_reference_spec.rb +0 -0
- data/{spec → core/spec}/core/hash/element_set_spec.rb +0 -0
- data/{spec → core/spec}/core/hash/merge_spec.rb +4 -4
- data/{spec → core/spec}/core/hash/new_spec.rb +0 -0
- data/{spec → core/spec}/core/matchdata/to_a_spec.rb +0 -0
- data/{spec → core/spec}/core/nil/and_spec.rb +0 -0
- data/{spec → core/spec}/core/nil/inspect_spec.rb +0 -0
- data/{spec → core/spec}/core/nil/nil_spec.rb +0 -0
- data/{spec → core/spec}/core/nil/or_spec.rb +0 -0
- data/{spec → core/spec}/core/nil/to_a_spec.rb +0 -0
- data/{spec → core/spec}/core/nil/to_f_spec.rb +0 -0
- data/{spec → core/spec}/core/nil/to_i_spec.rb +0 -0
- data/{spec → core/spec}/core/nil/to_s_spec.rb +0 -0
- data/{spec → core/spec}/core/nil/xor_spec.rb +0 -0
- data/{spec → core/spec}/core/numeric/equal_value_spec.rb +0 -0
- data/{spec → core/spec}/core/regexp/match_spec.rb +0 -0
- data/{spec → core/spec}/core/symbol/to_proc_spec.rb +0 -0
- data/{spec → core/spec}/core/true/and_spec.rb +0 -0
- data/{spec → core/spec}/core/true/inspect_spec.rb +0 -0
- data/{spec → core/spec}/core/true/or_spec.rb +0 -0
- data/{spec → core/spec}/core/true/to_s_spec.rb +0 -0
- data/{spec → core/spec}/core/true/xor_spec.rb +0 -0
- data/core/spec/index.html +11 -0
- data/{spec → core/spec}/language/alias_spec.rb +0 -0
- data/{spec → core/spec}/language/and_spec.rb +0 -0
- data/{spec → core/spec}/language/array_spec.rb +0 -0
- data/{spec → core/spec}/language/block_spec.rb +0 -0
- data/{spec → core/spec}/language/break_spec.rb +0 -0
- data/{spec → core/spec}/language/case_spec.rb +0 -0
- data/{spec → core/spec}/language/defined_spec.rb +0 -0
- data/{spec → core/spec}/language/ensure_spec.rb +0 -0
- data/{spec → core/spec}/language/hash_spec.rb +0 -0
- data/{spec → core/spec}/language/if_spec.rb +0 -0
- data/{spec → core/spec}/language/loop_spec.rb +0 -0
- data/{spec → core/spec}/language/metaclass_spec.rb +0 -0
- data/{spec → core/spec}/language/next_spec.rb +0 -0
- data/{spec → core/spec}/language/or_spec.rb +0 -0
- data/{spec → core/spec}/language/predefined_spec.rb +0 -0
- data/{spec → core/spec}/language/regexp_spec.rb +0 -0
- data/{spec → core/spec}/language/send_spec.rb +0 -0
- data/{spec → core/spec}/language/singleton_class_spec.rb +0 -0
- data/{spec → core/spec}/language/super_spec.rb +0 -0
- data/{spec → core/spec}/language/symbol_spec.rb +0 -0
- data/{spec → core/spec}/language/undef_spec.rb +0 -0
- data/{spec → core/spec}/language/unless_spec.rb +0 -0
- data/{spec → core/spec}/language/until_spec.rb +0 -0
- data/{spec → core/spec}/language/variables_spec.rb +0 -0
- data/{spec → core/spec}/language/while_spec.rb +0 -0
- data/examples/dependencies/.gitignore +1 -0
- data/examples/dependencies/Gemfile +6 -0
- data/examples/dependencies/README.md +41 -0
- data/examples/dependencies/Rakefile +10 -0
- data/examples/dependencies/app.rb +16 -0
- data/{test/builder/fixtures/build_source/adam.rb → examples/dependencies/build/.gitkeep} +0 -0
- data/examples/dependencies/index.html +13 -0
- data/examples/hello_world/.gitignore +1 -0
- data/examples/hello_world/Gemfile +3 -0
- data/examples/hello_world/README.md +27 -0
- data/examples/hello_world/Rakefile +23 -0
- data/examples/hello_world/app.rb +7 -0
- data/examples/hello_world/index.html +12 -0
- data/lib/opal/builder_task.rb +10 -3
- data/lib/opal/parser.rb +3 -2
- data/lib/opal/version.rb +1 -1
- data/{test → spec}/builder/build_source_spec.rb +0 -0
- data/{test/builder/fixtures/build_source/bar/a.rb → spec/builder/fixtures/build_source/adam.rb} +0 -0
- data/{test/builder/fixtures/build_source/foo → spec/builder/fixtures/build_source/bar}/a.rb +0 -0
- data/{test → spec}/builder/fixtures/build_source/bar/wow/b.rb +0 -0
- data/{test → spec}/builder/fixtures/build_source/bar/wow/cow/c.rb +0 -0
- data/{test → spec}/builder/fixtures/build_source/beynon.rb +0 -0
- data/{test → spec}/builder/fixtures/build_source/charles.js +0 -0
- data/{test/builder/fixtures/build_source/foo/b.rb → spec/builder/fixtures/build_source/foo/a.rb} +0 -0
- data/{test/builder/fixtures/build_source/foo/x.js → spec/builder/fixtures/build_source/foo/b.rb} +0 -0
- data/{test/builder/fixtures/build_source/foo/y.js → spec/builder/fixtures/build_source/foo/x.js} +0 -0
- data/spec/builder/fixtures/build_source/foo/y.js +0 -0
- data/{test → spec}/grammar/alias_spec.rb +0 -0
- data/{test → spec}/grammar/and_spec.rb +0 -0
- data/{test → spec}/grammar/array_spec.rb +0 -0
- data/{test → spec}/grammar/attrasgn_spec.rb +0 -0
- data/{test → spec}/grammar/begin_spec.rb +0 -0
- data/{test → spec}/grammar/block_spec.rb +0 -0
- data/{test → spec}/grammar/break_spec.rb +0 -0
- data/{test → spec}/grammar/call_spec.rb +0 -0
- data/{test → spec}/grammar/class_spec.rb +0 -0
- data/{test → spec}/grammar/const_spec.rb +0 -0
- data/{test → spec}/grammar/cvar_spec.rb +0 -0
- data/{test → spec}/grammar/def_spec.rb +0 -0
- data/{test → spec}/grammar/false_spec.rb +0 -0
- data/{test → spec}/grammar/file_spec.rb +0 -0
- data/{test → spec}/grammar/gvar_spec.rb +0 -0
- data/{test → spec}/grammar/hash_spec.rb +0 -0
- data/{test → spec}/grammar/iasgn_spec.rb +0 -0
- data/{test → spec}/grammar/if_spec.rb +0 -0
- data/{test → spec}/grammar/iter_spec.rb +0 -0
- data/{test → spec}/grammar/ivar_spec.rb +0 -0
- data/{test → spec}/grammar/lasgn_spec.rb +0 -0
- data/{test → spec}/grammar/line_spec.rb +0 -0
- data/{test → spec}/grammar/lvar_spec.rb +0 -0
- data/{test → spec}/grammar/masgn_spec.rb +0 -0
- data/{test → spec}/grammar/module_spec.rb +0 -0
- data/{test → spec}/grammar/nil_spec.rb +0 -0
- data/{test → spec}/grammar/not_spec.rb +0 -0
- data/{test → spec}/grammar/op_asgn1_spec.rb +0 -0
- data/{test → spec}/grammar/op_asgn2_spec.rb +0 -0
- data/{test → spec}/grammar/or_spec.rb +0 -0
- data/{test → spec}/grammar/return_spec.rb +0 -0
- data/{test → spec}/grammar/sclass_spec.rb +0 -0
- data/{test → spec}/grammar/self_spec.rb +0 -0
- data/{test → spec}/grammar/str_spec.rb +0 -0
- data/{test → spec}/grammar/super_spec.rb +0 -0
- data/{test → spec}/grammar/true_spec.rb +0 -0
- data/{test → spec}/grammar/undef_spec.rb +0 -0
- data/{test → spec}/grammar/unless_spec.rb +0 -0
- data/{test → spec}/grammar/while_spec.rb +0 -0
- data/{test → spec}/grammar/xstr_spec.rb +0 -0
- data/{test → spec}/grammar/yield_spec.rb +0 -0
- data/{test → spec}/spec_helper.rb +0 -0
- metadata +228 -320
- data/CHANGELOG.md +0 -12
- data/spec/index.html +0 -11
data/.gitignore
CHANGED
data/Gemfile
CHANGED
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
|
|
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 :
|
|
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
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
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
|
-
|
|
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
|
|
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(
|
|
190
|
-
return
|
|
189
|
+
if ((value = block.call(__context, bucket[0], bucket[1])) === __breaker) {
|
|
190
|
+
return __breaker.$v;
|
|
191
191
|
}
|
|
192
192
|
|
|
193
|
-
if (value !== false && value !==
|
|
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 ===
|
|
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(
|
|
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
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
|
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
|
|
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
|
|
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
|