Module: Opal::Config

Extended by:
Config
Included in:
Config
Defined in:
opal/lib/opal/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#arity_check_enabledtrue, false

Enable arity check on the arguments passed to methods, procs and lambdas.

Returns:

  • (true, false)


88
# File 'opal/lib/opal/config.rb', line 88

config_option :arity_check_enabled, false, compiler_option: :arity_check

#const_missing_enabledtrue, false

Enable const_missing support.

Returns:

  • (true, false)


83
# File 'opal/lib/opal/config.rb', line 83

config_option :const_missing_enabled, true, compiler_option: :const_missing

#dynamic_require_severity:error, ...

Set the error severity for when a require can't be solved at compile time.

  • :error will raise an error at compile time
  • :warning will print a warning on stderr at compile time
  • :ignore will skip the require silently at compile time

Returns:

  • (:error, :warning, :ignore)


107
# File 'opal/lib/opal/config.rb', line 107

config_option :dynamic_require_severity, :warning, compiler_option: :dynamic_require_severity, valid_values: [:error, :warning, :ignore]

#freezing_stubs_enabledtrue, false

Add stubs for methods related to freezing objects (for compatibility).

Returns:

  • (true, false)


93
# File 'opal/lib/opal/config.rb', line 93

config_option :freezing_stubs_enabled, true, compiler_option: :freezing

#inline_operators_enabledtrue, false

Enable for inline operators optimizations.

Returns:

  • (true, false)


117
# File 'opal/lib/opal/config.rb', line 117

config_option :inline_operators_enabled, true, compiler_option: :inline_operators

#irb_enabledtrue, false

Enable IRB support for making local variables across multiple compilations.

Returns:

  • (true, false)


112
# File 'opal/lib/opal/config.rb', line 112

config_option :irb_enabled, false, compiler_option: :irb

#method_missing_enabledtrue, false

Enable method_missing support.

Returns:

  • (true, false)


78
# File 'opal/lib/opal/config.rb', line 78

config_option :method_missing_enabled, true, compiler_option: :method_missing

#source_map_enabledtrue, false

Enable source maps support.

Returns:

  • (true, false)


122
# File 'opal/lib/opal/config.rb', line 122

config_option :source_map_enabled, true

#stubbed_filesSet

A set of stubbed files that will be marked as loaded and skipped during compilation. The value is expected to be mutated but it's ok to replace it.

Returns:

  • (Set)


129
# File 'opal/lib/opal/config.rb', line 129

config_option :stubbed_files, -> { Set.new }, valid_values: [Set]

#tainting_stubs_enabledtrue, false

Add stubs for methods related to tainting objects (for compatibility).

Returns:

  • (true, false)


98
# File 'opal/lib/opal/config.rb', line 98

config_option :tainting_stubs_enabled, true, compiler_option: :tainting

Instance Method Details

#compiler_optionsHash

Returns the configuration for Opal::Compiler

Returns:

  • (Hash)

    the configuration for Opal::Compiler



53
54
55
56
57
58
59
60
# File 'opal/lib/opal/config.rb', line 53

def compiler_options
  compiler_options = {}
  config_options.each do |name, options|
    compiler_option_name = options.fetch(:compiler)
    compiler_options[compiler_option_name] = config.fetch(name)
  end
  compiler_options
end

#configHash

Returns the current configuration, defaults to #default_config

Returns:

  • (Hash)

    the current configuration, defaults to #default_config



63
64
65
# File 'opal/lib/opal/config.rb', line 63

def config
  @config ||= default_config
end

#default_configHash

Returns the default configuration

Returns:

  • (Hash)

    the default configuration



42
43
44
45
46
47
48
49
50
# File 'opal/lib/opal/config.rb', line 42

def default_config
  default_config = {}
  config_options.each do |name, options|
    default_value = options.fetch(:default)
    default_value = Proc === default_value ? default_value.call : default_value
    default_config[name] = default_value
  end
  default_config
end

#reset!void

This method returns an undefined value.

Resets the config to its default value



70
71
72
# File 'opal/lib/opal/config.rb', line 70

def reset!
  @config = nil
end