opal 0.3.16 → 0.3.17
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/CHANGELOG.md +12 -0
- data/Gemfile +8 -7
- data/README.md +21 -13
- data/Rakefile +64 -78
- data/bin/opal +18 -29
- data/core/alpha.rb +2 -9
- data/core/array.rb +106 -50
- data/core/basic_object.rb +10 -8
- data/core/boolean.rb +2 -0
- data/core/class.rb +25 -13
- data/core/comparable.rb +6 -6
- data/core/enumerable.rb +90 -94
- data/core/enumerator.rb +3 -3
- data/core/hash.rb +86 -46
- data/core/kernel.rb +55 -39
- data/core/load_order +2 -5
- data/core/match_data.rb +1 -1
- data/core/module.rb +45 -20
- data/core/nil_class.rb +6 -2
- data/core/numeric.rb +20 -10
- data/core/proc.rb +2 -2
- data/core/range.rb +72 -13
- data/core/regexp.rb +5 -3
- data/core/runtime.js +228 -287
- data/core/string.rb +345 -37
- data/core/top_self.rb +1 -1
- data/lib/opal.rb +13 -91
- data/lib/opal/builder.rb +47 -120
- data/lib/opal/builder_task.rb +74 -0
- data/lib/opal/{parser/grammar.rb → grammar.rb} +1094 -1083
- data/lib/opal/{parser/grammar.y → grammar.y} +7 -0
- data/lib/opal/{parser/lexer.rb → lexer.rb} +32 -11
- data/lib/opal/{parser/parser.rb → parser.rb} +232 -238
- data/lib/opal/{parser/scope.rb → scope.rb} +72 -9
- data/lib/opal/version.rb +2 -3
- data/opal.gemspec +1 -2
- data/{core_spec → spec}/core/array/allocate_spec.rb +1 -3
- data/{core_spec → spec}/core/array/append_spec.rb +1 -4
- data/{core_spec → spec}/core/array/assoc_spec.rb +1 -4
- data/{core_spec → spec}/core/array/at_spec.rb +1 -3
- data/{core_spec → spec}/core/array/clear_spec.rb +1 -3
- data/spec/core/array/clone_spec.rb +15 -0
- data/{core_spec/core/array/shared/collect.rb → spec/core/array/collect_spec.rb} +1 -1
- data/{core_spec → spec}/core/array/compact_spec.rb +1 -3
- data/{core_spec → spec}/core/array/concat_spec.rb +1 -3
- data/{core_spec → spec}/core/array/constructor_spec.rb +9 -3
- data/{core_spec → spec}/core/array/count_spec.rb +1 -3
- data/{core_spec → spec}/core/array/delete_at_spec.rb +1 -4
- data/{core_spec → spec}/core/array/delete_if_spec.rb +1 -4
- data/{core_spec → spec}/core/array/delete_spec.rb +1 -4
- data/{core_spec → spec}/core/array/each_index_spec.rb +1 -4
- data/{core_spec → spec}/core/array/each_spec.rb +1 -4
- data/{core_spec → spec}/core/array/element_reference_spec.rb +74 -4
- data/{core_spec → spec}/core/array/empty_spec.rb +1 -4
- data/{core_spec/core/array/shared/eql.rb → spec/core/array/eql_spec.rb} +1 -1
- data/{core_spec → spec}/core/array/fetch_spec.rb +1 -4
- data/{core_spec → spec}/core/array/first_spec.rb +1 -3
- data/{core_spec → spec}/core/array/flatten_spec.rb +1 -3
- data/{core_spec → spec}/core/array/include_spec.rb +1 -3
- data/{core_spec → spec}/core/array/insert_spec.rb +1 -4
- data/{core_spec → spec}/core/array/last_spec.rb +1 -4
- data/{core_spec/core/array/shared/length.rb → spec/core/array/length_spec.rb} +1 -1
- data/spec/core/array/map_spec.rb +53 -0
- data/{core_spec → spec}/core/array/plus_spec.rb +1 -4
- data/{core_spec → spec}/core/array/pop_spec.rb +1 -4
- data/{core_spec → spec}/core/array/push_spec.rb +1 -4
- data/{core_spec → spec}/core/array/rassoc_spec.rb +1 -4
- data/{core_spec → spec}/core/array/reject_spec.rb +1 -4
- data/{core_spec/core/array/shared/replace.rb → spec/core/array/replace_spec.rb} +1 -1
- data/{core_spec → spec}/core/array/reverse_each_spec.rb +1 -4
- data/{core_spec → spec}/core/array/reverse_spec.rb +1 -4
- data/spec/core/array/size_spec.rb +6 -0
- data/spec/core/array/to_ary_spec.rb +6 -0
- data/spec/core/array/uniq_spec.rb +22 -0
- data/spec/core/array/zip_spec.rb +20 -0
- data/{core_spec → spec}/core/class/new_spec.rb +1 -4
- data/{core_spec → spec}/core/enumerable/all_spec.rb +1 -4
- data/{core_spec → spec}/core/enumerable/any_spec.rb +1 -4
- data/{core_spec/core/enumerable/shared/collect.rb → spec/core/enumerable/collect_spec.rb} +1 -1
- data/{core_spec → spec}/core/enumerable/count_spec.rb +2 -5
- data/{core_spec → spec}/core/enumerable/fixtures/classes.rb +1 -2
- data/{core_spec → spec}/core/false/and_spec.rb +1 -3
- data/{core_spec → spec}/core/false/inspect_spec.rb +1 -3
- data/{core_spec → spec}/core/false/or_spec.rb +1 -3
- data/{core_spec → spec}/core/false/to_s_spec.rb +1 -3
- data/{core_spec → spec}/core/false/xor_spec.rb +1 -3
- data/{core_spec → spec}/core/hash/allocate_spec.rb +1 -3
- data/spec/core/hash/assoc_spec.rb +25 -0
- data/{core_spec → spec}/core/hash/clear_spec.rb +1 -3
- data/{core_spec → spec}/core/hash/clone_spec.rb +1 -3
- data/{core_spec → spec}/core/hash/default_spec.rb +1 -3
- data/{core_spec → spec}/core/hash/delete_if_spec.rb +1 -3
- data/{core_spec → spec}/core/hash/element_reference_spec.rb +1 -3
- data/{core_spec → spec}/core/hash/element_set_spec.rb +1 -3
- data/spec/core/hash/merge_spec.rb +37 -0
- data/{core_spec → spec}/core/hash/new_spec.rb +1 -3
- data/{core_spec → spec}/core/matchdata/to_a_spec.rb +1 -3
- data/{core_spec → spec}/core/nil/and_spec.rb +1 -4
- data/{core_spec → spec}/core/nil/inspect_spec.rb +1 -4
- data/{core_spec → spec}/core/nil/nil_spec.rb +1 -4
- data/{core_spec → spec}/core/nil/or_spec.rb +1 -4
- data/{core_spec → spec}/core/nil/to_a_spec.rb +1 -4
- data/{core_spec → spec}/core/nil/to_f_spec.rb +1 -4
- data/{core_spec → spec}/core/nil/to_i_spec.rb +1 -4
- data/{core_spec → spec}/core/nil/to_s_spec.rb +1 -4
- data/{core_spec → spec}/core/nil/xor_spec.rb +1 -4
- data/{core_spec → spec}/core/numeric/equal_value_spec.rb +1 -3
- data/{core_spec → spec}/core/regexp/match_spec.rb +10 -3
- data/{core_spec → spec}/core/symbol/to_proc_spec.rb +1 -3
- data/{core_spec → spec}/core/true/and_spec.rb +1 -3
- data/{core_spec → spec}/core/true/inspect_spec.rb +1 -3
- data/{core_spec → spec}/core/true/or_spec.rb +1 -3
- data/{core_spec → spec}/core/true/to_s_spec.rb +1 -3
- data/{core_spec → spec}/core/true/xor_spec.rb +1 -3
- data/spec/index.html +11 -0
- data/{core_spec → spec}/language/alias_spec.rb +1 -3
- data/{core_spec → spec}/language/and_spec.rb +1 -4
- data/{core_spec → spec}/language/array_spec.rb +1 -4
- data/{core_spec → spec}/language/block_spec.rb +20 -3
- data/{core_spec → spec}/language/break_spec.rb +40 -3
- data/{core_spec → spec}/language/case_spec.rb +1 -4
- data/{core_spec → spec}/language/defined_spec.rb +9 -3
- data/{core_spec → spec}/language/ensure_spec.rb +38 -3
- data/{core_spec → spec}/language/hash_spec.rb +1 -3
- data/{core_spec → spec}/language/if_spec.rb +1 -4
- data/{core_spec → spec}/language/loop_spec.rb +1 -3
- data/spec/language/metaclass_spec.rb +13 -0
- data/{core_spec → spec}/language/next_spec.rb +47 -3
- data/{core_spec → spec}/language/or_spec.rb +1 -4
- data/{core_spec → spec}/language/predefined_spec.rb +1 -3
- data/{core_spec/language/regexp/interpolation_spec.rb → spec/language/regexp_spec.rb} +6 -3
- data/{core_spec → spec}/language/send_spec.rb +38 -4
- data/spec/language/singleton_class_spec.rb +31 -0
- data/spec/language/super_spec.rb +188 -0
- data/{core_spec → spec}/language/symbol_spec.rb +1 -3
- data/{core_spec → spec}/language/undef_spec.rb +1 -3
- data/{core_spec → spec}/language/unless_spec.rb +1 -4
- data/{core_spec → spec}/language/until_spec.rb +1 -3
- data/{core_spec → spec}/language/variables_spec.rb +1 -3
- data/{core_spec → spec}/language/while_spec.rb +1 -3
- data/{spec → test}/builder/build_source_spec.rb +0 -0
- data/{spec → test}/builder/fixtures/build_source/adam.rb +0 -0
- data/{spec → test}/builder/fixtures/build_source/bar/a.rb +0 -0
- data/{spec → test}/builder/fixtures/build_source/bar/wow/b.rb +0 -0
- data/{spec → test}/builder/fixtures/build_source/bar/wow/cow/c.rb +0 -0
- data/{spec → test}/builder/fixtures/build_source/beynon.rb +0 -0
- data/{spec → test}/builder/fixtures/build_source/charles.js +0 -0
- data/{spec → test}/builder/fixtures/build_source/foo/a.rb +0 -0
- data/{spec → test}/builder/fixtures/build_source/foo/b.rb +0 -0
- data/{spec → test}/builder/fixtures/build_source/foo/x.js +0 -0
- data/{spec → test}/builder/fixtures/build_source/foo/y.js +0 -0
- data/{spec → test}/grammar/alias_spec.rb +0 -0
- data/{spec → test}/grammar/and_spec.rb +0 -0
- data/{spec → test}/grammar/array_spec.rb +0 -0
- data/{spec → test}/grammar/attrasgn_spec.rb +0 -0
- data/{spec → test}/grammar/begin_spec.rb +0 -0
- data/{spec → test}/grammar/block_spec.rb +0 -0
- data/{spec → test}/grammar/break_spec.rb +0 -0
- data/{spec → test}/grammar/call_spec.rb +0 -0
- data/{spec → test}/grammar/class_spec.rb +0 -0
- data/{spec → test}/grammar/const_spec.rb +0 -0
- data/{spec → test}/grammar/cvar_spec.rb +0 -0
- data/{spec → test}/grammar/def_spec.rb +0 -0
- data/{spec → test}/grammar/false_spec.rb +0 -0
- data/{spec → test}/grammar/file_spec.rb +0 -0
- data/{spec → test}/grammar/gvar_spec.rb +0 -0
- data/{spec → test}/grammar/hash_spec.rb +0 -0
- data/{spec → test}/grammar/iasgn_spec.rb +0 -0
- data/{spec → test}/grammar/if_spec.rb +0 -0
- data/{spec → test}/grammar/iter_spec.rb +0 -0
- data/{spec → test}/grammar/ivar_spec.rb +0 -0
- data/{spec → test}/grammar/lasgn_spec.rb +0 -0
- data/{spec → test}/grammar/line_spec.rb +0 -0
- data/{spec → test}/grammar/lvar_spec.rb +0 -0
- data/{spec → test}/grammar/masgn_spec.rb +0 -0
- data/{spec → test}/grammar/module_spec.rb +0 -0
- data/{spec → test}/grammar/nil_spec.rb +0 -0
- data/{spec → test}/grammar/not_spec.rb +0 -0
- data/{spec → test}/grammar/op_asgn1_spec.rb +0 -0
- data/{spec → test}/grammar/op_asgn2_spec.rb +0 -0
- data/{spec → test}/grammar/or_spec.rb +0 -0
- data/{spec → test}/grammar/return_spec.rb +0 -0
- data/{spec → test}/grammar/sclass_spec.rb +0 -0
- data/{spec → test}/grammar/self_spec.rb +0 -0
- data/{spec → test}/grammar/str_spec.rb +0 -0
- data/{spec → test}/grammar/super_spec.rb +0 -0
- data/{spec → test}/grammar/true_spec.rb +0 -0
- data/{spec → test}/grammar/undef_spec.rb +0 -0
- data/{spec → test}/grammar/unless_spec.rb +0 -0
- data/{spec → test}/grammar/while_spec.rb +0 -0
- data/{spec → test}/grammar/xstr_spec.rb +0 -0
- data/{spec → test}/grammar/yield_spec.rb +0 -0
- data/{spec → test}/spec_helper.rb +0 -0
- metadata +330 -264
- data/core/debug.js +0 -59
- data/core/debug.rb +0 -35
- data/core/dir.rb +0 -90
- data/core/file.rb +0 -83
- data/core/gemlib.rb +0 -30
- data/core/io.rb +0 -44
- data/core_spec/README.md +0 -34
- data/core_spec/core/array/collect_spec.rb +0 -3
- data/core_spec/core/array/element_set_spec.rb +0 -7
- data/core_spec/core/array/eql_spec.rb +0 -3
- data/core_spec/core/array/equal_value_spec.rb +0 -3
- data/core_spec/core/array/fixtures/classes.rb +0 -8
- data/core_spec/core/array/length_spec.rb +0 -3
- data/core_spec/core/array/map_spec.rb +0 -3
- data/core_spec/core/array/replace_spec.rb +0 -3
- data/core_spec/core/enumerable/collect_spec.rb +0 -3
- data/core_spec/core/enumerable/detect_spec.rb +0 -3
- data/core_spec/core/enumerable/find_spec.rb +0 -3
- data/core_spec/core/enumerable/first_spec.rb +0 -3
- data/core_spec/core/enumerable/shared/entries.rb +0 -7
- data/core_spec/core/enumerable/shared/find.rb +0 -49
- data/core_spec/core/enumerable/shared/take.rb +0 -31
- data/core_spec/core/enumerable/to_a_spec.rb +0 -7
- data/core_spec/core/hash/assoc_spec.rb +0 -29
- data/core_spec/core/object/is_a_spec.rb +0 -2
- data/core_spec/core/object/shared/kind_of.rb +0 -0
- data/core_spec/core/regexp/shared/match.rb +0 -11
- data/core_spec/language/fixtures/block.rb +0 -19
- data/core_spec/language/fixtures/break.rb +0 -39
- data/core_spec/language/fixtures/defined.rb +0 -9
- data/core_spec/language/fixtures/ensure.rb +0 -37
- data/core_spec/language/fixtures/next.rb +0 -46
- data/core_spec/language/fixtures/send.rb +0 -36
- data/core_spec/language/fixtures/super.rb +0 -43
- data/core_spec/language/regexp_spec.rb +0 -7
- data/core_spec/language/string_spec.rb +0 -4
- data/core_spec/language/super_spec.rb +0 -18
- data/core_spec/language/versions/hash_1.9.rb +0 -20
- data/core_spec/opal/opal/defined_spec.rb +0 -15
- data/core_spec/opal/opal/function_spec.rb +0 -11
- data/core_spec/opal/opal/native_spec.rb +0 -16
- data/core_spec/opal/opal/null_spec.rb +0 -10
- data/core_spec/opal/opal/number_spec.rb +0 -11
- data/core_spec/opal/opal/object_spec.rb +0 -16
- data/core_spec/opal/opal/string_spec.rb +0 -11
- data/core_spec/opal/opal/typeof_spec.rb +0 -9
- data/core_spec/opal/opal/undefined_spec.rb +0 -10
- data/core_spec/opal/true/case_compare_spec.rb +0 -12
- data/core_spec/opal/true/class_spec.rb +0 -10
- data/core_spec/release_runner.html +0 -17
- data/core_spec/runner.html +0 -16
- data/core_spec/spec_helper.rb +0 -23
- data/lib/opal/context.rb +0 -269
- data/lib/opal/dependency_builder.rb +0 -133
- data/lib/opal/environment.rb +0 -87
- data/lib/opal/parser/sexp.rb +0 -17
data/core/debug.js
DELETED
@@ -1,59 +0,0 @@
|
|
1
|
-
// ..........................................................
|
2
|
-
// DEBUG - this is only included in debug mode
|
3
|
-
//
|
4
|
-
|
5
|
-
// Identify opal as being in debug mode
|
6
|
-
opal.debug = true;
|
7
|
-
|
8
|
-
// An array of every method send in debug mode
|
9
|
-
var debug_stack = [];
|
10
|
-
|
11
|
-
opal.send = function(recv, block, jsid) {
|
12
|
-
var args = $slice.call(arguments, 3),
|
13
|
-
meth = recv[jsid];
|
14
|
-
|
15
|
-
if (!meth) {
|
16
|
-
args.unshift(jsid_to_mid(jsid));
|
17
|
-
return recv.$method_missing.apply(recv, args);
|
18
|
-
}
|
19
|
-
|
20
|
-
// Always set a block. If a block wasn't given then this is just a
|
21
|
-
// no-op.
|
22
|
-
meth.$P = block;
|
23
|
-
|
24
|
-
// Push this call frame onto debug stack
|
25
|
-
debug_stack.push({
|
26
|
-
recv: recv,
|
27
|
-
jsid: jsid,
|
28
|
-
meth: meth
|
29
|
-
});
|
30
|
-
|
31
|
-
try {
|
32
|
-
var result = meth.apply(recv, args);
|
33
|
-
}
|
34
|
-
catch (err) {
|
35
|
-
if (!err.opal_stack) {
|
36
|
-
err.opal_stack = debug_stack.slice();
|
37
|
-
}
|
38
|
-
|
39
|
-
throw err;
|
40
|
-
}
|
41
|
-
finally {
|
42
|
-
debug_stack.pop();
|
43
|
-
}
|
44
|
-
|
45
|
-
return result;
|
46
|
-
};
|
47
|
-
|
48
|
-
var release_define_method = define_method;
|
49
|
-
|
50
|
-
define_method = opal.defn = function(klass, id, body, file, line) {
|
51
|
-
|
52
|
-
if (!body.$debugFile) {
|
53
|
-
body.$debugFile = file;
|
54
|
-
body.$debugLine = line;
|
55
|
-
body.$debugKlass = klass;
|
56
|
-
}
|
57
|
-
|
58
|
-
return release_define_method(klass, id, body);
|
59
|
-
};
|
data/core/debug.rb
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
#############################################################
|
2
|
-
# DEBUG - only included in debug mode
|
3
|
-
#
|
4
|
-
|
5
|
-
class Exception
|
6
|
-
def backtrace
|
7
|
-
%x{
|
8
|
-
var result = [],
|
9
|
-
stack = this.opal_stack || [],
|
10
|
-
frame,
|
11
|
-
recv,
|
12
|
-
meth;
|
13
|
-
|
14
|
-
for (var i = stack.length - 1; i >= 0; i--) {
|
15
|
-
frame = stack[i];
|
16
|
-
meth = frame.meth;
|
17
|
-
recv = frame.recv;
|
18
|
-
klass = meth.$debugKlass;
|
19
|
-
|
20
|
-
if (recv.$flags & T_OBJECT) {
|
21
|
-
recv = class_real(recv.$klass);
|
22
|
-
recv = (recv === klass ? recv.$name : klass.$name + '(' + recv.$name + ')') + '#';
|
23
|
-
}
|
24
|
-
else {
|
25
|
-
|
26
|
-
recv = recv.$name + '.';
|
27
|
-
}
|
28
|
-
|
29
|
-
result.push('from ' + recv + jsid_to_mid(frame.jsid) + ' at ' + meth.$debugFile + ':' + meth.$debugLine);
|
30
|
-
}
|
31
|
-
|
32
|
-
return result;
|
33
|
-
}
|
34
|
-
end
|
35
|
-
end
|
data/core/dir.rb
DELETED
@@ -1,90 +0,0 @@
|
|
1
|
-
class Dir
|
2
|
-
def self.getwd
|
3
|
-
`FS_CWD`
|
4
|
-
end
|
5
|
-
|
6
|
-
def self.pwd
|
7
|
-
`FS_CWD`
|
8
|
-
end
|
9
|
-
|
10
|
-
def self.[](*globs)
|
11
|
-
%x{
|
12
|
-
var result = [], files = FACTORIES;
|
13
|
-
|
14
|
-
for (var i = 0, ii = globs.length; i < ii; i++) {
|
15
|
-
var glob = globs[i];
|
16
|
-
|
17
|
-
var re = fs_glob_to_regexp(#{ File.expand_path `glob` });
|
18
|
-
|
19
|
-
for (var file in files) {
|
20
|
-
if (re.exec(file)) {
|
21
|
-
result.push(file);
|
22
|
-
}
|
23
|
-
}
|
24
|
-
}
|
25
|
-
|
26
|
-
return result;
|
27
|
-
}
|
28
|
-
end
|
29
|
-
|
30
|
-
%x(
|
31
|
-
function fs_glob_to_regexp(glob) {
|
32
|
-
var parts = glob.split(''),
|
33
|
-
length = parts.length,
|
34
|
-
result = '';
|
35
|
-
|
36
|
-
var opt_group_stack = 0;
|
37
|
-
|
38
|
-
for (var i = 0; i < length; i++) {
|
39
|
-
var cur = parts[i];
|
40
|
-
|
41
|
-
switch (cur) {
|
42
|
-
case '*':
|
43
|
-
if (parts[i + 1] === '*' && parts[i + 2] === '/') {
|
44
|
-
result += '.*';
|
45
|
-
i += 2;
|
46
|
-
}
|
47
|
-
else {
|
48
|
-
result += '[^/]*';
|
49
|
-
}
|
50
|
-
break;
|
51
|
-
|
52
|
-
case '.':
|
53
|
-
result += '\\\\';
|
54
|
-
result += cur;
|
55
|
-
break;
|
56
|
-
|
57
|
-
case ',':
|
58
|
-
if (opt_group_stack) {
|
59
|
-
result += '|';
|
60
|
-
}
|
61
|
-
else {
|
62
|
-
result += ',';
|
63
|
-
}
|
64
|
-
break;
|
65
|
-
|
66
|
-
case '{':
|
67
|
-
result += '(';
|
68
|
-
opt_group_stack++;
|
69
|
-
break;
|
70
|
-
|
71
|
-
case '}':
|
72
|
-
if (opt_group_stack) {
|
73
|
-
result += ')';
|
74
|
-
opt_group_stack--;
|
75
|
-
}
|
76
|
-
else {
|
77
|
-
result += '}'
|
78
|
-
}
|
79
|
-
break;
|
80
|
-
|
81
|
-
default:
|
82
|
-
result += cur;
|
83
|
-
}
|
84
|
-
}
|
85
|
-
|
86
|
-
return new RegExp('^' + result + '$');
|
87
|
-
}
|
88
|
-
|
89
|
-
)
|
90
|
-
end
|
data/core/file.rb
DELETED
@@ -1,83 +0,0 @@
|
|
1
|
-
class File
|
2
|
-
# Regexp to split path into dirname, basename and extname
|
3
|
-
PATH_RE = /^(.+\/(?!$)|\/)?((?:.+?)?(\.[^.]*)?)$/
|
4
|
-
|
5
|
-
def self.expand_path(path, base = undefined)
|
6
|
-
%x{
|
7
|
-
if (!base) {
|
8
|
-
if (path.charAt(0) !== '/') {
|
9
|
-
base = FS_CWD;
|
10
|
-
}
|
11
|
-
else {
|
12
|
-
base = '';
|
13
|
-
}
|
14
|
-
}
|
15
|
-
|
16
|
-
path = #{ join(base, path) };
|
17
|
-
|
18
|
-
var parts = path.split('/'), result = [], path;
|
19
|
-
|
20
|
-
// initial '/'
|
21
|
-
if (parts[0] === '') {
|
22
|
-
result.push('');
|
23
|
-
}
|
24
|
-
|
25
|
-
for (var i = 0, ii = parts.length; i < ii; i++) {
|
26
|
-
part = parts[i];
|
27
|
-
|
28
|
-
if (part === '..') {
|
29
|
-
result.pop();
|
30
|
-
}
|
31
|
-
else if (part === '.' || part === '') {
|
32
|
-
|
33
|
-
}
|
34
|
-
else {
|
35
|
-
result.push(part);
|
36
|
-
}
|
37
|
-
}
|
38
|
-
|
39
|
-
return result.join('/');
|
40
|
-
}
|
41
|
-
end
|
42
|
-
|
43
|
-
def self.join(*paths)
|
44
|
-
`paths.join('/')`
|
45
|
-
end
|
46
|
-
|
47
|
-
def self.dirname(path)
|
48
|
-
%x{
|
49
|
-
var dirname = #{PATH_RE}.exec(path)[1];
|
50
|
-
|
51
|
-
if (!dirname) {
|
52
|
-
return '.';
|
53
|
-
}
|
54
|
-
else if (dirname === '/') {
|
55
|
-
return dirname;
|
56
|
-
}
|
57
|
-
else {
|
58
|
-
return dirname.substring(0, dirname.length - 1);
|
59
|
-
}
|
60
|
-
}
|
61
|
-
end
|
62
|
-
|
63
|
-
def self.extname(path)
|
64
|
-
%x{
|
65
|
-
var extname = #{PATH_RE}.exec(path)[3];
|
66
|
-
|
67
|
-
if (!extname || extname === '.') {
|
68
|
-
return '';
|
69
|
-
}
|
70
|
-
else {
|
71
|
-
return extname;
|
72
|
-
}
|
73
|
-
}
|
74
|
-
end
|
75
|
-
|
76
|
-
def self.basename(path, suffix)
|
77
|
-
`$opal.fs.basename(path, suffix)`
|
78
|
-
end
|
79
|
-
|
80
|
-
def self.exist?(path)
|
81
|
-
`!!FACTORIES[#{ expand_path path }]`
|
82
|
-
end
|
83
|
-
end
|
data/core/gemlib.rb
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
# ...........................................................
|
2
|
-
# GEMLIB - only loaded when running inside v8 in gem
|
3
|
-
#
|
4
|
-
|
5
|
-
# In gem, use 'opal-ruby-. Browser (default) uses 'opal-browser'
|
6
|
-
RUBY_ENGINE = 'opal-ruby'
|
7
|
-
|
8
|
-
# Update load paths (aliasing does not yet work as planned)
|
9
|
-
$: = $LOAD_PATH = `opal_filesystem.find_paths`
|
10
|
-
|
11
|
-
$" = $LOADED_FEATURES = []
|
12
|
-
|
13
|
-
module Kernel
|
14
|
-
def require(path)
|
15
|
-
%x{
|
16
|
-
var resolved = opal_filesystem.require(#{path}, #{$:});
|
17
|
-
|
18
|
-
if (resolved === false) {
|
19
|
-
return false;
|
20
|
-
}
|
21
|
-
else if (!resolved) {
|
22
|
-
#{ raise LoadError, "cannot load file -- #{path}" };
|
23
|
-
}
|
24
|
-
else {
|
25
|
-
#{ $LOADED_FEATURES << `resolved` };
|
26
|
-
return true;
|
27
|
-
}
|
28
|
-
}
|
29
|
-
end
|
30
|
-
end
|
data/core/io.rb
DELETED
@@ -1,44 +0,0 @@
|
|
1
|
-
class IO
|
2
|
-
def puts(*args)
|
3
|
-
return flush if args.empty?
|
4
|
-
|
5
|
-
args.each do |a|
|
6
|
-
write a.to_s
|
7
|
-
flush
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
def print(*args)
|
12
|
-
args.each { |a| write a.to_s }
|
13
|
-
|
14
|
-
nil
|
15
|
-
end
|
16
|
-
|
17
|
-
def write()
|
18
|
-
# erm..
|
19
|
-
end
|
20
|
-
|
21
|
-
def flush
|
22
|
-
self
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
STDOUT = $stdout = IO.new
|
27
|
-
|
28
|
-
class << $stdout
|
29
|
-
# private variable used to buffer stdout until flush
|
30
|
-
`var stdout_buffer = [];`
|
31
|
-
|
32
|
-
def write(str)
|
33
|
-
`stdout_buffer.push(str);`
|
34
|
-
|
35
|
-
nil
|
36
|
-
end
|
37
|
-
|
38
|
-
def flush
|
39
|
-
`console.log(stdout_buffer.join(''));`
|
40
|
-
`stdout_buffer = [];`
|
41
|
-
|
42
|
-
nil
|
43
|
-
end
|
44
|
-
end
|
data/core_spec/README.md
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
Opal Tests
|
2
|
-
==========
|
3
|
-
|
4
|
-
All tests/specs in this folder should be run in an opal context, either
|
5
|
-
with the bundled buidl tools, or directly in the browser.
|
6
|
-
|
7
|
-
License
|
8
|
-
=======
|
9
|
-
|
10
|
-
All specs/tests are taken from rubyspec. Original license:
|
11
|
-
|
12
|
-
Copyright (c) 2008 Engine Yard, Inc. All rights reserved.
|
13
|
-
|
14
|
-
Permission is hereby granted, free of charge, to any person
|
15
|
-
obtaining a copy of this software and associated documentation
|
16
|
-
files (the "Software"), to deal in the Software without
|
17
|
-
restriction, including without limitation the rights to use,
|
18
|
-
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
19
|
-
copies of the Software, and to permit persons to whom the
|
20
|
-
Software is furnished to do so, subject to the following
|
21
|
-
conditions:
|
22
|
-
|
23
|
-
The above copyright notice and this permission notice shall be
|
24
|
-
included in all copies or substantial portions of the Software.
|
25
|
-
|
26
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
27
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
28
|
-
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
29
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
30
|
-
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
31
|
-
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
32
|
-
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
33
|
-
OTHER DEALINGS IN THE SOFTWARE.
|
34
|
-
|