opal 1.0.5 → 1.1.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.codeclimate.yml +14 -12
- data/.gitattributes +1 -1
- data/.github/workflows/build.yml +15 -10
- data/.jshintrc +1 -1
- data/.overcommit.yml +35 -0
- data/.rubocop.yml +44 -7
- data/{.rubocop_todo.yml → .rubocop/todo.yml} +4 -5
- data/CHANGELOG.md +87 -2
- data/Gemfile +1 -2
- data/HACKING.md +2 -9
- data/README.md +20 -17
- data/UNRELEASED.md +108 -0
- data/benchmark-ips/bm_array_pop_1.rb +8 -0
- data/benchmark-ips/bm_array_shift.rb +7 -0
- data/benchmark-ips/class_shovel_vs_singleton_class.rb +16 -0
- data/bin/build-browser-source-map-support +5 -0
- data/bin/format-filters +54 -0
- data/bin/remove-filters +39 -0
- data/docs/roda-sprockets.md +86 -0
- data/docs/sinatra.md +5 -12
- data/examples/rack/Gemfile +1 -0
- data/examples/rack/app/application.rb +3 -0
- data/examples/rack/config.ru +5 -4
- data/exe/opal-repl +2 -83
- data/lib/opal/ast/builder.rb +1 -1
- data/lib/opal/builder.rb +2 -10
- data/lib/opal/builder_processors.rb +1 -1
- data/lib/opal/cli_runners.rb +27 -37
- data/lib/opal/cli_runners/applescript.rb +5 -44
- data/lib/opal/cli_runners/chrome.js +7 -35
- data/lib/opal/cli_runners/chrome.rb +75 -17
- data/lib/opal/cli_runners/compiler.rb +17 -0
- data/lib/opal/cli_runners/nashorn.rb +9 -43
- data/lib/opal/cli_runners/nodejs.rb +18 -47
- data/lib/opal/cli_runners/server.rb +18 -6
- data/lib/opal/cli_runners/source-map-support-browser.js +6445 -0
- data/lib/opal/cli_runners/source-map-support.js +639 -0
- data/lib/opal/cli_runners/system_runner.rb +45 -0
- data/lib/opal/compiler.rb +57 -29
- data/lib/opal/config.rb +0 -5
- data/lib/opal/erb.rb +1 -1
- data/lib/opal/magic_comments.rb +34 -0
- data/lib/opal/nodes/args/arity_check.rb +2 -1
- data/lib/opal/nodes/base.rb +1 -1
- data/lib/opal/nodes/call.rb +1 -4
- data/lib/opal/nodes/def.rb +2 -0
- data/lib/opal/nodes/iter.rb +1 -1
- data/lib/opal/nodes/literal.rb +19 -14
- data/lib/opal/nodes/logic.rb +5 -80
- data/lib/opal/nodes/masgn.rb +2 -0
- data/lib/opal/nodes/rescue.rb +1 -1
- data/lib/opal/nodes/super.rb +24 -10
- data/lib/opal/nodes/top.rb +5 -4
- data/lib/opal/parser/with_c_lexer.rb +2 -1
- data/lib/opal/parser/with_ruby_lexer.rb +1 -1
- data/lib/opal/path_reader.rb +2 -2
- data/lib/opal/paths.rb +8 -5
- data/lib/opal/repl.rb +103 -0
- data/lib/opal/rewriter.rb +4 -0
- data/lib/opal/rewriters/for_rewriter.rb +1 -1
- data/lib/opal/rewriters/js_reserved_words.rb +7 -7
- data/lib/opal/rewriters/numblocks.rb +31 -0
- data/lib/opal/rewriters/returnable_logic.rb +33 -0
- data/lib/opal/version.rb +1 -1
- data/opal.gemspec +25 -25
- data/opal/corelib/array.rb +160 -118
- data/opal/corelib/array/pack.rb +5 -3
- data/opal/corelib/basic_object.rb +4 -4
- data/opal/corelib/class.rb +2 -1
- data/opal/corelib/comparable.rb +49 -31
- data/opal/corelib/constants.rb +5 -5
- data/opal/corelib/enumerable.rb +108 -46
- data/opal/corelib/enumerator.rb +27 -12
- data/opal/corelib/file.rb +3 -1
- data/opal/corelib/hash.rb +6 -1
- data/opal/corelib/helpers.rb +8 -28
- data/opal/corelib/io.rb +12 -7
- data/opal/corelib/kernel.rb +45 -14
- data/opal/corelib/kernel/format.rb +3 -1
- data/opal/corelib/math.rb +8 -6
- data/opal/corelib/method.rb +8 -0
- data/opal/corelib/module.rb +17 -2
- data/opal/corelib/number.rb +3 -12
- data/opal/corelib/proc.rb +16 -0
- data/opal/corelib/random/mersenne_twister.rb +147 -0
- data/opal/corelib/range.rb +3 -13
- data/opal/corelib/regexp.rb +10 -6
- data/opal/corelib/runtime.js +208 -81
- data/opal/corelib/string.rb +55 -49
- data/opal/corelib/string/encoding.rb +109 -32
- data/opal/corelib/string/unpack.rb +2 -17
- data/opal/corelib/struct.rb +14 -1
- data/opal/corelib/time.rb +4 -0
- data/opal/opal.rb +1 -1
- data/opal/opal/mini.rb +1 -1
- data/package.json +1 -0
- data/spec/README.md +10 -0
- data/spec/filters/bugs/array.rb +76 -0
- data/spec/filters/bugs/base64.rb +10 -0
- data/spec/filters/bugs/basicobject.rb +12 -0
- data/spec/filters/bugs/bigdecimal.rb +248 -0
- data/spec/filters/bugs/class.rb +12 -0
- data/spec/filters/bugs/complex.rb +7 -0
- data/spec/filters/bugs/date.rb +104 -0
- data/spec/filters/bugs/encoding.rb +259 -0
- data/spec/filters/bugs/enumerable.rb +26 -0
- data/spec/filters/bugs/enumerator.rb +48 -0
- data/spec/filters/bugs/exception.rb +120 -0
- data/spec/filters/bugs/file.rb +48 -0
- data/spec/filters/bugs/float.rb +74 -0
- data/spec/filters/bugs/hash.rb +60 -0
- data/spec/filters/bugs/integer.rb +78 -0
- data/spec/filters/bugs/io.rb +9 -0
- data/spec/filters/bugs/kernel.rb +401 -0
- data/spec/filters/bugs/language.rb +451 -0
- data/spec/filters/bugs/marshal.rb +50 -0
- data/spec/filters/bugs/math.rb +4 -0
- data/spec/filters/bugs/method.rb +79 -0
- data/spec/filters/bugs/module.rb +281 -0
- data/spec/filters/bugs/nilclass.rb +4 -0
- data/spec/filters/bugs/numeric.rb +27 -0
- data/spec/filters/bugs/openstruct.rb +8 -0
- data/spec/filters/bugs/pack_unpack.rb +138 -0
- data/spec/filters/bugs/pathname.rb +9 -0
- data/spec/filters/bugs/proc.rb +80 -0
- data/spec/filters/bugs/random.rb +20 -0
- data/spec/filters/bugs/range.rb +139 -0
- data/spec/filters/bugs/rational.rb +12 -0
- data/spec/filters/bugs/regexp.rb +91 -0
- data/spec/filters/bugs/set.rb +51 -0
- data/spec/filters/bugs/singleton.rb +7 -0
- data/spec/filters/bugs/string.rb +341 -0
- data/spec/filters/bugs/stringscanner.rb +78 -0
- data/spec/filters/bugs/struct.rb +26 -0
- data/spec/filters/bugs/symbol.rb +7 -0
- data/spec/filters/bugs/time.rb +109 -0
- data/spec/filters/bugs/unboundmethod.rb +33 -0
- data/spec/filters/bugs/warnings.rb +30 -0
- data/spec/filters/unsupported/array.rb +168 -0
- data/spec/filters/unsupported/basicobject.rb +15 -0
- data/spec/filters/unsupported/bignum.rb +55 -0
- data/spec/filters/unsupported/class.rb +5 -0
- data/spec/filters/unsupported/delegator.rb +6 -0
- data/spec/filters/unsupported/enumerable.rb +12 -0
- data/spec/filters/unsupported/enumerator.rb +14 -0
- data/spec/filters/unsupported/file.rb +4 -0
- data/spec/filters/unsupported/fixnum.rb +15 -0
- data/spec/filters/unsupported/float.rb +47 -0
- data/spec/filters/unsupported/freeze.rb +259 -0
- data/spec/filters/unsupported/hash.rb +44 -0
- data/spec/filters/unsupported/integer.rb +101 -0
- data/spec/filters/unsupported/kernel.rb +35 -0
- data/spec/filters/unsupported/language.rb +25 -0
- data/spec/filters/unsupported/marshal.rb +44 -0
- data/spec/filters/unsupported/matchdata.rb +63 -0
- data/spec/filters/unsupported/math.rb +4 -0
- data/spec/filters/unsupported/pathname.rb +4 -0
- data/spec/filters/unsupported/privacy.rb +287 -0
- data/spec/filters/unsupported/proc.rb +4 -0
- data/spec/filters/unsupported/random.rb +5 -0
- data/spec/filters/unsupported/range.rb +8 -0
- data/spec/filters/unsupported/regexp.rb +70 -0
- data/spec/filters/unsupported/set.rb +5 -0
- data/spec/filters/unsupported/singleton.rb +7 -0
- data/spec/filters/unsupported/string.rb +687 -0
- data/spec/filters/unsupported/struct.rb +7 -0
- data/spec/filters/unsupported/symbol.rb +21 -0
- data/spec/filters/unsupported/taint.rb +162 -0
- data/spec/filters/unsupported/thread.rb +10 -0
- data/spec/filters/unsupported/time.rb +204 -0
- data/spec/filters/unsupported/usage_of_files.rb +262 -0
- data/spec/lib/builder_processors_spec.rb +44 -0
- data/spec/lib/builder_spec.rb +133 -0
- data/spec/lib/cli_runners/server_spec.rb +25 -0
- data/spec/lib/cli_runners_spec.rb +16 -0
- data/spec/lib/cli_spec.rb +256 -0
- data/spec/lib/compiler_spec.rb +693 -0
- data/spec/lib/config_spec.rb +112 -0
- data/spec/lib/dependency_resolver_spec.rb +43 -0
- data/spec/lib/deprecations_spec.rb +17 -0
- data/spec/lib/fixtures/complex_sprockets.js.rb.erb +4 -0
- data/spec/lib/fixtures/file_with_directives.js +2 -0
- data/spec/lib/fixtures/jst_file.js.jst +1 -0
- data/spec/lib/fixtures/no_requires.rb +1 -0
- data/spec/lib/fixtures/opal_file.rb +2 -0
- data/spec/lib/fixtures/require_tree_test.rb +3 -0
- data/spec/lib/fixtures/required_file.js +1 -0
- data/spec/lib/fixtures/required_tree_test/required_file1.rb +1 -0
- data/spec/lib/fixtures/required_tree_test/required_file2.rb +1 -0
- data/spec/lib/fixtures/requires.rb +7 -0
- data/spec/lib/fixtures/source_location_test.rb +7 -0
- data/spec/lib/fixtures/source_map.rb +1 -0
- data/spec/lib/fixtures/source_map/subfolder/other_file.rb +1 -0
- data/spec/lib/fixtures/sprockets_file.js.rb +3 -0
- data/spec/lib/fixtures/sprockets_require_tree_test.rb +3 -0
- data/spec/lib/path_reader_spec.rb +47 -0
- data/spec/lib/paths_spec.rb +18 -0
- data/spec/lib/repl_spec.rb +28 -0
- data/spec/lib/rewriters/base_spec.rb +68 -0
- data/spec/lib/rewriters/binary_operator_assignment_spec.rb +153 -0
- data/spec/lib/rewriters/block_to_iter_spec.rb +28 -0
- data/spec/lib/rewriters/dot_js_syntax_spec.rb +108 -0
- data/spec/lib/rewriters/explicit_writer_return_spec.rb +186 -0
- data/spec/lib/rewriters/for_rewriter_spec.rb +92 -0
- data/spec/lib/rewriters/hashes/key_duplicates_rewriter_spec.rb +47 -0
- data/spec/lib/rewriters/js_reserved_words_spec.rb +119 -0
- data/spec/lib/rewriters/logical_operator_assignment_spec.rb +202 -0
- data/spec/lib/rewriters/opal_engine_check_spec.rb +84 -0
- data/spec/lib/rewriters/returnable_logic_spec.rb +52 -0
- data/spec/lib/rewriters/rubyspec/filters_rewriter_spec.rb +59 -0
- data/spec/lib/simple_server_spec.rb +56 -0
- data/spec/lib/source_map/file_spec.rb +67 -0
- data/spec/lib/source_map/index_spec.rb +80 -0
- data/spec/lib/spec_helper.rb +105 -0
- data/spec/mspec-opal/formatters.rb +197 -0
- data/spec/mspec-opal/runner.rb +172 -0
- data/spec/opal/compiler/irb_spec.rb +44 -0
- data/spec/opal/compiler/unicode_spec.rb +10 -0
- data/spec/opal/core/array/dup_spec.rb +23 -0
- data/spec/opal/core/array/intersection_spec.rb +38 -0
- data/spec/opal/core/array/minus_spec.rb +38 -0
- data/spec/opal/core/array/union_spec.rb +38 -0
- data/spec/opal/core/array/uniq_spec.rb +49 -0
- data/spec/opal/core/class/inherited_spec.rb +18 -0
- data/spec/opal/core/enumerable/all_break_spec.rb +5 -0
- data/spec/opal/core/enumerable/any_break_spec.rb +5 -0
- data/spec/opal/core/enumerable/collect_break_spec.rb +13 -0
- data/spec/opal/core/enumerable/count_break_spec.rb +5 -0
- data/spec/opal/core/enumerable/detect_break_spec.rb +5 -0
- data/spec/opal/core/enumerable/drop_while_break_spec.rb +5 -0
- data/spec/opal/core/enumerable/each_slice_break_spec.rb +6 -0
- data/spec/opal/core/enumerable/each_with_index_break_spec.rb +5 -0
- data/spec/opal/core/enumerable/each_with_object_break_spec.rb +5 -0
- data/spec/opal/core/enumerable/find_all_break_spec.rb +5 -0
- data/spec/opal/core/enumerable/find_index_break_spec.rb +5 -0
- data/spec/opal/core/enumerable/grep_break_spec.rb +5 -0
- data/spec/opal/core/enumerable/max_break_spec.rb +5 -0
- data/spec/opal/core/enumerable/max_by_break_spec.rb +5 -0
- data/spec/opal/core/enumerable/min_break_spec.rb +5 -0
- data/spec/opal/core/enumerable/min_by_break_spec.rb +5 -0
- data/spec/opal/core/enumerable/none_break_spec.rb +5 -0
- data/spec/opal/core/enumerable/one_break_spec.rb +5 -0
- data/spec/opal/core/enumerable/reduce_break_spec.rb +5 -0
- data/spec/opal/core/enumerable/take_while_break_spec.rb +5 -0
- data/spec/opal/core/enumerator/with_index_spec.rb +6 -0
- data/spec/opal/core/exception_spec.rb +8 -0
- data/spec/opal/core/fixtures/require_tree_files/file 1.rb +1 -0
- data/spec/opal/core/fixtures/require_tree_files/file 2.rb +1 -0
- data/spec/opal/core/fixtures/require_tree_files/file 3.rb +1 -0
- data/spec/opal/core/fixtures/require_tree_files/file 4.rb +1 -0
- data/spec/opal/core/fixtures/require_tree_files/file 5.rb +1 -0
- data/spec/opal/core/fixtures/require_tree_files/nested/nested 1.rb +1 -0
- data/spec/opal/core/fixtures/require_tree_files/nested/nested 2.rb +1 -0
- data/spec/opal/core/fixtures/require_tree_files/other/other 1.rb +1 -0
- data/spec/opal/core/fixtures/require_tree_with_dot/file 1.rb +1 -0
- data/spec/opal/core/fixtures/require_tree_with_dot/file 2.rb +1 -0
- data/spec/opal/core/fixtures/require_tree_with_dot/file 3.rb +1 -0
- data/spec/opal/core/fixtures/require_tree_with_dot/index.rb +3 -0
- data/spec/opal/core/hash/internals_spec.rb +339 -0
- data/spec/opal/core/helpers_spec.rb +14 -0
- data/spec/opal/core/iterable_props_spec.rb +53 -0
- data/spec/opal/core/kernel/at_exit_spec.rb +70 -0
- data/spec/opal/core/kernel/freeze_spec.rb +15 -0
- data/spec/opal/core/kernel/instance_variables_spec.rb +110 -0
- data/spec/opal/core/kernel/methods_spec.rb +25 -0
- data/spec/opal/core/kernel/public_methods_spec.rb +25 -0
- data/spec/opal/core/kernel/require_tree_spec.rb +18 -0
- data/spec/opal/core/kernel/respond_to_spec.rb +15 -0
- data/spec/opal/core/language/DATA/characters_support_spec.rb +9 -0
- data/spec/opal/core/language/DATA/empty___END___spec.rb +7 -0
- data/spec/opal/core/language/DATA/multiple___END___spec.rb +10 -0
- data/spec/opal/core/language/arguments/mlhs_arg_spec.rb +18 -0
- data/spec/opal/core/language/keyword_arguments_spec.rb +9 -0
- data/spec/opal/core/language/numblocks_spec.rb +16 -0
- data/spec/opal/core/language/safe_navigator_spec.rb +7 -0
- data/spec/opal/core/language/while_spec.rb +31 -0
- data/spec/opal/core/language_spec.rb +29 -0
- data/spec/opal/core/marshal/dump_spec.rb +81 -0
- data/spec/opal/core/marshal/load_spec.rb +13 -0
- data/spec/opal/core/module_spec.rb +27 -0
- data/spec/opal/core/object_id_spec.rb +56 -0
- data/spec/opal/core/regexp/interpolation_spec.rb +40 -0
- data/spec/opal/core/regexp/match_spec.rb +78 -0
- data/spec/opal/core/runtime/bridged_classes_spec.rb +123 -0
- data/spec/opal/core/runtime/constants_spec.rb +16 -0
- data/spec/opal/core/runtime/eval_spec.rb +5 -0
- data/spec/opal/core/runtime/exit_spec.rb +29 -0
- data/spec/opal/core/runtime/is_a_spec.rb +48 -0
- data/spec/opal/core/runtime/loaded_spec.rb +20 -0
- data/spec/opal/core/runtime/main_methods_spec.rb +39 -0
- data/spec/opal/core/runtime/method_missing_spec.rb +68 -0
- data/spec/opal/core/runtime/rescue_spec.rb +37 -0
- data/spec/opal/core/runtime/string_spec.rb +25 -0
- data/spec/opal/core/runtime/truthy_spec.rb +61 -0
- data/spec/opal/core/runtime_spec.rb +58 -0
- data/spec/opal/core/string/each_byte_spec.rb +19 -0
- data/spec/opal/core/string/gsub_spec.rb +35 -0
- data/spec/opal/core/string/to_sym_spec.rb +9 -0
- data/spec/opal/core/string_spec.rb +28 -0
- data/spec/opal/core/struct/dup_spec.rb +11 -0
- data/spec/opal/core/time_spec.rb +68 -0
- data/spec/opal/stdlib/erb/erb_spec.rb +30 -0
- data/spec/opal/stdlib/erb/inline_block.opalerb +3 -0
- data/spec/opal/stdlib/erb/quoted.opalerb +1 -0
- data/spec/opal/stdlib/erb/simple.opalerb +1 -0
- data/spec/opal/stdlib/js_spec.rb +72 -0
- data/spec/opal/stdlib/json/ext_spec.rb +55 -0
- data/spec/opal/stdlib/json/parse_spec.rb +37 -0
- data/spec/opal/stdlib/logger/logger_spec.rb +308 -0
- data/spec/opal/stdlib/native/alias_native_spec.rb +27 -0
- data/spec/opal/stdlib/native/array_spec.rb +11 -0
- data/spec/opal/stdlib/native/date_spec.rb +12 -0
- data/spec/opal/stdlib/native/deprecated_include_spec.rb +8 -0
- data/spec/opal/stdlib/native/each_spec.rb +13 -0
- data/spec/opal/stdlib/native/element_reference_spec.rb +16 -0
- data/spec/opal/stdlib/native/exposure_spec.rb +33 -0
- data/spec/opal/stdlib/native/ext_spec.rb +19 -0
- data/spec/opal/stdlib/native/hash_spec.rb +67 -0
- data/spec/opal/stdlib/native/initialize_spec.rb +17 -0
- data/spec/opal/stdlib/native/method_missing_spec.rb +51 -0
- data/spec/opal/stdlib/native/native_alias_spec.rb +26 -0
- data/spec/opal/stdlib/native/native_class_spec.rb +18 -0
- data/spec/opal/stdlib/native/native_module_spec.rb +13 -0
- data/spec/opal/stdlib/native/native_reader_spec.rb +22 -0
- data/spec/opal/stdlib/native/native_writer_spec.rb +30 -0
- data/spec/opal/stdlib/native/new_spec.rb +92 -0
- data/spec/opal/stdlib/native/struct_spec.rb +12 -0
- data/spec/opal/stdlib/pp_spec.rb +5 -0
- data/spec/opal/stdlib/promise/always_spec.rb +49 -0
- data/spec/opal/stdlib/promise/error_spec.rb +15 -0
- data/spec/opal/stdlib/promise/rescue_spec.rb +53 -0
- data/spec/opal/stdlib/promise/then_spec.rb +79 -0
- data/spec/opal/stdlib/promise/trace_spec.rb +51 -0
- data/spec/opal/stdlib/promise/value_spec.rb +15 -0
- data/spec/opal/stdlib/promise/when_spec.rb +34 -0
- data/spec/opal/stdlib/source_map_spec.rb +8 -0
- data/spec/opal/stdlib/strscan/scan_spec.rb +11 -0
- data/spec/opal/stdlib/template/paths_spec.rb +10 -0
- data/spec/opal/stdlib/thread/mutex_spec.rb +40 -0
- data/spec/opal/stdlib/thread/thread_queue_spec.rb +32 -0
- data/spec/opal/stdlib/thread/thread_spec.rb +60 -0
- data/spec/ruby_specs +183 -0
- data/spec/spec_helper.rb +31 -0
- data/spec/support/guard_platform.rb +4 -0
- data/spec/support/match_helpers.rb +57 -0
- data/spec/support/mspec_rspec_adapter.rb +33 -0
- data/spec/support/rewriters_helper.rb +54 -0
- data/spec/support/source_map_helper.rb +190 -0
- data/stdlib/base64.rb +2 -2
- data/stdlib/bigdecimal.rb +15 -3
- data/stdlib/bigdecimal/bignumber.js.rb +1 -1
- data/stdlib/bigdecimal/util.rb +148 -0
- data/stdlib/delegate.rb +8 -0
- data/stdlib/nodejs/fileutils.rb +1 -1
- data/stdlib/nodejs/kernel.rb +0 -13
- data/stdlib/nodejs/stacktrace.rb +4 -179
- data/stdlib/ostruct.rb +5 -0
- data/stdlib/pp.rb +586 -19
- data/stdlib/prettyprint.rb +556 -0
- data/stdlib/rbconfig/sizeof.rb +2 -0
- data/stdlib/securerandom.rb +32 -0
- data/stdlib/set.rb +36 -0
- data/stdlib/strscan.rb +15 -0
- data/tasks/benchmarking.rake +1 -1
- data/tasks/releasing.rake +0 -3
- data/tasks/testing.rake +16 -11
- data/tasks/testing/mspec_special_calls.rb +1 -19
- data/test/nodejs/fixtures/cat.png +0 -0
- data/test/nodejs/fixtures/hello.rb +1 -0
- data/test/nodejs/fixtures/iso88591.txt +1 -0
- data/test/nodejs/fixtures/utf8.txt +1 -0
- data/test/nodejs/fixtures/win1258.txt +1 -0
- data/test/nodejs/test_dir.rb +39 -0
- data/test/nodejs/test_env.rb +62 -0
- data/test/nodejs/test_error.rb +29 -0
- data/test/nodejs/test_file.rb +206 -0
- data/test/nodejs/test_file_encoding.rb +20 -0
- data/test/nodejs/test_io.rb +18 -0
- data/test/nodejs/test_opal_builder.rb +12 -0
- data/test/nodejs/test_pathname.rb +16 -0
- data/test/opal/cat.png +0 -0
- data/test/opal/http_server.rb +52 -0
- data/test/opal/test_base64.rb +115 -0
- data/test/opal/test_keyword.rb +590 -0
- data/test/opal/test_matrix.rb +661 -0
- data/test/opal/test_openuri.rb +53 -0
- data/test/opal/unsupported_and_bugs.rb +39 -0
- data/yarn.lock +1114 -3
- metadata +889 -31
- data/lib/opal/nodes/runtime_helpers.rb +0 -51
- data/opal/corelib/random/MersenneTwister.js +0 -137
- data/opal/corelib/random/mersenne_twister.js.rb +0 -13
- data/stdlib/bigdecimal/kernel.rb +0 -5
data/UNRELEASED.md
CHANGED
@@ -1 +1,109 @@
|
|
1
|
+
### Added
|
1
2
|
|
3
|
+
- Basic support for `uplevel:` keyword argument in `Kernel#warn` (#2006)
|
4
|
+
- Added a `#respond_to_missing?` implementation for `BasicObject`, `Delegator`, `OpenStruct`, that's meant for future support in the Opal runtime, which currently ignores it (#2007)
|
5
|
+
- `Opal::Compiler#magic_comments` that allows to access magic-comments format and converts it to a hash (#2038)
|
6
|
+
- Use magic-comments to declare helpers required by the file (#2038)
|
7
|
+
- `Opal.$$` is now a shortcut for `Opal.const_get_relative` (#2038)
|
8
|
+
- `Opal.$$$` is now a shortcut for `Opal.const_get_qualified` (#2038)
|
9
|
+
- Added support for `globalThis` as the generic global object accessor (#2047)
|
10
|
+
- `Opal::Compiler#magic_comments` that allows to access magic-comments format and converts it to a hash
|
11
|
+
- Use magic-comments to declare helpers required by the file
|
12
|
+
- `Opal.$$` is now a shortcut for `Opal.const_get_relative`
|
13
|
+
- `Opal.$$$` is now a shortcut for `Opal.const_get_qualified`
|
14
|
+
- Source-map support for Node.js in the default runner (#2045)
|
15
|
+
- SecureRandom#hex(n) (#2050)
|
16
|
+
- Added a generic implementation of Kernel#caller and #warn(uplevel:) that works with sourcemaps in Node.js and Chrome (#2065)
|
17
|
+
- Added support for numblocks `-> { _1 + _2 }.call(3, 4) # => 7` (#2149)
|
18
|
+
- Support `<internal:…>` and `<js:…>` in stacktraces, like MRI we now distinguish internal lines from lib/app lines (#2154)
|
19
|
+
- `Array#difference`, `Array#intersection`, `Array#union` as aliases respectively to `Array#{-,&,|}` (#2151)
|
20
|
+
- Aliases `filter{,!}` to `select{,!}` throughout the corelib classes (#2151)
|
21
|
+
- `Enumerable#filter_map`, `Enumerable#tally` (#2151)
|
22
|
+
- Alias `Kernel#then` for `Kernel#yield_self` (#2151)
|
23
|
+
- Method chaining: `{Proc,Method}#{<<,>>}` (#2151)
|
24
|
+
- Added Integer#to_d (#2006)
|
25
|
+
- Added a compiler option `use_strict` which can also be set by the `use_strict` magic comment (#1959)
|
26
|
+
- Add `--rbrequire (-q)` option to `opal` command line executable (#2120)
|
27
|
+
|
28
|
+
### Fixed
|
29
|
+
|
30
|
+
- Array#delete_if (#2069)
|
31
|
+
- Array#keep_if (#2069)
|
32
|
+
- Array#reject! (#2069)
|
33
|
+
- Array#select! (#2069)
|
34
|
+
- Struct#dup (#1995)
|
35
|
+
- Integer#gcdlcm (#1972)
|
36
|
+
- Enumerable#to_h (#1979)
|
37
|
+
- Enumerator#size (#1980)
|
38
|
+
- Enumerable#min (#1982)
|
39
|
+
- Enumerable#min_by (#1985)
|
40
|
+
- Enumerable#max_by (#1985)
|
41
|
+
- Set#intersect? (#1988)
|
42
|
+
- Set#disjoint? (#1988)
|
43
|
+
- Set#keep_if (#1987)
|
44
|
+
- Set#select! (#1987)
|
45
|
+
- Set#reject! (#1987)
|
46
|
+
- String#unicode_normalize (#2175)
|
47
|
+
- Module#alias_method (#1983)
|
48
|
+
- Enumerable#minmax_by (#1981)
|
49
|
+
- Enumerator#each_with_index (#1990)
|
50
|
+
- Range#== (#1992)
|
51
|
+
- Range#each (#1991)
|
52
|
+
- Enumerable#zip (#1986)
|
53
|
+
- String#getbyte (#2141)
|
54
|
+
- Struct#dup not copying `$$data` (#1995)
|
55
|
+
- Fixed usage of semicolon in single-line backticks (#2004)
|
56
|
+
- Module#attr with multiple arguments (#2003)
|
57
|
+
- `PathReader` used to try to read missing files instead of respecting the `missing_require_severity` configuration value (#2044)
|
58
|
+
- Removed some unused variables from the runtime (#2052)
|
59
|
+
- Fixed a typo in the runtime (#2054)
|
60
|
+
- Fix Regexp interpolation, previously interpolating with other regexps was broken (#2062)
|
61
|
+
- Set match on StringScanner#skip and StringScanner#scan_until (#2061)
|
62
|
+
- Fix ruby 2.7 warnings (#2071)
|
63
|
+
- Improve the --help descriptions (#2146)
|
64
|
+
- Remove BasicObject#class (#2166)
|
65
|
+
- Time#strftime %j leading zeros (#2161)
|
66
|
+
- Fix `call { true or next }` producing invalid code (#2160)
|
67
|
+
- `define_method` can now be called on the main object (#2029)
|
68
|
+
- Fix nested for-loops (#2033)
|
69
|
+
- Fix Number#round for Integers (#2030)
|
70
|
+
- Fix parsing Unicode characters from Opal (#2073)
|
71
|
+
- Integer#===: improve Integer recognition (#2089)
|
72
|
+
- Regexp: ensure ignoreCase is never undefined (#2098)
|
73
|
+
- Hash#delete: ensure String keys are converted to values (#2106)
|
74
|
+
- Array#shift: improve performance on v8 >7.1 (#2115)
|
75
|
+
- Array#pop(1): improve performance (#2130)
|
76
|
+
- Object#pretty_inspect (#2139)
|
77
|
+
- Fix conversion from UTF-8 to bytes (#2138)
|
78
|
+
- Restore compatibility with Chrome 38, used by Cordova and many mobile browsers (#2109)
|
79
|
+
|
80
|
+
### Changed
|
81
|
+
|
82
|
+
- Updated outdated parser version (#2013)
|
83
|
+
- Nashorn has been deprecated but GraalVM still supports it (#1997)
|
84
|
+
- "opal/mini" now includes "opal/io" (#2002)
|
85
|
+
- Regexps assigned to constants are now frozen (#2007)
|
86
|
+
- `Opal.$$` changed from being the constant cache of Object to being a shortcut for `Opal.const_get_relative` (#2038)
|
87
|
+
- Moved REPL implementation from bin/ to its own lib/ file as `opal/repl.rb` (#2048)
|
88
|
+
- `Encoding.default_external` is now initialized with `__ENCODING__` (#2072)
|
89
|
+
- Keep the MersenneTwister implementation private (#2108)
|
90
|
+
- Change parser to 3.0 (#2148)
|
91
|
+
- Fix forwarding a rescued error to a global var: `rescue => $gvar` (#2154)
|
92
|
+
- Now using Parser v3.0 and targeting Ruby 3.0 (#2156)
|
93
|
+
- `Comparable#clamp` to support a Range argument (#2151)
|
94
|
+
- `#to_h` method to support a block (shortform for `.map(&block).to_h`) (#2151)
|
95
|
+
- BigDecimal is now a subclass of Numeric (#2006)
|
96
|
+
- PP to be rebased on upstream Ruby version (#2083)
|
97
|
+
- String to report UTF-8 encoding by default, as MRI does (#2117)
|
98
|
+
- Don't output "Failed to load WithCLexer, using pure Ruby lexer" warning unless in $DEBUG mode (#2174)
|
99
|
+
|
100
|
+
### Deprecated
|
101
|
+
|
102
|
+
- Requiring nodejs/stacktrace has been deprecated, source-maps are already
|
103
|
+
supported by the default Node.js runner or by requiring https://github.com/evanw/node-source-map-support
|
104
|
+
before loading code compiled by Opal (#2045)
|
105
|
+
|
106
|
+
### Removed
|
107
|
+
|
108
|
+
- Removed special compilation for the `Opal.truthy?` and `Opal.falsy?` helpers (#2076)
|
109
|
+
- Removed the deprecated `tainting` compiler config option (#2072)
|
@@ -0,0 +1,8 @@
|
|
1
|
+
Benchmark.ips do |x|
|
2
|
+
x.report('pop(1)') do
|
3
|
+
a = ['4768', '4964', '4266', '4872', '4231', '4017', '4565', '4793', '4298', '4135', '4639', '4780', '4237', '4548', '4655', '4153', '4654', '4922', '4563', '4042', '4329', '4699', '4352', '4127', '4544', '4906', '4814', '4948', '4977', '4830', '4405', '4642', '4666', '4402', '4679', '4465', '4401', '4155', '4767', '4510', '4747', '4993', '4508', '4697', '4758', '4133', '4348', '4200', '4442', '4970', '4452', '4041', '4103', '4567', '4937', '4047', '4933', '4121', '4860', '4659', '4221', '4312', '4583', '4473', '4973', '4262', '4630', '4123', '4139', '4289', '4147', '4222', '4050', '4019', '4454', '4253', '4552', '4947', '4725', '4457', '4929', '4021', '4502', '4307', '4576', '4124', '4586', '4610', '4027', '4572', '4926', '4753', '4185', '4382', '4394', '4923', '4186', '4254', '4012', '4417', '4556', '4349', '4550', '4330', '4938', '4985', '4778', '4716', '4924', '4045', '4358', '4189', '4591', '4213', '4851', '4825', '4260', '4198', '4342', '4824', '4333', '4244', '4752', '4994', '4488', '4532', '4082', '4595', '4098', '4436', '4540', '4267', '4407', '4998', '4751', '4535', '4861', '4819', '4419', '4031', '4029', '4453', '4698', '4965', '4450', '4668', '4036', '4300', '4519', '4281', '4981', '4818', '4939', '4378', '4140', '4841', '4249', '4290', '4388', '4878', '4884', '4235', '4515', '4638', '4410', '4054', '4383', '4238', '4870', '4295', '4804', '4308', '4614', '4105', '4053', '4446', '4757', '4971', '4637', '4831', '4193', '4912', '4000', '4187', '4606', '4566', '4169', '4641', '4749', '4729', '4928', '4601', '4949', '4210', '4313', '4647', '4495', '4460', '4621', '4605', '4694', '4317', '4226', '4263', '4016', '4997', '4940', '4715', '4907', '4620', '4934', '4996', '4955', '4688', '4304', '4220', '4882', '4772', '4536', '4815', '4693', '4469', '4276', '4409', '4071', '4224', '4020', '4629', '4865', '4813', '4366', '4622', '4129', '4533', '4634', '4564', '4087', '4386', '4161', '4265', '4711', '4009', '4376', '4781', '4837', '4112', '4915', '4592', '4658', '4025', '4987', '4291', '4477', '4503', '4437', '4111', '4707', '4879', '4611', '4549', '4078', '4044', '4853', '4835', '4463', '4577', '4008', '4233', '4741', '4384', '4225', '4024', '4726', '4743', '4160', '4180', '4722', '4609', '4114', '4834', '4742', '4662', '4984', '4299', '4060', '4498', '4755', '4320', '4874', '4528', '4216', '4852', '4951', '4958', '4283', '4239', '4476', '4644', '4143', '4104', '4455', '4126', '4950', '4663', '4013', '4931', '4850', '4242', '4130', '4623', '4871', '4014', '4854', '4293', '4512', '4166', '4740', '4735', '4150', '4651', '4172', '4836', '4530', '4664', '4429', '4511', '4558', '4676', '4085', '4074', '4580', '4794', '4379', '4310', '4817', '4966', '4848', '4202', '4336', '4608', '4351', '4396', '4652', '4033', '4188', '4431', '4916', '4259', '4607', '4816', '4810', '4627', '4527', '4560', '4728', '4589', '4274', '4809', '4790', '4398', '4414', '4516', '4581', '4919', '4665', '4331', '4978', '4543', '4877', '4974', '4284', '4004', '4177', '4466', '4116', '4217', '4901', '4372', '4137', '4806', '4264', '4497', '4294', '4787', '4212', '4215', '4115', '4782', '4739', '4821', '4125', '4505', '4230', '4399', '4395', '4079', '4867', '4381', '4706', '4695', '4404', '4691', '4075', '4353', '4301', '4876', '4731', '4523', '4246', '4529', '4412', '4784', '4449', '4229', '4616', '4158', '4002', '4318', '4377', '4205', '4911', '4777', '4792', '4271', '4763', '4141', '4287', '4890', '4279', '4829', '4646', '4840', '4089', '4880', '4067', '4918', '4059', '4109', '4164', '4863', '4883', '4909', '4361', '4174', '4960', '4302', '4003', '4236', '4846', '4034', '4324', '4513', '4765', '4596', '4900', '4007', '4603', '4474', '4439', '4805', '4015', '4496', '4953', '4363', '4551', '4459', '4063', '4983', '4881', '4365', '4604', '4587', '4798', '4005', '4163', '4421', '4471', '4826', '4144', '4635', '4600', '4913', '4640', '4247', '4766', '4779', '4280', '4391', '4891', '4636', '4546', '4683', '4181', '4081', '4862', '4458', '4037', '4321', '4786', '4717', '4628', '4154', '4326', '4032', '4873', '4151', '4905', '4270', '4156', '4733', '4980', '4866', '4325', '4055', '4467', '4480', '4286', '4191', '4762', '4322', '4574', '4022', '4056', '4770', '4451', '4448', '4845', '4341', '4433', '4245', '4684', '4671', '4093', '4920', '4272', '4745', '4799', '4761', '4250', '4578', '4347', '4499', '4526', '4369', '4162', '4537', '4434', '4893', '4120', '4962', '4667', '4525', '4091', '4462', '4182', '4738', '4935', '4173', '4490', '4571', '4424', '4894', '4051', '4214', '4823', '4096', '4206', '4598', '4943', '4701', '4649', '4807', '4107', '4435', '4456', '4083', '4612', '4721', '4472', '4146', '4925', '4340', '4789', '4277', '4375', '4211', '4427', '4547', '4690', '4613', '4727', '4006', '4203', '4430', '4223', '4039', '4932', '4296', '4108', '4278', '4832', '4422', '4917', '4470', '4183', '4887', '4076', '4485', '4597', '4443', '4257', '4991', '4944', '4196', '4672', '4397', '4097', '4119', '4077', '4773', '4602', '4538', '4479', '4968', '4159', '4539', '4956', '4710', '4812', '4902', '4569', '4954', '4385', '4128', '4936', '4416', '4148', '4632', '4759', '4117', '4896', '4392', '4864', '4316', '4132', '4319', '4969', '4175', '4484', '4903', '4910', '4350', '4332', '4952', '4176', '4594', '4709', '4509', '4178', '4167', '4545', '4857', '4617', '4501', '4859', '4207', '4275', '4687', '4049', '4579', '4046', '4921', '4113', '4898', '4681', '4052', '4415', '4064', '4184', '4895', '4744', '4685', '4084', '4305', '4899', '4559', '4208', '4057', '4507', '4258', '4355', '4086', '4373', '4323', '4541', '4297', '4483', '4889', '4531', '4327', '4441', '4914', '4303', '4677', '4445', '4802', '4343', '4585', '4338', '4524', '4590', '4624', '4288', '4704', '4134', '4043', '4720', '4058', '4328', '4095', '4026', '4423', '4657', '4118', '4633', '4487', '4822', '4904', '4255', '4001', '4387', '4500', '4190', '4686', '4995', '4661', '4783', '4992', '4165', '4065', '4927', '4306', '4856', '4292', '4420', '4963', '4468', '4240', '4724', '4432', '4447', '4518', '4028', '4670', '4339', '4771', '4018', '4489', '4110', '4708', '4945', '4136', '4492', '4930', '4090', '4734', '4886', '4542', '4227', '4486', '4491', '4713', '4986', '4068', '4048', '4975', '4570', '4842', '4475', '4131', '4555', '4428', '4776', '4101', '4273', '4811', '4345', '5000', '4653', '4256', '4209', '4769', '4946', '4561', '4080', '4461', '4820', '4311', '4959', '4750', '4795', '4748', '4368', '4506', '4335', '4346', '4568', '4675', '4692', '4774', '4413', '4370', '4723', '4521', '4885', '4678', '4897', '4066', '4674', '4106', '4626', '4389', '4204', '4839', '4023', '4712', '4145', '4035', '4357', '4756', '4648', '4972', '4157', '4406', '4615', '4061', '4219', '4791', '4660', '4073', '4356', '4072', '4599', '4359', '4094', '4673', '4696', '4796', '4282', '4714', '4522', '4736', '4775', '4760', '4400', '4847', '4228', '4803', '4908', '4732', '4645', '4122', '4218', '4478', '4941', '4892', '4364', '4403', '4152', '4444', '4360', '4354', '4241', '4494', '4367', '4808', '4261', '4088', '4573', '4554', '4248', '4371', '4393', '4268', '4201', '4038', '4788', '4593', '4040', '4801', '4582', '4309', '4976', '4374', '4869', '4380', '4514', '4243', '4362', '4849', '4680', '4888', '4764', '4618', '4838', '4828', '4643', '4010', '4827', '4957', '4099', '4875', '4843', '4737', '4102', '4979', '4011', '4504', '4440', '4746', '4557', '4426', '4553', '4656', '4868', '4689', '4988', '4703', '4967', '4069', '4619', '4334', '4669', '4785', '4464', '4562', '4961', '4625', '4754', '4797', '4481', '4705', '4199', '4337', '4062', '4138', '4702', '4534', '4168', '4418', '4092', '4682', '4520', '4030', '4171', '4650', '4858', '4411', '4999', '4252', '4197', '4170', '4942', '4631', '4990', '4179', '4285', '4700', '4482', '4575', '4800', '4070', '4251', '4344', '4982', '4719', '4390', '4149', '4100', '4194', '4269', '4855', '4314', '4718', '4232', '4730', '4438', '4588', '4195', '4192', '4493', '4517', '4833', '4234', '4989', '4315', '4844', '4142', '4408', '4584', '4425']
|
4
|
+
a.pop(1)
|
5
|
+
end
|
6
|
+
|
7
|
+
x.compare!
|
8
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
Benchmark.ips do |x|
|
2
|
+
x.report("shift no arg") do
|
3
|
+
a = ['4768', '4964', '4266', '4872', '4231', '4017', '4565', '4793', '4298', '4135', '4639', '4780', '4237', '4548', '4655', '4153', '4654', '4922', '4563', '4042', '4329', '4699', '4352', '4127', '4544', '4906', '4814', '4948', '4977', '4830', '4405', '4642', '4666', '4402', '4679', '4465', '4401', '4155', '4767', '4510', '4747', '4993', '4508', '4697', '4758', '4133', '4348', '4200', '4442', '4970', '4452', '4041', '4103', '4567', '4937', '4047', '4933', '4121', '4860', '4659', '4221', '4312', '4583', '4473', '4973', '4262', '4630', '4123', '4139', '4289', '4147', '4222', '4050', '4019', '4454', '4253', '4552', '4947', '4725', '4457', '4929', '4021', '4502', '4307', '4576', '4124', '4586', '4610', '4027', '4572', '4926', '4753', '4185', '4382', '4394', '4923', '4186', '4254', '4012', '4417', '4556', '4349', '4550', '4330', '4938', '4985', '4778', '4716', '4924', '4045', '4358', '4189', '4591', '4213', '4851', '4825', '4260', '4198', '4342', '4824', '4333', '4244', '4752', '4994', '4488', '4532', '4082', '4595', '4098', '4436', '4540', '4267', '4407', '4998', '4751', '4535', '4861', '4819', '4419', '4031', '4029', '4453', '4698', '4965', '4450', '4668', '4036', '4300', '4519', '4281', '4981', '4818', '4939', '4378', '4140', '4841', '4249', '4290', '4388', '4878', '4884', '4235', '4515', '4638', '4410', '4054', '4383', '4238', '4870', '4295', '4804', '4308', '4614', '4105', '4053', '4446', '4757', '4971', '4637', '4831', '4193', '4912', '4000', '4187', '4606', '4566', '4169', '4641', '4749', '4729', '4928', '4601', '4949', '4210', '4313', '4647', '4495', '4460', '4621', '4605', '4694', '4317', '4226', '4263', '4016', '4997', '4940', '4715', '4907', '4620', '4934', '4996', '4955', '4688', '4304', '4220', '4882', '4772', '4536', '4815', '4693', '4469', '4276', '4409', '4071', '4224', '4020', '4629', '4865', '4813', '4366', '4622', '4129', '4533', '4634', '4564', '4087', '4386', '4161', '4265', '4711', '4009', '4376', '4781', '4837', '4112', '4915', '4592', '4658', '4025', '4987', '4291', '4477', '4503', '4437', '4111', '4707', '4879', '4611', '4549', '4078', '4044', '4853', '4835', '4463', '4577', '4008', '4233', '4741', '4384', '4225', '4024', '4726', '4743', '4160', '4180', '4722', '4609', '4114', '4834', '4742', '4662', '4984', '4299', '4060', '4498', '4755', '4320', '4874', '4528', '4216', '4852', '4951', '4958', '4283', '4239', '4476', '4644', '4143', '4104', '4455', '4126', '4950', '4663', '4013', '4931', '4850', '4242', '4130', '4623', '4871', '4014', '4854', '4293', '4512', '4166', '4740', '4735', '4150', '4651', '4172', '4836', '4530', '4664', '4429', '4511', '4558', '4676', '4085', '4074', '4580', '4794', '4379', '4310', '4817', '4966', '4848', '4202', '4336', '4608', '4351', '4396', '4652', '4033', '4188', '4431', '4916', '4259', '4607', '4816', '4810', '4627', '4527', '4560', '4728', '4589', '4274', '4809', '4790', '4398', '4414', '4516', '4581', '4919', '4665', '4331', '4978', '4543', '4877', '4974', '4284', '4004', '4177', '4466', '4116', '4217', '4901', '4372', '4137', '4806', '4264', '4497', '4294', '4787', '4212', '4215', '4115', '4782', '4739', '4821', '4125', '4505', '4230', '4399', '4395', '4079', '4867', '4381', '4706', '4695', '4404', '4691', '4075', '4353', '4301', '4876', '4731', '4523', '4246', '4529', '4412', '4784', '4449', '4229', '4616', '4158', '4002', '4318', '4377', '4205', '4911', '4777', '4792', '4271', '4763', '4141', '4287', '4890', '4279', '4829', '4646', '4840', '4089', '4880', '4067', '4918', '4059', '4109', '4164', '4863', '4883', '4909', '4361', '4174', '4960', '4302', '4003', '4236', '4846', '4034', '4324', '4513', '4765', '4596', '4900', '4007', '4603', '4474', '4439', '4805', '4015', '4496', '4953', '4363', '4551', '4459', '4063', '4983', '4881', '4365', '4604', '4587', '4798', '4005', '4163', '4421', '4471', '4826', '4144', '4635', '4600', '4913', '4640', '4247', '4766', '4779', '4280', '4391', '4891', '4636', '4546', '4683', '4181', '4081', '4862', '4458', '4037', '4321', '4786', '4717', '4628', '4154', '4326', '4032', '4873', '4151', '4905', '4270', '4156', '4733', '4980', '4866', '4325', '4055', '4467', '4480', '4286', '4191', '4762', '4322', '4574', '4022', '4056', '4770', '4451', '4448', '4845', '4341', '4433', '4245', '4684', '4671', '4093', '4920', '4272', '4745', '4799', '4761', '4250', '4578', '4347', '4499', '4526', '4369', '4162', '4537', '4434', '4893', '4120', '4962', '4667', '4525', '4091', '4462', '4182', '4738', '4935', '4173', '4490', '4571', '4424', '4894', '4051', '4214', '4823', '4096', '4206', '4598', '4943', '4701', '4649', '4807', '4107', '4435', '4456', '4083', '4612', '4721', '4472', '4146', '4925', '4340', '4789', '4277', '4375', '4211', '4427', '4547', '4690', '4613', '4727', '4006', '4203', '4430', '4223', '4039', '4932', '4296', '4108', '4278', '4832', '4422', '4917', '4470', '4183', '4887', '4076', '4485', '4597', '4443', '4257', '4991', '4944', '4196', '4672', '4397', '4097', '4119', '4077', '4773', '4602', '4538', '4479', '4968', '4159', '4539', '4956', '4710', '4812', '4902', '4569', '4954', '4385', '4128', '4936', '4416', '4148', '4632', '4759', '4117', '4896', '4392', '4864', '4316', '4132', '4319', '4969', '4175', '4484', '4903', '4910', '4350', '4332', '4952', '4176', '4594', '4709', '4509', '4178', '4167', '4545', '4857', '4617', '4501', '4859', '4207', '4275', '4687', '4049', '4579', '4046', '4921', '4113', '4898', '4681', '4052', '4415', '4064', '4184', '4895', '4744', '4685', '4084', '4305', '4899', '4559', '4208', '4057', '4507', '4258', '4355', '4086', '4373', '4323', '4541', '4297', '4483', '4889', '4531', '4327', '4441', '4914', '4303', '4677', '4445', '4802', '4343', '4585', '4338', '4524', '4590', '4624', '4288', '4704', '4134', '4043', '4720', '4058', '4328', '4095', '4026', '4423', '4657', '4118', '4633', '4487', '4822', '4904', '4255', '4001', '4387', '4500', '4190', '4686', '4995', '4661', '4783', '4992', '4165', '4065', '4927', '4306', '4856', '4292', '4420', '4963', '4468', '4240', '4724', '4432', '4447', '4518', '4028', '4670', '4339', '4771', '4018', '4489', '4110', '4708', '4945', '4136', '4492', '4930', '4090', '4734', '4886', '4542', '4227', '4486', '4491', '4713', '4986', '4068', '4048', '4975', '4570', '4842', '4475', '4131', '4555', '4428', '4776', '4101', '4273', '4811', '4345', '5000', '4653', '4256', '4209', '4769', '4946', '4561', '4080', '4461', '4820', '4311', '4959', '4750', '4795', '4748', '4368', '4506', '4335', '4346', '4568', '4675', '4692', '4774', '4413', '4370', '4723', '4521', '4885', '4678', '4897', '4066', '4674', '4106', '4626', '4389', '4204', '4839', '4023', '4712', '4145', '4035', '4357', '4756', '4648', '4972', '4157', '4406', '4615', '4061', '4219', '4791', '4660', '4073', '4356', '4072', '4599', '4359', '4094', '4673', '4696', '4796', '4282', '4714', '4522', '4736', '4775', '4760', '4400', '4847', '4228', '4803', '4908', '4732', '4645', '4122', '4218', '4478', '4941', '4892', '4364', '4403', '4152', '4444', '4360', '4354', '4241', '4494', '4367', '4808', '4261', '4088', '4573', '4554', '4248', '4371', '4393', '4268', '4201', '4038', '4788', '4593', '4040', '4801', '4582', '4309', '4976', '4374', '4869', '4380', '4514', '4243', '4362', '4849', '4680', '4888', '4764', '4618', '4838', '4828', '4643', '4010', '4827', '4957', '4099', '4875', '4843', '4737', '4102', '4979', '4011', '4504', '4440', '4746', '4557', '4426', '4553', '4656', '4868', '4689', '4988', '4703', '4967', '4069', '4619', '4334', '4669', '4785', '4464', '4562', '4961', '4625', '4754', '4797', '4481', '4705', '4199', '4337', '4062', '4138', '4702', '4534', '4168', '4418', '4092', '4682', '4520', '4030', '4171', '4650', '4858', '4411', '4999', '4252', '4197', '4170', '4942', '4631', '4990', '4179', '4285', '4700', '4482', '4575', '4800', '4070', '4251', '4344', '4982', '4719', '4390', '4149', '4100', '4194', '4269', '4855', '4314', '4718', '4232', '4730', '4438', '4588', '4195', '4192', '4493', '4517', '4833', '4234', '4989', '4315', '4844', '4142', '4408', '4584', '4425']
|
4
|
+
a.shift
|
5
|
+
end
|
6
|
+
x.compare!
|
7
|
+
end
|
data/bin/format-filters
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
sort_lines = -> lines {
|
4
|
+
lines.sort.uniq { |l| l.split('" # ', 2).first }
|
5
|
+
}
|
6
|
+
|
7
|
+
write_group = ->(title:, lines:, type:) {
|
8
|
+
%{#{type} "#{title}" do\n}+
|
9
|
+
sort_lines[lines].join+
|
10
|
+
%{end\n}
|
11
|
+
}
|
12
|
+
|
13
|
+
write_groups = -> groups {
|
14
|
+
%{# NOTE: run bin/format-filters after changing this file\n}+
|
15
|
+
groups.map.with_index do |group, index|
|
16
|
+
puts "- #{group[:type]} #{group[:title].inspect}..."
|
17
|
+
("\n" if index > 0).to_s + write_group.call(**group)
|
18
|
+
end.join
|
19
|
+
}
|
20
|
+
|
21
|
+
group_lines = -> lines {
|
22
|
+
groups = []
|
23
|
+
group = nil
|
24
|
+
lines.each do |line|
|
25
|
+
case line
|
26
|
+
when /^(opal_(?:unsupported_)?filter) *"([^"]+)" *do *\n/
|
27
|
+
raise "bad group for #{line.inspect}!" if group
|
28
|
+
|
29
|
+
group = {
|
30
|
+
type: $1,
|
31
|
+
title: $2,
|
32
|
+
lines: []
|
33
|
+
}
|
34
|
+
|
35
|
+
when /^ fails/
|
36
|
+
group[:lines] << line
|
37
|
+
|
38
|
+
when /^end/
|
39
|
+
groups << group
|
40
|
+
group = nil
|
41
|
+
end
|
42
|
+
end
|
43
|
+
groups
|
44
|
+
}
|
45
|
+
|
46
|
+
format_filter = -> path {
|
47
|
+
File.write path, write_groups[group_lines[File.read(path).lines]]
|
48
|
+
}
|
49
|
+
|
50
|
+
Dir['spec/filters/**/*.rb'].each do |path|
|
51
|
+
puts
|
52
|
+
puts "Formatting #{path} ..."
|
53
|
+
format_filter[path]
|
54
|
+
end
|
data/bin/remove-filters
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# This is an utility to automatically remove a group of filters provided
|
3
|
+
# to its standard input.
|
4
|
+
#
|
5
|
+
# This utility is to assist with removing a large group of filters spread
|
6
|
+
# around multiple files that is being output by a command:
|
7
|
+
#
|
8
|
+
# rake mspec_ruby_nodejs RUBYSPECS=true INVERT_RUNNING_MODE=true
|
9
|
+
#
|
10
|
+
# It expects an input of format:
|
11
|
+
# 1) "Set#filter! returns an Enumerator when passed no block"
|
12
|
+
# 2) "Set#filter! yields every element of self"
|
13
|
+
# 3) "Set#filter! keeps every element from self for which the passed block returns true"
|
14
|
+
# 4) "Set#filter! returns self when self was modified"
|
15
|
+
# 5) "Set#filter! returns nil when self was not modified"
|
16
|
+
|
17
|
+
filters = $stdin.read.split("\n").map do |i|
|
18
|
+
# This special example should be rather moved to unsupported for now...
|
19
|
+
next if i =~ /formats the local time following the pattern/
|
20
|
+
|
21
|
+
i.scan(/\d+\) (".*")/).first.first
|
22
|
+
end.compact
|
23
|
+
filters = Regexp.union(*filters)
|
24
|
+
|
25
|
+
remove_filters = -> path {
|
26
|
+
file = File.read(path).split("\n")
|
27
|
+
|
28
|
+
remove, good = file.partition { |i| i =~ filters }
|
29
|
+
|
30
|
+
if remove.length > 0
|
31
|
+
puts "Removing #{remove.length} filters from #{path}"
|
32
|
+
|
33
|
+
File.write(path, good.join("\n")+"\n")
|
34
|
+
end
|
35
|
+
}
|
36
|
+
|
37
|
+
Dir['spec/filters/**/*.rb'].each do |path|
|
38
|
+
remove_filters[path]
|
39
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
# Using Opal with Roda and Sprockets
|
2
|
+
|
3
|
+
Add Opal-Sprockets and Roda-Sprockets to your Gemfile (or install using `gem`):
|
4
|
+
|
5
|
+
```ruby
|
6
|
+
# Gemfile
|
7
|
+
gem "opal-sprockets"
|
8
|
+
gem "roda-sprockets"
|
9
|
+
gem "puma"
|
10
|
+
```
|
11
|
+
|
12
|
+
Roda-Sprockets uses `sprockets` as its default build system, so the asset-pipeline
|
13
|
+
from rails can be mimicked here to map all ruby assets in the `/assets`
|
14
|
+
path to be compiled using opal.
|
15
|
+
|
16
|
+
## Basic Application
|
17
|
+
|
18
|
+
```ruby
|
19
|
+
# config.ru
|
20
|
+
require 'roda'
|
21
|
+
|
22
|
+
class App < Roda
|
23
|
+
plugin :sprockets, precompile: %w(application.js),
|
24
|
+
prefix: %w(app/),
|
25
|
+
root: __dir__,
|
26
|
+
public_path: 'public/',
|
27
|
+
opal: true,
|
28
|
+
debug: ENV['RACK_ENV'] != 'production'
|
29
|
+
plugin :public
|
30
|
+
|
31
|
+
route do |r|
|
32
|
+
r.public
|
33
|
+
r.sprockets
|
34
|
+
|
35
|
+
r.root do
|
36
|
+
<<~END
|
37
|
+
<!doctype html>
|
38
|
+
<html>
|
39
|
+
<head>
|
40
|
+
#{ javascript_tag 'application' }
|
41
|
+
#{ opal_require 'application' }
|
42
|
+
</head>
|
43
|
+
</html>
|
44
|
+
END
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
run App.app
|
50
|
+
|
51
|
+
```
|
52
|
+
|
53
|
+
This creates a sprockets instance under the `/assets` path, serving Opal assets
|
54
|
+
from `app/` with all the custom opal paths added automatically.
|
55
|
+
|
56
|
+
This `env` object includes all the opal corelib and stdlib paths. To add
|
57
|
+
any custom application directories, you must add them to the load path using
|
58
|
+
`Opal.append_path` or adding them to the `prefix` parameter. You can now add
|
59
|
+
an `app/application.rb` file into this added path with some basic content:
|
60
|
+
|
61
|
+
```ruby
|
62
|
+
# app/application.rb
|
63
|
+
require 'opal'
|
64
|
+
|
65
|
+
puts "wow, running ruby!"
|
66
|
+
```
|
67
|
+
|
68
|
+
It is necessary to require the opal corelib (seen in the `require` call) above.
|
69
|
+
This just makes the Opal runtime and corelib available. Then it is possible to
|
70
|
+
use all the corelib methods and classes, e.g. `Kernel#puts` as seen above.
|
71
|
+
|
72
|
+
### Running Application
|
73
|
+
|
74
|
+
As this is just a simple Roda application, you can run it:
|
75
|
+
|
76
|
+
```sh
|
77
|
+
$ bundle exec rackup
|
78
|
+
```
|
79
|
+
|
80
|
+
And point your browser towards `http://localhost:9292/` and view the browser
|
81
|
+
debug console. You should see this message printed.
|
82
|
+
|
83
|
+
### Extending the integration
|
84
|
+
|
85
|
+
It's possible to extend this integration, for that please look into the
|
86
|
+
[roda-sprockets documentation](https://github.com/hmdne/roda-sprockets)
|
data/docs/sinatra.md
CHANGED
@@ -4,8 +4,11 @@ Add Opal-Sprockets to your Gemfile (or install using `gem`):
|
|
4
4
|
|
5
5
|
```ruby
|
6
6
|
# Gemfile
|
7
|
+
source 'https://rubygems.org'
|
8
|
+
|
7
9
|
gem 'sinatra'
|
8
10
|
gem 'opal-sprockets'
|
11
|
+
gem 'puma'
|
9
12
|
```
|
10
13
|
|
11
14
|
Opal-Sprockets uses `sprockets` as its default build system, so the asset-pipeline
|
@@ -22,17 +25,9 @@ require 'sinatra'
|
|
22
25
|
opal = Opal::Sprockets::Server.new {|s|
|
23
26
|
s.append_path 'app'
|
24
27
|
s.main = 'application'
|
28
|
+
s.debug = ENV['RACK_ENV'] != 'production'
|
25
29
|
}
|
26
30
|
|
27
|
-
maps_prefix = Opal::Sprockets::Server::SOURCE_MAPS_PREFIX_PATH
|
28
|
-
maps_app = Opal::SourceMapServer.new(opal.sprockets, maps_prefix)
|
29
|
-
|
30
|
-
map maps_prefix do
|
31
|
-
use Rack::ConditionalGet
|
32
|
-
use Rack::ETag
|
33
|
-
run maps_app
|
34
|
-
end
|
35
|
-
|
36
31
|
map '/assets' do
|
37
32
|
run opal.sprockets
|
38
33
|
end
|
@@ -42,9 +37,7 @@ get '/' do
|
|
42
37
|
<!doctype html>
|
43
38
|
<html>
|
44
39
|
<head>
|
45
|
-
|
46
|
-
<script src="/assets/application.self.js"></script>
|
47
|
-
<script type="text/javascript">Opal.load("application")</script>
|
40
|
+
#{ Opal::Sprockets.javascript_include_tag('application', debug: opal.debug, sprockets: opal.sprockets, prefix: 'assets/' ) }
|
48
41
|
</head>
|
49
42
|
</html>
|
50
43
|
HTML
|
data/examples/rack/Gemfile
CHANGED
data/examples/rack/config.ru
CHANGED
@@ -2,19 +2,20 @@ require 'bundler'
|
|
2
2
|
Bundler.require
|
3
3
|
|
4
4
|
# Instructions: bundle in this directory
|
5
|
-
# then run bundle exec rackup to start the server
|
6
|
-
# and browse to localhost:9292
|
5
|
+
# then run `bundle exec rackup` to start the server
|
6
|
+
# and browse to http://localhost:9292
|
7
7
|
|
8
8
|
# a very small application that just tries to authenticate a user and fails
|
9
9
|
# it just writes to the console in the browser (no visible html)
|
10
10
|
|
11
11
|
# with gems like opal-jquery or opal-browser you could manipulate the dom directly
|
12
12
|
|
13
|
+
# the directory where the code is (add to opal load path )
|
14
|
+
Opal.append_path 'app'
|
15
|
+
|
13
16
|
run Opal::SimpleServer.new { |s|
|
14
17
|
# the name of the ruby file to load. To use more files they must be required from here (see app)
|
15
18
|
s.main = 'application'
|
16
|
-
# the directory where the code is (add to opal load path )
|
17
|
-
s.append_path 'app'
|
18
19
|
# need to set the index explicitly for opal server to pick it up
|
19
20
|
s.index_path = 'index.html.erb'
|
20
21
|
}
|
data/exe/opal-repl
CHANGED
@@ -1,86 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require 'opal'
|
3
|
+
require 'opal/repl'
|
4
4
|
|
5
|
-
|
6
|
-
class V8Context
|
7
|
-
def initialize
|
8
|
-
@builder = Opal::Builder.new
|
9
|
-
@history_path = File.expand_path('~/.opal-repl-history')
|
10
|
-
@history = File.exist?(@history_path)
|
11
|
-
end
|
12
|
-
|
13
|
-
def run(filename = nil)
|
14
|
-
return if @v8
|
15
|
-
|
16
|
-
begin
|
17
|
-
require 'mini_racer'
|
18
|
-
rescue LoadError
|
19
|
-
abort 'opal-repl depends on mini_racer gem, which is not currently installed'
|
20
|
-
end
|
21
|
-
|
22
|
-
@v8 = MiniRacer::Context.new
|
23
|
-
@v8.eval Opal::Builder.new.build('opal').to_s
|
24
|
-
|
25
|
-
if filename
|
26
|
-
if File.exist? filename
|
27
|
-
eval_ruby File.read(filename)
|
28
|
-
else
|
29
|
-
fail "file does not exist: #{filename}"
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
run_repl
|
34
|
-
end
|
35
|
-
|
36
|
-
def log(*str)
|
37
|
-
puts(*str)
|
38
|
-
end
|
39
|
-
|
40
|
-
def run_repl
|
41
|
-
require 'readline'
|
42
|
-
load_history
|
43
|
-
|
44
|
-
loop do
|
45
|
-
# on SIGINT lets just return from the loop..
|
46
|
-
trap('SIGINT') { finish; return }
|
47
|
-
line = Readline.readline '>> ', true
|
48
|
-
|
49
|
-
# if we type exit, then we need to close down context
|
50
|
-
if line == 'exit' or line.nil?
|
51
|
-
break
|
52
|
-
end
|
53
|
-
|
54
|
-
puts "=> #{eval_ruby line}"
|
55
|
-
end
|
56
|
-
|
57
|
-
finish
|
58
|
-
end
|
59
|
-
|
60
|
-
def eval_ruby(str)
|
61
|
-
code = Opal::Builder.new.build_str(str, '(irb)', :irb => true, :const_missing => true)
|
62
|
-
code.processed[0...-1].each { |c| @v8.eval(c.to_s) }
|
63
|
-
@v8.eval "var $_result = #{code.processed.last.to_s} ($_result == null ? 'nil' : $_result.$inspect());"
|
64
|
-
rescue Exception => e
|
65
|
-
puts "#{e.message}\n\t#{e.backtrace.join("\n\t")}"
|
66
|
-
end
|
67
|
-
|
68
|
-
def load_history
|
69
|
-
return unless @history
|
70
|
-
File.read(@history_path).lines.each { |line| Readline::HISTORY.push line.strip }
|
71
|
-
end
|
72
|
-
|
73
|
-
def dump_history
|
74
|
-
return unless @history
|
75
|
-
length = (Readline::HISTORY.size > 1000) ? 1000 : Readline::HISTORY.size
|
76
|
-
File.write(@history_path, Readline::HISTORY.to_a[-length..-1].join("\n"))
|
77
|
-
end
|
78
|
-
|
79
|
-
def finish
|
80
|
-
dump_history
|
81
|
-
@v8 = nil
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
Opal::V8Context.new.run ARGV.first
|
5
|
+
repl = Opal::REPL.new.run ARGV.first
|