Class: Klenod::Build::Config

Inherits:
Data
  • Object
show all
Defined in:
lib/klenod/build/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source_dir: "src", entrypoints: [], output: "dist/klenod.bundle", assets_dir: nil, plugins: Context::DEFAULT_PLUGINS, mode: :development, base_dir: Dir.pwd) ⇒ Config

Returns a new instance of Config.



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/klenod/build/config.rb', line 7

def initialize(source_dir: "src", entrypoints: [], output: "dist/klenod.bundle", assets_dir: nil, plugins: Context::DEFAULT_PLUGINS, mode: :development, base_dir: Dir.pwd)
  super(
    source_dir: source_dir,
    entrypoints: Array(entrypoints),
    output: output,
    assets_dir: assets_dir,
    plugins: plugins,
    mode: mode,
    base_dir: base_dir
  )
end

Instance Attribute Details

#assets_dirObject (readonly)

Returns the value of attribute assets_dir

Returns:

  • (Object)

    the current value of assets_dir



5
6
7
# File 'lib/klenod/build/config.rb', line 5

def assets_dir
  @assets_dir
end

#base_dirObject (readonly)

Returns the value of attribute base_dir

Returns:

  • (Object)

    the current value of base_dir



5
6
7
# File 'lib/klenod/build/config.rb', line 5

def base_dir
  @base_dir
end

#entrypointsObject (readonly)

Returns the value of attribute entrypoints

Returns:

  • (Object)

    the current value of entrypoints



5
6
7
# File 'lib/klenod/build/config.rb', line 5

def entrypoints
  @entrypoints
end

#modeObject (readonly)

Returns the value of attribute mode

Returns:

  • (Object)

    the current value of mode



5
6
7
# File 'lib/klenod/build/config.rb', line 5

def mode
  @mode
end

#outputObject (readonly)

Returns the value of attribute output

Returns:

  • (Object)

    the current value of output



5
6
7
# File 'lib/klenod/build/config.rb', line 5

def output
  @output
end

#pluginsObject (readonly)

Returns the value of attribute plugins

Returns:

  • (Object)

    the current value of plugins



5
6
7
# File 'lib/klenod/build/config.rb', line 5

def plugins
  @plugins
end

#source_dirObject (readonly)

Returns the value of attribute source_dir

Returns:

  • (Object)

    the current value of source_dir



5
6
7
# File 'lib/klenod/build/config.rb', line 5

def source_dir
  @source_dir
end

Instance Method Details

#assets_pathObject



40
41
42
# File 'lib/klenod/build/config.rb', line 40

def assets_path
  assets_dir && expand_path(assets_dir)
end

#context(**overrides) ⇒ Object



23
24
25
26
27
28
29
30
# File 'lib/klenod/build/config.rb', line 23

def context(**overrides)
  Context.new(
    source_dir: source_path,
    plugins: plugins,
    mode: mode,
    **overrides
  )
end

#output_pathObject



36
37
38
# File 'lib/klenod/build/config.rb', line 36

def output_path
  expand_path(output)
end

#source_pathObject



32
33
34
# File 'lib/klenod/build/config.rb', line 32

def source_path
  expand_path(source_dir)
end

#with(**attributes) ⇒ Object



19
20
21
# File 'lib/klenod/build/config.rb', line 19

def with(**attributes)
  self.class.new(**to_h.merge(attributes))
end