opal 0.3.16 → 0.3.17

Sign up to get free protection for your applications and to get access to all the features.
Files changed (251) hide show
  1. data/.gitignore +2 -0
  2. data/CHANGELOG.md +12 -0
  3. data/Gemfile +8 -7
  4. data/README.md +21 -13
  5. data/Rakefile +64 -78
  6. data/bin/opal +18 -29
  7. data/core/alpha.rb +2 -9
  8. data/core/array.rb +106 -50
  9. data/core/basic_object.rb +10 -8
  10. data/core/boolean.rb +2 -0
  11. data/core/class.rb +25 -13
  12. data/core/comparable.rb +6 -6
  13. data/core/enumerable.rb +90 -94
  14. data/core/enumerator.rb +3 -3
  15. data/core/hash.rb +86 -46
  16. data/core/kernel.rb +55 -39
  17. data/core/load_order +2 -5
  18. data/core/match_data.rb +1 -1
  19. data/core/module.rb +45 -20
  20. data/core/nil_class.rb +6 -2
  21. data/core/numeric.rb +20 -10
  22. data/core/proc.rb +2 -2
  23. data/core/range.rb +72 -13
  24. data/core/regexp.rb +5 -3
  25. data/core/runtime.js +228 -287
  26. data/core/string.rb +345 -37
  27. data/core/top_self.rb +1 -1
  28. data/lib/opal.rb +13 -91
  29. data/lib/opal/builder.rb +47 -120
  30. data/lib/opal/builder_task.rb +74 -0
  31. data/lib/opal/{parser/grammar.rb → grammar.rb} +1094 -1083
  32. data/lib/opal/{parser/grammar.y → grammar.y} +7 -0
  33. data/lib/opal/{parser/lexer.rb → lexer.rb} +32 -11
  34. data/lib/opal/{parser/parser.rb → parser.rb} +232 -238
  35. data/lib/opal/{parser/scope.rb → scope.rb} +72 -9
  36. data/lib/opal/version.rb +2 -3
  37. data/opal.gemspec +1 -2
  38. data/{core_spec → spec}/core/array/allocate_spec.rb +1 -3
  39. data/{core_spec → spec}/core/array/append_spec.rb +1 -4
  40. data/{core_spec → spec}/core/array/assoc_spec.rb +1 -4
  41. data/{core_spec → spec}/core/array/at_spec.rb +1 -3
  42. data/{core_spec → spec}/core/array/clear_spec.rb +1 -3
  43. data/spec/core/array/clone_spec.rb +15 -0
  44. data/{core_spec/core/array/shared/collect.rb → spec/core/array/collect_spec.rb} +1 -1
  45. data/{core_spec → spec}/core/array/compact_spec.rb +1 -3
  46. data/{core_spec → spec}/core/array/concat_spec.rb +1 -3
  47. data/{core_spec → spec}/core/array/constructor_spec.rb +9 -3
  48. data/{core_spec → spec}/core/array/count_spec.rb +1 -3
  49. data/{core_spec → spec}/core/array/delete_at_spec.rb +1 -4
  50. data/{core_spec → spec}/core/array/delete_if_spec.rb +1 -4
  51. data/{core_spec → spec}/core/array/delete_spec.rb +1 -4
  52. data/{core_spec → spec}/core/array/each_index_spec.rb +1 -4
  53. data/{core_spec → spec}/core/array/each_spec.rb +1 -4
  54. data/{core_spec → spec}/core/array/element_reference_spec.rb +74 -4
  55. data/{core_spec → spec}/core/array/empty_spec.rb +1 -4
  56. data/{core_spec/core/array/shared/eql.rb → spec/core/array/eql_spec.rb} +1 -1
  57. data/{core_spec → spec}/core/array/fetch_spec.rb +1 -4
  58. data/{core_spec → spec}/core/array/first_spec.rb +1 -3
  59. data/{core_spec → spec}/core/array/flatten_spec.rb +1 -3
  60. data/{core_spec → spec}/core/array/include_spec.rb +1 -3
  61. data/{core_spec → spec}/core/array/insert_spec.rb +1 -4
  62. data/{core_spec → spec}/core/array/last_spec.rb +1 -4
  63. data/{core_spec/core/array/shared/length.rb → spec/core/array/length_spec.rb} +1 -1
  64. data/spec/core/array/map_spec.rb +53 -0
  65. data/{core_spec → spec}/core/array/plus_spec.rb +1 -4
  66. data/{core_spec → spec}/core/array/pop_spec.rb +1 -4
  67. data/{core_spec → spec}/core/array/push_spec.rb +1 -4
  68. data/{core_spec → spec}/core/array/rassoc_spec.rb +1 -4
  69. data/{core_spec → spec}/core/array/reject_spec.rb +1 -4
  70. data/{core_spec/core/array/shared/replace.rb → spec/core/array/replace_spec.rb} +1 -1
  71. data/{core_spec → spec}/core/array/reverse_each_spec.rb +1 -4
  72. data/{core_spec → spec}/core/array/reverse_spec.rb +1 -4
  73. data/spec/core/array/size_spec.rb +6 -0
  74. data/spec/core/array/to_ary_spec.rb +6 -0
  75. data/spec/core/array/uniq_spec.rb +22 -0
  76. data/spec/core/array/zip_spec.rb +20 -0
  77. data/{core_spec → spec}/core/class/new_spec.rb +1 -4
  78. data/{core_spec → spec}/core/enumerable/all_spec.rb +1 -4
  79. data/{core_spec → spec}/core/enumerable/any_spec.rb +1 -4
  80. data/{core_spec/core/enumerable/shared/collect.rb → spec/core/enumerable/collect_spec.rb} +1 -1
  81. data/{core_spec → spec}/core/enumerable/count_spec.rb +2 -5
  82. data/{core_spec → spec}/core/enumerable/fixtures/classes.rb +1 -2
  83. data/{core_spec → spec}/core/false/and_spec.rb +1 -3
  84. data/{core_spec → spec}/core/false/inspect_spec.rb +1 -3
  85. data/{core_spec → spec}/core/false/or_spec.rb +1 -3
  86. data/{core_spec → spec}/core/false/to_s_spec.rb +1 -3
  87. data/{core_spec → spec}/core/false/xor_spec.rb +1 -3
  88. data/{core_spec → spec}/core/hash/allocate_spec.rb +1 -3
  89. data/spec/core/hash/assoc_spec.rb +25 -0
  90. data/{core_spec → spec}/core/hash/clear_spec.rb +1 -3
  91. data/{core_spec → spec}/core/hash/clone_spec.rb +1 -3
  92. data/{core_spec → spec}/core/hash/default_spec.rb +1 -3
  93. data/{core_spec → spec}/core/hash/delete_if_spec.rb +1 -3
  94. data/{core_spec → spec}/core/hash/element_reference_spec.rb +1 -3
  95. data/{core_spec → spec}/core/hash/element_set_spec.rb +1 -3
  96. data/spec/core/hash/merge_spec.rb +37 -0
  97. data/{core_spec → spec}/core/hash/new_spec.rb +1 -3
  98. data/{core_spec → spec}/core/matchdata/to_a_spec.rb +1 -3
  99. data/{core_spec → spec}/core/nil/and_spec.rb +1 -4
  100. data/{core_spec → spec}/core/nil/inspect_spec.rb +1 -4
  101. data/{core_spec → spec}/core/nil/nil_spec.rb +1 -4
  102. data/{core_spec → spec}/core/nil/or_spec.rb +1 -4
  103. data/{core_spec → spec}/core/nil/to_a_spec.rb +1 -4
  104. data/{core_spec → spec}/core/nil/to_f_spec.rb +1 -4
  105. data/{core_spec → spec}/core/nil/to_i_spec.rb +1 -4
  106. data/{core_spec → spec}/core/nil/to_s_spec.rb +1 -4
  107. data/{core_spec → spec}/core/nil/xor_spec.rb +1 -4
  108. data/{core_spec → spec}/core/numeric/equal_value_spec.rb +1 -3
  109. data/{core_spec → spec}/core/regexp/match_spec.rb +10 -3
  110. data/{core_spec → spec}/core/symbol/to_proc_spec.rb +1 -3
  111. data/{core_spec → spec}/core/true/and_spec.rb +1 -3
  112. data/{core_spec → spec}/core/true/inspect_spec.rb +1 -3
  113. data/{core_spec → spec}/core/true/or_spec.rb +1 -3
  114. data/{core_spec → spec}/core/true/to_s_spec.rb +1 -3
  115. data/{core_spec → spec}/core/true/xor_spec.rb +1 -3
  116. data/spec/index.html +11 -0
  117. data/{core_spec → spec}/language/alias_spec.rb +1 -3
  118. data/{core_spec → spec}/language/and_spec.rb +1 -4
  119. data/{core_spec → spec}/language/array_spec.rb +1 -4
  120. data/{core_spec → spec}/language/block_spec.rb +20 -3
  121. data/{core_spec → spec}/language/break_spec.rb +40 -3
  122. data/{core_spec → spec}/language/case_spec.rb +1 -4
  123. data/{core_spec → spec}/language/defined_spec.rb +9 -3
  124. data/{core_spec → spec}/language/ensure_spec.rb +38 -3
  125. data/{core_spec → spec}/language/hash_spec.rb +1 -3
  126. data/{core_spec → spec}/language/if_spec.rb +1 -4
  127. data/{core_spec → spec}/language/loop_spec.rb +1 -3
  128. data/spec/language/metaclass_spec.rb +13 -0
  129. data/{core_spec → spec}/language/next_spec.rb +47 -3
  130. data/{core_spec → spec}/language/or_spec.rb +1 -4
  131. data/{core_spec → spec}/language/predefined_spec.rb +1 -3
  132. data/{core_spec/language/regexp/interpolation_spec.rb → spec/language/regexp_spec.rb} +6 -3
  133. data/{core_spec → spec}/language/send_spec.rb +38 -4
  134. data/spec/language/singleton_class_spec.rb +31 -0
  135. data/spec/language/super_spec.rb +188 -0
  136. data/{core_spec → spec}/language/symbol_spec.rb +1 -3
  137. data/{core_spec → spec}/language/undef_spec.rb +1 -3
  138. data/{core_spec → spec}/language/unless_spec.rb +1 -4
  139. data/{core_spec → spec}/language/until_spec.rb +1 -3
  140. data/{core_spec → spec}/language/variables_spec.rb +1 -3
  141. data/{core_spec → spec}/language/while_spec.rb +1 -3
  142. data/{spec → test}/builder/build_source_spec.rb +0 -0
  143. data/{spec → test}/builder/fixtures/build_source/adam.rb +0 -0
  144. data/{spec → test}/builder/fixtures/build_source/bar/a.rb +0 -0
  145. data/{spec → test}/builder/fixtures/build_source/bar/wow/b.rb +0 -0
  146. data/{spec → test}/builder/fixtures/build_source/bar/wow/cow/c.rb +0 -0
  147. data/{spec → test}/builder/fixtures/build_source/beynon.rb +0 -0
  148. data/{spec → test}/builder/fixtures/build_source/charles.js +0 -0
  149. data/{spec → test}/builder/fixtures/build_source/foo/a.rb +0 -0
  150. data/{spec → test}/builder/fixtures/build_source/foo/b.rb +0 -0
  151. data/{spec → test}/builder/fixtures/build_source/foo/x.js +0 -0
  152. data/{spec → test}/builder/fixtures/build_source/foo/y.js +0 -0
  153. data/{spec → test}/grammar/alias_spec.rb +0 -0
  154. data/{spec → test}/grammar/and_spec.rb +0 -0
  155. data/{spec → test}/grammar/array_spec.rb +0 -0
  156. data/{spec → test}/grammar/attrasgn_spec.rb +0 -0
  157. data/{spec → test}/grammar/begin_spec.rb +0 -0
  158. data/{spec → test}/grammar/block_spec.rb +0 -0
  159. data/{spec → test}/grammar/break_spec.rb +0 -0
  160. data/{spec → test}/grammar/call_spec.rb +0 -0
  161. data/{spec → test}/grammar/class_spec.rb +0 -0
  162. data/{spec → test}/grammar/const_spec.rb +0 -0
  163. data/{spec → test}/grammar/cvar_spec.rb +0 -0
  164. data/{spec → test}/grammar/def_spec.rb +0 -0
  165. data/{spec → test}/grammar/false_spec.rb +0 -0
  166. data/{spec → test}/grammar/file_spec.rb +0 -0
  167. data/{spec → test}/grammar/gvar_spec.rb +0 -0
  168. data/{spec → test}/grammar/hash_spec.rb +0 -0
  169. data/{spec → test}/grammar/iasgn_spec.rb +0 -0
  170. data/{spec → test}/grammar/if_spec.rb +0 -0
  171. data/{spec → test}/grammar/iter_spec.rb +0 -0
  172. data/{spec → test}/grammar/ivar_spec.rb +0 -0
  173. data/{spec → test}/grammar/lasgn_spec.rb +0 -0
  174. data/{spec → test}/grammar/line_spec.rb +0 -0
  175. data/{spec → test}/grammar/lvar_spec.rb +0 -0
  176. data/{spec → test}/grammar/masgn_spec.rb +0 -0
  177. data/{spec → test}/grammar/module_spec.rb +0 -0
  178. data/{spec → test}/grammar/nil_spec.rb +0 -0
  179. data/{spec → test}/grammar/not_spec.rb +0 -0
  180. data/{spec → test}/grammar/op_asgn1_spec.rb +0 -0
  181. data/{spec → test}/grammar/op_asgn2_spec.rb +0 -0
  182. data/{spec → test}/grammar/or_spec.rb +0 -0
  183. data/{spec → test}/grammar/return_spec.rb +0 -0
  184. data/{spec → test}/grammar/sclass_spec.rb +0 -0
  185. data/{spec → test}/grammar/self_spec.rb +0 -0
  186. data/{spec → test}/grammar/str_spec.rb +0 -0
  187. data/{spec → test}/grammar/super_spec.rb +0 -0
  188. data/{spec → test}/grammar/true_spec.rb +0 -0
  189. data/{spec → test}/grammar/undef_spec.rb +0 -0
  190. data/{spec → test}/grammar/unless_spec.rb +0 -0
  191. data/{spec → test}/grammar/while_spec.rb +0 -0
  192. data/{spec → test}/grammar/xstr_spec.rb +0 -0
  193. data/{spec → test}/grammar/yield_spec.rb +0 -0
  194. data/{spec → test}/spec_helper.rb +0 -0
  195. metadata +330 -264
  196. data/core/debug.js +0 -59
  197. data/core/debug.rb +0 -35
  198. data/core/dir.rb +0 -90
  199. data/core/file.rb +0 -83
  200. data/core/gemlib.rb +0 -30
  201. data/core/io.rb +0 -44
  202. data/core_spec/README.md +0 -34
  203. data/core_spec/core/array/collect_spec.rb +0 -3
  204. data/core_spec/core/array/element_set_spec.rb +0 -7
  205. data/core_spec/core/array/eql_spec.rb +0 -3
  206. data/core_spec/core/array/equal_value_spec.rb +0 -3
  207. data/core_spec/core/array/fixtures/classes.rb +0 -8
  208. data/core_spec/core/array/length_spec.rb +0 -3
  209. data/core_spec/core/array/map_spec.rb +0 -3
  210. data/core_spec/core/array/replace_spec.rb +0 -3
  211. data/core_spec/core/enumerable/collect_spec.rb +0 -3
  212. data/core_spec/core/enumerable/detect_spec.rb +0 -3
  213. data/core_spec/core/enumerable/find_spec.rb +0 -3
  214. data/core_spec/core/enumerable/first_spec.rb +0 -3
  215. data/core_spec/core/enumerable/shared/entries.rb +0 -7
  216. data/core_spec/core/enumerable/shared/find.rb +0 -49
  217. data/core_spec/core/enumerable/shared/take.rb +0 -31
  218. data/core_spec/core/enumerable/to_a_spec.rb +0 -7
  219. data/core_spec/core/hash/assoc_spec.rb +0 -29
  220. data/core_spec/core/object/is_a_spec.rb +0 -2
  221. data/core_spec/core/object/shared/kind_of.rb +0 -0
  222. data/core_spec/core/regexp/shared/match.rb +0 -11
  223. data/core_spec/language/fixtures/block.rb +0 -19
  224. data/core_spec/language/fixtures/break.rb +0 -39
  225. data/core_spec/language/fixtures/defined.rb +0 -9
  226. data/core_spec/language/fixtures/ensure.rb +0 -37
  227. data/core_spec/language/fixtures/next.rb +0 -46
  228. data/core_spec/language/fixtures/send.rb +0 -36
  229. data/core_spec/language/fixtures/super.rb +0 -43
  230. data/core_spec/language/regexp_spec.rb +0 -7
  231. data/core_spec/language/string_spec.rb +0 -4
  232. data/core_spec/language/super_spec.rb +0 -18
  233. data/core_spec/language/versions/hash_1.9.rb +0 -20
  234. data/core_spec/opal/opal/defined_spec.rb +0 -15
  235. data/core_spec/opal/opal/function_spec.rb +0 -11
  236. data/core_spec/opal/opal/native_spec.rb +0 -16
  237. data/core_spec/opal/opal/null_spec.rb +0 -10
  238. data/core_spec/opal/opal/number_spec.rb +0 -11
  239. data/core_spec/opal/opal/object_spec.rb +0 -16
  240. data/core_spec/opal/opal/string_spec.rb +0 -11
  241. data/core_spec/opal/opal/typeof_spec.rb +0 -9
  242. data/core_spec/opal/opal/undefined_spec.rb +0 -10
  243. data/core_spec/opal/true/case_compare_spec.rb +0 -12
  244. data/core_spec/opal/true/class_spec.rb +0 -10
  245. data/core_spec/release_runner.html +0 -17
  246. data/core_spec/runner.html +0 -16
  247. data/core_spec/spec_helper.rb +0 -23
  248. data/lib/opal/context.rb +0 -269
  249. data/lib/opal/dependency_builder.rb +0 -133
  250. data/lib/opal/environment.rb +0 -87
  251. 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
-
@@ -1,3 +0,0 @@
1
- require File.expand_path('../../../spec_helper', __FILE__)
2
- require File.expand_path('../fixtures/classes', __FILE__)
3
- require File.expand_path('../shared/collect', __FILE__)
@@ -1,7 +0,0 @@
1
- require File.expand_path('../../../spec_helper', __FILE__)
2
- require File.expand_path('../fixtures/classes', __FILE__)
3
-
4
- describe "Array#[]=" do
5
- it "sets the value of the element at index" do
6
- end
7
- end
@@ -1,3 +0,0 @@
1
- require File.expand_path('../../../spec_helper', __FILE__)
2
- require File.expand_path('../fixtures/classes', __FILE__)
3
- require File.expand_path('../shared/eql', __FILE__)
@@ -1,3 +0,0 @@
1
- require File.expand_path('../../../spec_helper', __FILE__)
2
- require File.expand_path('../fixtures/classes', __FILE__)
3
- require File.expand_path('../shared/eql', __FILE__)
@@ -1,8 +0,0 @@
1
- module ArraySpecs
2
- class MyArray < Array
3
- def initialize(a, b)
4
- self << a << b
5
- ScratchPad.record :my_array_initialize
6
- end
7
- end
8
- end
@@ -1,3 +0,0 @@
1
- require File.expand_path('../../../spec_helper', __FILE__)
2
- require File.expand_path('../fixtures/classes', __FILE__)
3
- require File.expand_path('../shared/length', __FILE__)
@@ -1,3 +0,0 @@
1
- require File.expand_path('../../../spec_helper', __FILE__)
2
- require File.expand_path('../fixtures/classes', __FILE__)
3
- require File.expand_path('../shared/collect', __FILE__)
@@ -1,3 +0,0 @@
1
- require File.expand_path('../../../spec_helper', __FILE__)
2
- require File.expand_path('../fixtures/classes', __FILE__)
3
- require File.expand_path('../shared/replace', __FILE__)
@@ -1,3 +0,0 @@
1
- require File.expand_path('../../../spec_helper', __FILE__)
2
- require File.expand_path('../fixtures/classes', __FILE__)
3
- require File.expand_path('../shared/collect', __FILE__)
@@ -1,3 +0,0 @@
1
- require File.expand_path('../../../spec_helper', __FILE__)
2
- require File.expand_path('../fixtures/classes', __FILE__)
3
- require File.expand_path('../shared/find', __FILE__)