Class: Ruby2JS::ConfigurationDSL
- Inherits:
-
Object
- Object
- Ruby2JS::ConfigurationDSL
- Defined in:
- lib/ruby2js/configuration_dsl.rb
Class Method Summary collapse
Instance Method Summary collapse
- #autoexports(value) ⇒ Object
- #autoimport(identifier = nil, file = nil, &block) ⇒ Object
- #autoimport_defs(value) ⇒ Object
- #cjs_modules ⇒ Object
- #equality_comparison ⇒ Object
- #eslevel(level) ⇒ Object
- #esm_modules ⇒ Object
- #filter(name) ⇒ Object
- #identity_comparison ⇒ Object
- #include_method(method_name) ⇒ Object
-
#initialize(options = {}) ⇒ ConfigurationDSL
constructor
A new instance of ConfigurationDSL.
- #logical_or ⇒ Object
- #nullish_or ⇒ Object
- #preset(bool = true) ⇒ Object
-
#private_field_ivars ⇒ Object
Only applies for ES2022+.
- #remove_filter(name) ⇒ Object
- #template_literal_tags(tags) ⇒ Object
- #to_h ⇒ Object
- #underscored_ivars ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ ConfigurationDSL
Returns a new instance of ConfigurationDSL.
7 8 9 |
# File 'lib/ruby2js/configuration_dsl.rb', line 7 def initialize( = {}) @options = end |
Class Method Details
.load_from_file(config_file, options = {}) ⇒ Object
3 4 5 |
# File 'lib/ruby2js/configuration_dsl.rb', line 3 def self.load_from_file(config_file, = {}) new().tap { _1.instance_eval(File.read(config_file), config_file, 1) } end |
Instance Method Details
#autoexports(value) ⇒ Object
78 79 80 |
# File 'lib/ruby2js/configuration_dsl.rb', line 78 def autoexports(value) @options[:autoexports] = value end |
#autoimport(identifier = nil, file = nil, &block) ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/ruby2js/configuration_dsl.rb', line 62 def autoimport(identifier = nil, file = nil, &block) if block @options[:autoimports] = block return elsif @options[:autoimports].is_a?(Proc) @options[:autoimports] = {} end @options[:autoimports] ||= {} @options[:autoimports][identifier] = file end |
#autoimport_defs(value) ⇒ Object
74 75 76 |
# File 'lib/ruby2js/configuration_dsl.rb', line 74 def autoimport_defs(value) @options[:defs] = value end |
#cjs_modules ⇒ Object
41 42 43 |
# File 'lib/ruby2js/configuration_dsl.rb', line 41 def cjs_modules @options[:module] = :cjs end |
#equality_comparison ⇒ Object
29 30 31 |
# File 'lib/ruby2js/configuration_dsl.rb', line 29 def equality_comparison @options[:comparison] = :equality end |
#eslevel(level) ⇒ Object
25 26 27 |
# File 'lib/ruby2js/configuration_dsl.rb', line 25 def eslevel(level) @options[:eslevel] = level end |
#esm_modules ⇒ Object
37 38 39 |
# File 'lib/ruby2js/configuration_dsl.rb', line 37 def esm_modules @options[:module] = :esm end |
#filter(name) ⇒ Object
15 16 17 18 |
# File 'lib/ruby2js/configuration_dsl.rb', line 15 def filter(name) @options[:filters] ||= [] @options[:filters] << name end |
#identity_comparison ⇒ Object
33 34 35 |
# File 'lib/ruby2js/configuration_dsl.rb', line 33 def identity_comparison @options[:comparison] = :identity end |
#include_method(method_name) ⇒ Object
82 83 84 85 |
# File 'lib/ruby2js/configuration_dsl.rb', line 82 def include_method(method_name) @options[:include] ||= [] @options[:include] << method_name unless @options[:include].include?(method_name) end |
#logical_or ⇒ Object
54 55 56 |
# File 'lib/ruby2js/configuration_dsl.rb', line 54 def logical_or @options[:or] = :logical end |
#nullish_or ⇒ Object
58 59 60 |
# File 'lib/ruby2js/configuration_dsl.rb', line 58 def nullish_or @options[:or] = :nullish end |
#preset(bool = true) ⇒ Object
11 12 13 |
# File 'lib/ruby2js/configuration_dsl.rb', line 11 def preset(bool = true) @options[:preset] = bool end |
#private_field_ivars ⇒ Object
Only applies for ES2022+
50 51 52 |
# File 'lib/ruby2js/configuration_dsl.rb', line 50 def private_field_ivars @options[:underscored_private] = false end |
#remove_filter(name) ⇒ Object
20 21 22 23 |
# File 'lib/ruby2js/configuration_dsl.rb', line 20 def remove_filter(name) @options[:disable_filters] ||= [] @options[:disable_filters] << name end |
#template_literal_tags(tags) ⇒ Object
87 88 89 |
# File 'lib/ruby2js/configuration_dsl.rb', line 87 def () @options[:template_literal_tags] = end |
#to_h ⇒ Object
91 92 93 |
# File 'lib/ruby2js/configuration_dsl.rb', line 91 def to_h @options end |
#underscored_ivars ⇒ Object
45 46 47 |
# File 'lib/ruby2js/configuration_dsl.rb', line 45 def underscored_ivars @options[:underscored_private] = true end |