Class: WebpackDriver::Configuration
- Inherits:
-
Object
- Object
- WebpackDriver::Configuration
- Defined in:
- lib/webpack_driver/configuration.rb,
lib/webpack_driver/configuration/example.rb,
lib/webpack_driver/configuration/generated.rb
Defined Under Namespace
Constant Summary collapse
- ROOT =
Pathname.new(__FILE__).dirname.join('..', '..')
Instance Attribute Summary collapse
-
#cmd_line_flags ⇒ Object
Returns the value of attribute cmd_line_flags.
-
#compile_script ⇒ Object
Returns the value of attribute compile_script.
-
#directory ⇒ Object
Returns the value of attribute directory.
- #environment ⇒ Object
-
#file ⇒ Object
readonly
Returns the value of attribute file.
-
#generated ⇒ Object
readonly
Returns the value of attribute generated.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#port ⇒ Object
Returns the value of attribute port.
Instance Method Summary collapse
- #flags ⇒ Object
- #gem_root ⇒ Object
- #generate! ⇒ Object
-
#initialize(file = './webpack.config.js', options = {}) ⇒ Configuration
constructor
A new instance of Configuration.
- #path ⇒ Object
- #present? ⇒ Boolean
Constructor Details
#initialize(file = './webpack.config.js', options = {}) ⇒ Configuration
Returns a new instance of Configuration.
21 22 23 24 25 26 27 |
# File 'lib/webpack_driver/configuration.rb', line 21 def initialize(file = './webpack.config.js', = {}) .each { |k, v| send("#{k}=", v) } @directory ||= '.' @file = Pathname.new(file) @generated = Tempfile.new(['webpack.config', '.js']) Generated.new([], config: self).invoke_all end |
Instance Attribute Details
#cmd_line_flags ⇒ Object
Returns the value of attribute cmd_line_flags.
12 13 14 |
# File 'lib/webpack_driver/configuration.rb', line 12 def cmd_line_flags @cmd_line_flags end |
#compile_script ⇒ Object
Returns the value of attribute compile_script.
10 11 12 |
# File 'lib/webpack_driver/configuration.rb', line 10 def compile_script @compile_script end |
#directory ⇒ Object
Returns the value of attribute directory.
11 12 13 |
# File 'lib/webpack_driver/configuration.rb', line 11 def directory @directory end |
#environment ⇒ Object
45 46 47 |
# File 'lib/webpack_driver/configuration.rb', line 45 def environment @environment ||= { NODE_ENV: 'development' } end |
#file ⇒ Object (readonly)
Returns the value of attribute file.
15 16 17 |
# File 'lib/webpack_driver/configuration.rb', line 15 def file @file end |
#generated ⇒ Object (readonly)
Returns the value of attribute generated.
16 17 18 |
# File 'lib/webpack_driver/configuration.rb', line 16 def generated @generated end |
#logger ⇒ Object
Returns the value of attribute logger.
9 10 11 |
# File 'lib/webpack_driver/configuration.rb', line 9 def logger @logger end |
#port ⇒ Object
Returns the value of attribute port.
8 9 10 |
# File 'lib/webpack_driver/configuration.rb', line 8 def port @port end |
Instance Method Details
#flags ⇒ Object
49 50 51 52 53 54 |
# File 'lib/webpack_driver/configuration.rb', line 49 def flags opts = ['--config', path] opts += ['--port', port] if port opts += cmd_line_flags if cmd_line_flags opts end |
#gem_root ⇒ Object
41 42 43 |
# File 'lib/webpack_driver/configuration.rb', line 41 def gem_root ROOT end |
#generate! ⇒ Object
29 30 31 |
# File 'lib/webpack_driver/configuration.rb', line 29 def generate! Example.new([], config: self).invoke_all end |
#path ⇒ Object
37 38 39 |
# File 'lib/webpack_driver/configuration.rb', line 37 def path @generated.path end |
#present? ⇒ Boolean
33 34 35 |
# File 'lib/webpack_driver/configuration.rb', line 33 def present? file.exist? end |