repo stringlengths 5 92 | file_url stringlengths 80 287 | file_path stringlengths 5 197 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 15:37:27 2026-01-04 17:58:21 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/spec/lib/rewriters/base_spec.rb | spec/lib/rewriters/base_spec.rb | require 'lib/spec_helper'
require 'support/rewriters_helper'
require 'opal/rewriters/base'
RSpec.describe Opal::Rewriters::Base do
include RewritersHelper
def body_ast_of(method_source)
def_ast = parse_without_rewriting(method_source).children.first
_, _, body_ast = *def_ast
body_ast
end
let(:nod... | ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/spec/lib/rewriters/logical_operator_assignment_spec.rb | spec/lib/rewriters/logical_operator_assignment_spec.rb | require 'lib/spec_helper'
require 'support/rewriters_helper'
RSpec.describe Opal::Rewriters::LogicalOperatorAssignment do
include RewritersHelper
use_only_described_rewriter!
before(:each) { Opal::Rewriters::LogicalOperatorAssignment.reset_tmp_counter! }
let(:cache_tmp_name) { :$logical_op_recvr_tmp_1 }
le... | ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/spec/lib/rewriters/hashes/key_duplicates_rewriter_spec.rb | spec/lib/rewriters/hashes/key_duplicates_rewriter_spec.rb | require 'lib/spec_helper'
require 'support/rewriters_helper'
require 'opal/rewriters/hashes/key_duplicates_rewriter'
RSpec.describe Opal::Rewriters::Hashes::KeyDuplicatesRewriter do
include RewritersHelper
shared_examples 'it warns' do |code, key_to_warn|
context "for #{code} code" do
it "warns about #{... | ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/spec/lib/rewriters/rubyspec/filters_rewriter_spec.rb | spec/lib/rewriters/rubyspec/filters_rewriter_spec.rb | require 'lib/spec_helper'
require 'opal/rewriters/rubyspec/filters_rewriter'
require 'support/rewriters_helper'
RSpec.describe Opal::Rubyspec::FiltersRewriter do
include RewritersHelper
let(:source) do
<<-SOURCE
describe 'User#email' do
context 'when this' do
it 'does that'
... | ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/spec/lib/cli_runners/server_spec.rb | spec/lib/cli_runners/server_spec.rb | require 'lib/spec_helper'
require 'opal/cli_runners'
require 'rack/test'
RSpec.describe Opal::CliRunners::Server do
include Rack::Test::Methods
def app
@app
end
it 'starts a server for the given code' do
expect(Rack::Server).to receive(:start) do |options|
@app = options[:app]
expect(opti... | ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/spec/lib/builder/post_processor_spec.rb | spec/lib/builder/post_processor_spec.rb | require 'lib/spec_helper'
require 'opal/os'
require 'opal/builder'
require 'opal/builder/scheduler/sequential'
require 'opal/builder/scheduler/threaded'
require 'opal/fragment'
require 'tmpdir'
RSpec.describe Opal::Builder::PostProcessor do
subject(:builder) { Opal::Builder.new(options) }
let(:options) { {compiler... | ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/spec/lib/builder/post_processor/dce_spec.rb | spec/lib/builder/post_processor/dce_spec.rb | require 'lib/spec_helper'
require 'opal/builder'
RSpec.describe Opal::Builder::PostProcessor::DCE do
let(:builder) { Opal::Builder.new(compiler_options: {cache_fragments: true}, dce: dce_types) }
def build(code)
builder.build_str(code, 'input.rb').to_s
end
context "when dce removes unused instance method... | ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/spec/lib/fixtures/source_location_test.rb | spec/lib/fixtures/source_location_test.rb |
# Do not move this method
# This file is used to test Method#source_location
def m
end
| ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/spec/lib/fixtures/sprockets_file.js.rb | spec/lib/fixtures/sprockets_file.js.rb | require 'opal'
require 'native'
puts 'sprockets!'
| ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/spec/lib/fixtures/no_requires.rb | spec/lib/fixtures/no_requires.rb | puts 'hi there'
| ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/spec/lib/fixtures/opal_file.rb | spec/lib/fixtures/opal_file.rb | require 'opal'
puts 'hi from opal!'
| ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/spec/lib/fixtures/requires.rb | spec/lib/fixtures/requires.rb | require 'foo'
puts 'hello'
require 'bar'
puts 'goodbye'
| ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/spec/lib/fixtures/build_order.rb | spec/lib/fixtures/build_order.rb | # This fixture tests build order of required JS files
require 'fixtures/build_order/file1'
require 'fixtures/build_order/file2'
require 'fixtures/build_order/file3'
require 'fixtures/build_order/file4'
require 'fixtures/build_order/file5'
require 'fixtures/build_order/file6'
require 'fixtures/build_order/file7'
| ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/spec/lib/fixtures/sprockets_require_tree_test.rb | spec/lib/fixtures/sprockets_require_tree_test.rb | #=require_tree ./required_tree_test
puts 5
| ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/spec/lib/fixtures/source_map.rb | spec/lib/fixtures/source_map.rb | puts 'smap!'
| ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/spec/lib/fixtures/require_tree_test.rb | spec/lib/fixtures/require_tree_test.rb | require_tree '../fixtures/required_tree_test'
puts 5
| ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/spec/lib/fixtures/project/p1/test.rb | spec/lib/fixtures/project/p1/test.rb | ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false | |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/spec/lib/fixtures/project/p3/require_from_p3.rb | spec/lib/fixtures/project/p3/require_from_p3.rb | def require_from_p3_working?
true
end
| ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/spec/lib/fixtures/build_order/file63.rb | spec/lib/fixtures/build_order/file63.rb | # A circular require
require_relative 'file62'
FILE_63 = true
| ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/spec/lib/fixtures/build_order/file61.rb | spec/lib/fixtures/build_order/file61.rb | FILE_61 = true
| ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/spec/lib/fixtures/build_order/file64.rb | spec/lib/fixtures/build_order/file64.rb | FILE_64 = true
| ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/spec/lib/fixtures/build_order/file6.rb | spec/lib/fixtures/build_order/file6.rb | require_relative 'file61'
# There's a circular require between file63 and 62
# file62 should be in output file before 63
require 'fixtures/build_order/file63'
require_relative './file62'
require 'fixtures/build_order/file64.rb'
FILE_6 = true
| ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/spec/lib/fixtures/build_order/file7.rb | spec/lib/fixtures/build_order/file7.rb | FILE_7 = true
| ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/spec/lib/fixtures/build_order/file62.rb | spec/lib/fixtures/build_order/file62.rb | # A circular require
require_relative 'file63'
FILE_62 = true
| ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/spec/lib/fixtures/required_tree_test/required_file1.rb | spec/lib/fixtures/required_tree_test/required_file1.rb | p 1
| ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/spec/lib/fixtures/required_tree_test/required_file2.rb | spec/lib/fixtures/required_tree_test/required_file2.rb | p 2
| ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/spec/lib/fixtures/source_map/subfolder/other_file.rb | spec/lib/fixtures/source_map/subfolder/other_file.rb | puts 'other!'
| ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/spec/lib/source_map/file_spec.rb | spec/lib/source_map/file_spec.rb | require 'support/source_map_helper'
RSpec.describe Opal::SourceMap::File do
include SourceMapHelper
specify '#as_json' do
map = described_class.new([fragment(code: "foo")], 'foo.rb', "foo")
expect(map.as_json).to be_a(Hash)
expect(map.as_json(ignored: :options)).to be_a(Hash)
end
it 'correctly ma... | ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/spec/lib/source_map/index_spec.rb | spec/lib/source_map/index_spec.rb | require 'support/source_map_helper'
RSpec.describe Opal::SourceMap::Index do
include SourceMapHelper
specify '#as_json' do
builder = Opal::Builder.new
builder.build_str('foo', 'bar.rb')
map = builder.source_map
expect(map.as_json).to be_a(Hash)
expect(map.as_json(ignored: :options)).to be_a(Ha... | ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/examples/rack-esm/app/application.rb | examples/rack-esm/app/application.rb | require 'opal'
require 'user'
require 'opal/platform'
module MyApp
class Application
def initialize
@user = User.new('Bob')
end
def title
"#{@user.name} is #{:not unless @user.authenticated?} authenticated"
end
end
end
$app = MyApp::Application.new
require 'native'
$$[:document][:ti... | ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/examples/rack-esm/app/user.rb | examples/rack-esm/app/user.rb | class User
def initialize(name)
puts "wow"
@name = name
end
attr_reader :name
def authenticated?
if admin? or special_permission?
true
else
raise "not authenticated"
end
end
def admin?
@name == 'Bob'
end
def special_permission?
false
end
end
| ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/examples/rack/app/application.rb | examples/rack/app/application.rb | require 'opal'
require 'user'
require 'opal/platform'
module MyApp
class Application
def initialize
@user = User.new('Bob')
end
def title
"#{@user.name} is #{:not unless @user.authenticated?} authenticated"
end
end
end
$app = MyApp::Application.new
require 'native'
$$[:document][:ti... | ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/examples/rack/app/user.rb | examples/rack/app/user.rb | class User
def initialize(name)
puts "wow"
@name = name
end
attr_reader :name
def authenticated?
if admin? or special_permission?
true
else
raise "not authenticated"
end
end
def admin?
@name == 'Bob'
end
def special_permission?
false
end
end
| ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/examples/sinatra/app/application.rb | examples/sinatra/app/application.rb | require 'opal'
def alert(msg)
`alert(msg)`
raise "an example exception with source-map powered backtrace"
end
alert "Hi there!"
| ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/examples/exe/simple.rb | examples/exe/simple.rb | puts "It works! Very cool app!" | ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/lib/opal.rb | lib/opal.rb | # frozen_string_literal: true
require 'opal/requires'
| ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/lib/tilt/opal.rb | lib/tilt/opal.rb | # frozen_string_literal: true
require 'tilt'
require 'opal/builder'
require 'opal/config'
require 'opal/version'
module Opal
class TiltTemplate < Tilt::Template
self.default_mime_type = 'application/javascript'
def self.inherited(subclass)
subclass.default_mime_type = 'application/javascript'
end... | ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/lib/opal/path_reader.rb | lib/opal/path_reader.rb | # frozen_string_literal: true
require 'opal/regexp_anchors'
require 'opal/hike'
module Opal
class PathReader
RELATIVE_PATH_REGEXP = /#{Opal::REGEXP_START}\.?\.#{Regexp.quote File::SEPARATOR}/.freeze
DEFAULT_EXTENSIONS = ['.js', '.js.rb', '.rb', '.opalerb'].freeze
def initialize(paths = Opal.paths, exte... | ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/lib/opal/regexp_anchors.rb | lib/opal/regexp_anchors.rb | # frozen_string_literal: true
module Opal
# rubocop:disable Style/MutableConstant
self::REGEXP_START = '\A'
self::REGEXP_END = '\z'
# Unicode characters in ranges
# \u0001 - \u002F (blank unicode characters + space + !"#$%&'()*+,-./ chars)
# \u003A - \u0040 (:;<=>?@ chars)
# \u005B - \u005E ([\]^ chars)... | ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/lib/opal/version.rb | lib/opal/version.rb | # frozen_string_literal: true
module Opal
# WHEN RELEASING:
# Remember to update RUBY_ENGINE_VERSION in opal/corelib/constants.rb too!
VERSION = '2.0.0dev'
# Only major and minor parts of version
VERSION_MAJOR_MINOR = VERSION.split('.').first(2).join('.').freeze
end
| ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/lib/opal/project.rb | lib/opal/project.rb | # frozen_string_literal: true
module Opal
# Opal::Project is a representation of an Opal project. In particular
# it's a directory containing Ruby files which is described by Opalfile.
class Project
# DSL for Opal::Project
class Opalfile
def initialize(project)
@project = project
yi... | ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/lib/opal/compiler.rb | lib/opal/compiler.rb | # frozen_string_literal: true
if RUBY_ENGINE == 'opal'
require 'corelib/string/unpack'
end
require 'set'
require 'opal/parser'
require 'opal/fragment'
require 'opal/nodes'
require 'opal/eof_content'
require 'opal/errors'
require 'opal/magic_comments'
require 'opal/nodes/closure'
require 'opal/source_map'
module Opa... | ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/lib/opal/errors.rb | lib/opal/errors.rb | # frozen_string_literal: true
module Opal
# Generic Opal error
class Error < StandardError
end
# raised if Gem not found in Opal#use_gem
class GemNotFound < Error
# name of gem that not found
attr_reader :gem_name
# @param gem_name [String] name of gem that not found
def initialize(gem_name... | ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/lib/opal/nodes.rb | lib/opal/nodes.rb | # frozen_string_literal: true
require 'opal/nodes/closure'
require 'opal/nodes/base'
require 'opal/nodes/literal'
require 'opal/nodes/variables'
require 'opal/nodes/constants'
require 'opal/nodes/call'
require 'opal/nodes/call/eval'
require 'opal/nodes/call/match3'
require 'opal/nodes/call/js_property'
require 'opal/n... | ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/lib/opal/simple_server.rb | lib/opal/simple_server.rb | # frozen_string_literal: true
require 'opal/deprecations'
# Opal::SimpleServer is a very basic Rack server for Opal assets, it relies on
# Opal::Builder and Ruby corelib/stdlib. It's meant to be used just for local
# development.
#
# For a more complete implementation see opal-sprockets (Rubygems) or
# opal-webpack (... | ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/lib/opal/exe_compiler.rb | lib/opal/exe_compiler.rb | # frozen_string_literal: true
require 'fileutils'
require 'tmpdir'
require 'opal/os'
module Opal
class ExeCompiler
RUNTIMES = -> {
types = %w[bun deno node quickjs]
types << 'osascript' if OS.macos?
types.freeze
}.call
def self.compile_exe(type, src_out)
new(type, src_out).compi... | ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/lib/opal/deprecations.rb | lib/opal/deprecations.rb | # frozen_string_literal: true
module Opal
module Deprecations
attr_accessor :raise_on_deprecation
def deprecation(message)
message = "DEPRECATION WARNING: #{message}"
if defined?(@raise_on_deprecation) && @raise_on_deprecation
raise message
else
warn message
end
e... | ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/lib/opal/cli_runners.rb | lib/opal/cli_runners.rb | # frozen_string_literal: true
require 'opal/os'
module Opal
# `Opal::CliRunners` is the register in which JavaScript runners can be
# defined for use by `Opal::CLI`. Runners will be called via the `#call`
# method and passed a Hash containing the following keys:
#
#
# - `options`: a hash of options for th... | ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/lib/opal/fragment.rb | lib/opal/fragment.rb | # frozen_string_literal: true
module Opal
# A fragment holds a string of generated javascript that will be written
# to the destination. It also keeps hold of the original sexp from which
# it was generated. Using this sexp, when writing fragments in order, a
# mapping can be created of the original location =... | ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/lib/opal/rewriter.rb | lib/opal/rewriter.rb | # frozen_string_literal: true
require 'opal/rewriters/opal_engine_check'
require 'opal/rewriters/targeted_patches'
require 'opal/rewriters/for_rewriter'
require 'opal/rewriters/js_reserved_words'
require 'opal/rewriters/block_to_iter'
require 'opal/rewriters/dot_js_syntax'
require 'opal/rewriters/pattern_matching'
req... | ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/lib/opal/os.rb | lib/opal/os.rb | # frozen_string_literal: true
require 'shellwords'
module Opal
module OS
module_function
def windows?
/bccwin|cygwin|djgpp|mingw|mswin|wince/.match?(RbConfig::CONFIG['host_os'])
end
def macos?
/darwin|mac os/.match?(RbConfig::CONFIG['host_os'])
end
def shellescape(str)
i... | ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/lib/opal/parser.rb | lib/opal/parser.rb | # frozen_string_literal: true
require 'opal/ast/builder'
require 'opal/rewriter'
require 'opal/parser/source_buffer'
require 'opal/parser/default_config'
require 'opal/parser/with_ruby_lexer'
require 'opal/parser/patch'
| ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/lib/opal/requires.rb | lib/opal/requires.rb | # frozen_string_literal: true
require 'opal/config'
require 'opal/compiler'
require 'opal/builder'
require 'opal/builder/processor'
require 'opal/erb'
require 'opal/paths'
require 'opal/version'
require 'opal/errors'
require 'opal/source_map'
require 'opal/deprecations'
module Opal
autoload :Server, 'opal/server' i... | ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/lib/opal/repl.rb | lib/opal/repl.rb | # frozen_string_literal: true
require 'opal'
require 'securerandom'
require 'stringio'
require 'fileutils'
require 'rbconfig'
module Opal
class REPL
HISTORY_PATH = File.expand_path('~/.opal-repl-history')
attr_accessor :colorize
def initialize(runner_type = nil)
@argv = []
@colorize = true... | ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/lib/opal/hike.rb | lib/opal/hike.rb | # frozen_string_literal: true
# Copyright (c) 2011 Sam Stephenson
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, cop... | ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/lib/opal/cli_options.rb | lib/opal/cli_options.rb | # frozen_string_literal: true
require 'optparse'
require 'opal/cli_runners'
require 'opal/exe_compiler'
module Opal
class CLIOptions < OptionParser
def initialize
super
@options = {}
self.banner = 'Usage: opal [options] -- [programfile]'
separator ''
on('--repl', 'Run the Opal R... | ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/lib/opal/paths.rb | lib/opal/paths.rb | # frozen_string_literal: true
require 'opal/project'
module Opal
def self.gem_dir
if defined? Opal::GEM_DIR
# This is for the case of opalopal. __FILE__ and __dir__ are unreliable
# in this case.
Opal::GEM_DIR
else
File.expand_path('..', __dir__)
end
end
# Add a file path to... | ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/lib/opal/eof_content.rb | lib/opal/eof_content.rb | # frozen_string_literal: true
module Opal
class EofContent
DATA_SEPARATOR = "__END__\n"
def initialize(tokens, source)
@tokens = tokens
@source = source
end
def eof
return nil if @tokens.empty?
eof_content = @source[last_token_position..-1]
return nil unless eof_conte... | ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/lib/opal/regexp_transpiler.rb | lib/opal/regexp_transpiler.rb | # frozen_string_literal: true
# backtick_javascript: true
# use_strict: true
module Opal
module RegexpTranspiler
module_function
# Transform a regular expression from Ruby syntax to JS syntax, as much
# as possible.
def transform_regexp(original_regexp, flags)
flags ||= ''
if include?(... | ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/lib/opal/cli.rb | lib/opal/cli.rb | # frozen_string_literal: true
require 'opal/requires'
require 'opal/builder'
require 'opal/cli_runners'
require 'opal/exe_compiler'
require 'stringio'
module Opal
class CLI
attr_reader :options, :file, :compiler_options, :evals, :load_paths, :argv,
:output, :requires, :rbrequires, :gems, :stubs, :verbose,... | ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/lib/opal/config.rb | lib/opal/config.rb | # frozen_string_literal: true
require 'set'
module Opal
module Config
extend self
private
def config_options
@config_options ||= {}
end
# Defines a new configuration option
#
# @param [String] name the option name
# @param [Object] default_value the option's default value
... | ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/lib/opal/server.rb | lib/opal/server.rb | # frozen_string_literal: true
Opal.deprecation "`require 'opal/server` and `Opal::Server` are deprecated in favor of `require 'opal/sprockets/server'` and `Opal::Sprockets::Server` (now part of the opal-sprockets gem)."
require 'opal/sprockets/server'
Opal::Server = Opal::Sprockets::Server
| ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/lib/opal/erb.rb | lib/opal/erb.rb | # frozen_string_literal: true
require 'opal/compiler'
module Opal
module ERB
# Compile ERB code into javascript.
#
# [Opal::ERB] can be used to compile [ERB] templates into javascript code.
# This module uses the [Opal::Compiler] internally.
#
# Compiled templates, when run in a javascript e... | ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/lib/opal/builder.rb | lib/opal/builder.rb | # frozen_string_literal: true
require 'opal/path_reader'
require 'opal/paths'
require 'opal/config'
require 'opal/cache'
require 'opal/builder/scheduler'
require 'opal/project'
require 'opal/builder/directory'
require 'opal/builder/post_processor'
require 'set'
module Opal
class Builder
# The registered process... | ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/lib/opal/source_map.rb | lib/opal/source_map.rb | # frozen_string_literal: true
module Opal
# To generate the source map for a single file use Opal::SourceMap::File.
# To combine multiple files the Opal::SourceMap::Index should be used.
module SourceMap
autoload :Map, 'opal/source_map/map'
autoload :File, 'opal/source_map/file'
autoload :Index, '... | ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/lib/opal/cache.rb | lib/opal/cache.rb | # frozen_string_literal: true
require 'opal/paths'
require 'digest/sha2' unless RUBY_ENGINE == 'opal'
if RUBY_ENGINE != 'opal'
require 'opal/cache/file_cache'
end
module Opal
# A Sprockets-compatible cache, for example an instance of
# Opal::Cache::FileCache or Opal::Cache::NullCache.
singleton_class.attr_wr... | ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/lib/opal/util.rb | lib/opal/util.rb | # frozen_string_literal: true
require 'open3'
module Opal
module Util
extend self
ExitStatusError = Class.new(StandardError)
# Used for uglifying source to minify.
#
# Opal::Util.uglify("javascript contents")
#
# @param str [String] string to minify
# @return [String]
def u... | ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/lib/opal/magic_comments.rb | lib/opal/magic_comments.rb | # frozen_string_literal: true
module Opal::MagicComments
MAGIC_COMMENT_RE = /\A# *(\w+) *: *(\S+.*?) *\z/.freeze
EMACS_MAGIC_COMMENT_RE = /\A# *-\*- *(\w+) *: *(\S+.*?) *-\*- *\z/.freeze
def self.parse(sexp, comments)
flags = {}
# We have an upper limit at the first line of code
if sexp
first... | ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/lib/opal/rewriters/opal_engine_check.rb | lib/opal/rewriters/opal_engine_check.rb | # frozen_string_literal: true
require 'opal/rewriters/base'
module Opal
module Rewriters
class OpalEngineCheck < Base
def on_if(node)
test, true_body, false_body = *node.children
if (values = engine_check?(test))
if positive_engine_check?(*values)
process(true_body |... | ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/lib/opal/rewriters/returnable_logic.rb | lib/opal/rewriters/returnable_logic.rb | # frozen_string_literal: true
require 'opal/rewriters/base'
module Opal
module Rewriters
class ReturnableLogic < Base
def next_tmp
@counter ||= 0
@counter += 1
"$ret_or_#{@counter}"
end
def free_tmp
@counter -= 1
end
def reset_tmp_counter!
... | ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/lib/opal/rewriters/for_rewriter.rb | lib/opal/rewriters/for_rewriter.rb | # frozen_string_literal: true
require 'opal/rewriters/base'
module Opal
module Rewriters
class ForRewriter < Base
def self.reset_tmp_counter!
@counter = 0
end
def self.next_tmp
@counter ||= 0
@counter += 1
:"$for_tmp#{@counter}"
end
# Handles
... | ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/lib/opal/rewriters/logical_operator_assignment.rb | lib/opal/rewriters/logical_operator_assignment.rb | # frozen_string_literal: true
require 'opal/rewriters/base'
module Opal
module Rewriters
class LogicalOperatorAssignment < Base
def self.reset_tmp_counter!
@@counter = 0
end
def self.new_temp
@@counter ||= 0
@@counter += 1
:"$logical_op_recvr_tmp_#{@@counter}"
... | ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/lib/opal/rewriters/js_reserved_words.rb | lib/opal/rewriters/js_reserved_words.rb | # frozen_string_literal: true
require 'opal/rewriters/base'
require 'opal/regexp_anchors'
module Opal
module Rewriters
class JsReservedWords < Base
# Reserved javascript keywords - we cannot create variables with the
# same name (ref: http://stackoverflow.com/a/9337272/601782)
ES51_RESERVED_WO... | ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/lib/opal/rewriters/arguments.rb | lib/opal/rewriters/arguments.rb | # frozen_string_literal: true
module Opal
module Rewriters
class Arguments
attr_reader :args, :optargs, :restarg, :postargs,
:kwargs, :kwoptargs, :kwrestarg, :kwnilarg,
:shadowargs, :blockarg
def initialize(args)
@args = []
@optargs = []
@restarg = nil
... | ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/lib/opal/rewriters/binary_operator_assignment.rb | lib/opal/rewriters/binary_operator_assignment.rb | # frozen_string_literal: true
require 'opal/rewriters/base'
module Opal
module Rewriters
class BinaryOperatorAssignment < Base
def self.reset_tmp_counter!
@@counter = 0
end
def self.new_temp
@@counter ||= 0
@@counter += 1
:"$binary_op_recvr_tmp_#{@@counter}"
... | ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/lib/opal/rewriters/thrower_finder.rb | lib/opal/rewriters/thrower_finder.rb | # frozen_string_literal: true
# rubocop:disable Layout/EmptyLineBetweenDefs, Style/SingleLineMethods
module Opal
module Rewriters
# ThrowerFinder attempts to track the presence of throwers, like
# break, redo, so we can make an informed guess in the early
# compilation phase before traversing other nodes... | ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/lib/opal/rewriters/inline_args.rb | lib/opal/rewriters/inline_args.rb | # frozen_string_literal: true
require 'opal/rewriters/base'
require 'opal/rewriters/arguments'
module Opal
module Rewriters
# Converts
#
# def m( a, b = 1, *c, d, e:, f: 1, **g, &blk )
# end
#
# To something like
#
# def m( a, <fake b>, <fake c>, <fake d>, <fake kwargs>)
# ... | ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/lib/opal/rewriters/base.rb | lib/opal/rewriters/base.rb | # frozen_string_literal: true
require 'parser'
require 'opal/ast/node'
module Opal
module Rewriters
class Base < ::Parser::AST::Processor
class DummyLocation
def node=(*)
# stub
end
def expression
self
end
def begin_pos
0
end
... | ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/lib/opal/rewriters/mlhs_args.rb | lib/opal/rewriters/mlhs_args.rb | # frozen_string_literal: true
require 'opal/rewriters/base'
module Opal
module Rewriters
# Rewrites
#
# def m( (a, b), (c, d) )
# body
# end
#
# To
#
# def m($mlhs_tmp1, $mlhs_tmp2)
# (a, b) = $mlhs_tmp1
# (c, d) = $mlhs_tmp2
# body
# end
#
class M... | ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/lib/opal/rewriters/targeted_patches.rb | lib/opal/rewriters/targeted_patches.rb | # frozen_string_literal: true
require 'opal/rewriters/base'
module Opal
module Rewriters
# This module attempts to run some optimizations or compatibility
# improvements against some libraries used with Opal.
#
# This should be a last resort and must not break functionality in
# existing applica... | ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/lib/opal/rewriters/block_to_iter.rb | lib/opal/rewriters/block_to_iter.rb | # frozen_string_literal: true
require 'opal/rewriters/base'
module Opal
module Rewriters
class BlockToIter < Base
def on_block(node)
recvr, args, body = *node
iter_node = s(:iter, args, body)
process recvr.updated(
nil,
recvr.children + [iter_node],
)
... | ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/lib/opal/rewriters/dump_args.rb | lib/opal/rewriters/dump_args.rb | # frozen_string_literal: true
require 'opal/rewriters/base'
module Opal
module Rewriters
class DumpArgs < Base
def on_def(node)
node = super(node)
_mid, args, _body = *node
node.updated(nil, nil, meta: { original_args: args })
end
def on_defs(node)
node = super... | ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/lib/opal/rewriters/deduplicate_arg_name.rb | lib/opal/rewriters/deduplicate_arg_name.rb | # frozen_string_literal: true
module Opal
module Rewriters
# Ruby allows for args with the same name, if the arg starts with a '_', like:
# def funny_method_name(_, _)
# puts _
# end
# but JavaScript in strict mode does not allow for args with the same name
# Ruby assigns the value of... | ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/lib/opal/rewriters/dot_js_syntax.rb | lib/opal/rewriters/dot_js_syntax.rb | # frozen_string_literal: true
require 'opal/rewriters/base'
module Opal
module Rewriters
class DotJsSyntax < Base
def on_send(node)
recv, meth, *args = *node
if recv && recv.type == :send
recv_of_recv, meth_of_recv, _ = *recv
if meth_of_recv == :JS
case meth... | ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/lib/opal/rewriters/forward_args.rb | lib/opal/rewriters/forward_args.rb | # frozen_string_literal: true
require 'opal/rewriters/base'
module Opal
module Rewriters
class ForwardArgs < Base
def on_forward_args(_node)
process(
s(:args, s(:forward_arg, :"$"))
)
end
def on_forwarded_restarg(_node)
process(
s(:splat, s(:lvar, '... | ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/lib/opal/rewriters/numblocks.rb | lib/opal/rewriters/numblocks.rb | # frozen_string_literal: true
require 'opal/rewriters/base'
module Opal
module Rewriters
# This rewriter transforms the Ruby 2.7 numblocks to regular blocks:
#
# proc { _1 }
# v
# proc { |_1| _1 }
class Numblocks < Base
def on_numblock(node)
left, arg_count, right = node.c... | ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/lib/opal/rewriters/pattern_matching.rb | lib/opal/rewriters/pattern_matching.rb | # frozen_string_literal: true
require 'opal/rewriters/base'
module Opal
module Rewriters
class PatternMatching < Base
def initialize
@depth = 0
super
end
# a => b
def on_match_pattern(node)
from, pat = *node
s(:begin,
s(:lvasgn, :"$pmvar", from... | ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/lib/opal/rewriters/hashes/key_duplicates_rewriter.rb | lib/opal/rewriters/hashes/key_duplicates_rewriter.rb | # frozen_string_literal: true
require 'opal/rewriters/base'
require 'set'
module Opal
module Rewriters
module Hashes
class KeyDuplicatesRewriter < ::Opal::Rewriters::Base
def initialize
@keys = UniqKeysSet.new
end
def on_hash(node)
previous_keys, @keys = @keys,... | ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/lib/opal/rewriters/rubyspec/filters_rewriter.rb | lib/opal/rewriters/rubyspec/filters_rewriter.rb | # frozen_string_literal: true
require 'opal/rewriters/base'
module Opal
module Rubyspec
class FiltersRewriter < Opal::Rewriters::Base
class << self
def filters
@filters ||= []
end
def filter(spec_name)
filters << spec_name
end
alias fails filte... | ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/lib/opal/cli_runners/applescript.rb | lib/opal/cli_runners/applescript.rb | # frozen_string_literal: true
require 'opal/cli_runners/system_runner'
module Opal
module CliRunners
class Applescript
def self.call(data)
unless system('which osalang > /dev/null')
raise MissingJavaScriptSupport, 'JavaScript Automation is only supported by OS X Yosemite and above.'
... | ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/lib/opal/cli_runners/quickjs.rb | lib/opal/cli_runners/quickjs.rb | # frozen_string_literal: true
require 'opal/paths'
require 'opal/cli_runners/system_runner'
require 'shellwords'
module Opal
module CliRunners
# QuickJS is Fabrice Bellard's minimalistic JavaScript engine
# https://github.com/bellard/quickjs
class Quickjs
def self.call(data)
exe = ENV['QJS... | ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/lib/opal/cli_runners/mini_racer.rb | lib/opal/cli_runners/mini_racer.rb | # frozen_string_literal: true
require 'mini_racer'
require 'opal/paths'
module Opal
module CliRunners
class MiniRacer
def self.call(data)
::MiniRacer::Platform.set_flags! :harmony
builder = data.fetch(:builder).call
output = data.fetch(:output)
# TODO: pass it
argv... | ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/lib/opal/cli_runners/compiler.rb | lib/opal/cli_runners/compiler.rb | # frozen_string_literal: true
require 'opal/paths'
# The compiler runner will just output the compiled JavaScript
class Opal::CliRunners::Compiler
def self.call(data)
new(data).start
end
def initialize(data)
@options = data[:options] || {}
@builder_factory = data.fetch(:builder)
@map_fi... | ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/lib/opal/cli_runners/chrome.rb | lib/opal/cli_runners/chrome.rb | # frozen_string_literal: true
require 'shellwords'
require 'socket'
require 'timeout'
require 'tmpdir'
require 'rbconfig'
require 'opal/os'
module Opal
module CliRunners
class Chrome
SCRIPT_PATH = File.expand_path('cdp_interface.rb', __dir__).freeze
DEFAULT_CDP_HOST = 'localhost'
DEFAULT_CDP_... | ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/lib/opal/cli_runners/firefox.rb | lib/opal/cli_runners/firefox.rb | # frozen_string_literal: true
require 'shellwords'
require 'socket'
require 'timeout'
require 'tmpdir'
require 'rbconfig'
require 'opal/os'
require 'json'
require 'fileutils'
require 'net/http'
module Opal
module CliRunners
class Firefox
SCRIPT_PATH = File.expand_path('cdp_interface.rb', __dir__).freeze
... | ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/lib/opal/cli_runners/cdp_interface.rb | lib/opal/cli_runners/cdp_interface.rb | # backtick_javascript: true
# frozen_string_literal: true
# This script I converted into Opal, so that I don't have to write
# buffer handling again. We have gets, Node has nothing close to it,
# even async.
# For CDP see docs/cdp_common.(md|json)
require 'opal/platform'
require 'nodejs/env'
%x{
var CDP = require("c... | ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/lib/opal/cli_runners/nodejs.rb | lib/opal/cli_runners/nodejs.rb | # frozen_string_literal: true
require 'shellwords'
require 'opal/paths'
require 'opal/cli_runners/system_runner'
require 'opal/os'
module Opal
module CliRunners
class Nodejs
if RUBY_ENGINE == 'opal'
# We can't rely on Opal.gem_dir for now...
NODE_PATH = 'stdlib/nodejs/node_modules'
... | ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/lib/opal/cli_runners/safari.rb | lib/opal/cli_runners/safari.rb | # frozen_string_literal: true
require 'shellwords'
require 'socket'
require 'timeout'
require 'tmpdir'
require 'rbconfig'
require 'opal/os'
require 'net/http'
require 'webrick'
module Opal
module CliRunners
class Safari
EXECUTION_TIMEOUT = 600 # seconds
DEFAULT_SAFARI_DRIVER_HOST = 'localhost'
... | ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/lib/opal/cli_runners/bun.rb | lib/opal/cli_runners/bun.rb | # frozen_string_literal: true
require 'shellwords'
require 'opal/paths'
require 'opal/cli_runners/system_runner'
require 'opal/os'
module Opal
module CliRunners
class Bun
def self.call(data)
argv = data[:argv].dup.to_a
SystemRunner.call(data) do |tempfile|
opts = Shellwords.shel... | ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
opal/opal | https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/lib/opal/cli_runners/system_runner.rb | lib/opal/cli_runners/system_runner.rb | # frozen_string_literal: true
require 'tempfile'
require 'tmpdir'
require 'fileutils'
module Opal
VirtualFileObject = Struct.new(:path, keyword_init: true)
# Generic runner that will resort to calling an external program.
#
# @option :options [Hash,nil] :env a hash of options to be used as env in the
# c... | ruby | MIT | b4e228990534515b83cd509a9297beca59bf8733 | 2026-01-04T15:44:44.154940Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.