Class: Sprockets::BumbleD::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/sprockets/bumble_d/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



13
14
15
16
17
18
19
20
21
# File 'lib/sprockets/bumble_d/config.rb', line 13

def initialize
  @file_extension = '.es6'
  @globals_map = {}.freeze
  @transform_to_umd = true
  @babel_options = {
    presets: ['@babel/preset-env'],
    plugins: ['@babel/plugin-external-helpers']
  }
end

Instance Attribute Details

#babel_config_versionObject

Returns the value of attribute babel_config_version.



6
7
8
# File 'lib/sprockets/bumble_d/config.rb', line 6

def babel_config_version
  @babel_config_version
end

#babel_optionsObject

Returns the value of attribute babel_options.



6
7
8
# File 'lib/sprockets/bumble_d/config.rb', line 6

def babel_options
  @babel_options
end

#file_extensionObject

Returns the value of attribute file_extension.



6
7
8
# File 'lib/sprockets/bumble_d/config.rb', line 6

def file_extension
  @file_extension
end

#globals_mapObject (readonly)

Returns the value of attribute globals_map.



11
12
13
# File 'lib/sprockets/bumble_d/config.rb', line 11

def globals_map
  @globals_map
end

#root_dirObject

Returns the value of attribute root_dir.



6
7
8
# File 'lib/sprockets/bumble_d/config.rb', line 6

def root_dir
  @root_dir
end

#transform_to_umdObject

Returns the value of attribute transform_to_umd.



6
7
8
# File 'lib/sprockets/bumble_d/config.rb', line 6

def transform_to_umd
  @transform_to_umd
end

Instance Method Details

#configure {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:



23
24
25
# File 'lib/sprockets/bumble_d/config.rb', line 23

def configure
  yield self
end

#register_globals(globals_map) ⇒ Object



27
28
29
30
31
32
33
34
35
# File 'lib/sprockets/bumble_d/config.rb', line 27

def register_globals(globals_map)
  duplicate_keys = @globals_map.keys & globals_map.keys
  unless duplicate_keys.empty?
    error_message = "Duplicate keys registered: #{duplicate_keys}"
    raise ConflictingGlobalRegistrationError, error_message
  end

  @globals_map = @globals_map.merge(globals_map).freeze
end