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.
23 24 25 26 27 28 29 |
# File 'lib/webpack_driver/configuration.rb', line 23 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.
14 15 16 |
# File 'lib/webpack_driver/configuration.rb', line 14 def cmd_line_flags @cmd_line_flags end |
#compile_script ⇒ Object
Returns the value of attribute compile_script.
12 13 14 |
# File 'lib/webpack_driver/configuration.rb', line 12 def compile_script @compile_script end |
#directory ⇒ Object
Returns the value of attribute directory.
13 14 15 |
# File 'lib/webpack_driver/configuration.rb', line 13 def directory @directory end |
#environment ⇒ Object
47 48 49 |
# File 'lib/webpack_driver/configuration.rb', line 47 def environment @environment ||= { NODE_ENV: 'development' } end |
#file ⇒ Object (readonly)
Returns the value of attribute file.
17 18 19 |
# File 'lib/webpack_driver/configuration.rb', line 17 def file @file end |
#generated ⇒ Object (readonly)
Returns the value of attribute generated.
18 19 20 |
# File 'lib/webpack_driver/configuration.rb', line 18 def generated @generated end |
#logger ⇒ Object
Returns the value of attribute logger.
11 12 13 |
# File 'lib/webpack_driver/configuration.rb', line 11 def logger @logger end |
#port ⇒ Object
Returns the value of attribute port.
10 11 12 |
# File 'lib/webpack_driver/configuration.rb', line 10 def port @port end |
Instance Method Details
#flags ⇒ Object
51 52 53 54 55 56 |
# File 'lib/webpack_driver/configuration.rb', line 51 def flags opts = ['--config', path] opts += ['--port', port] if port opts += cmd_line_flags if cmd_line_flags opts end |
#gem_root ⇒ Object
43 44 45 |
# File 'lib/webpack_driver/configuration.rb', line 43 def gem_root ROOT end |
#generate! ⇒ Object
31 32 33 |
# File 'lib/webpack_driver/configuration.rb', line 31 def generate! Example.new([], config: self).invoke_all end |
#path ⇒ Object
39 40 41 |
# File 'lib/webpack_driver/configuration.rb', line 39 def path @generated.path end |
#present? ⇒ Boolean
35 36 37 |
# File 'lib/webpack_driver/configuration.rb', line 35 def present? file.exist? end |