Class: TestData::Wrap::WebpackerConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/test_data/wrap/webpacker_config.rb

Instance Method Summary collapse

Constructor Details

#initializeWebpackerConfig

Returns a new instance of WebpackerConfig.



4
5
6
# File 'lib/test_data/wrap/webpacker_config.rb', line 4

def initialize
  @user_config_path = Pathname.new("#{TestData.config.pwd}/config/webpacker.yml")
end

Instance Method Details

#builtin_configObject



24
25
26
27
# File 'lib/test_data/wrap/webpacker_config.rb', line 24

def builtin_config
  webpacker_path = Gem.loaded_specs["webpacker"].full_gem_path
  load_yaml(File.join(webpacker_path, "lib/install/config/webpacker.yml"))
end

#no_user_config_exists?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/test_data/wrap/webpacker_config.rb', line 12

def no_user_config_exists?
  !@user_config_path.readable?
end

#relative_user_config_pathObject



8
9
10
# File 'lib/test_data/wrap/webpacker_config.rb', line 8

def relative_user_config_path
  @user_config_path.relative_path_from(Rails.root)
end

#required_entries_missing_from_test_data_configObject



29
30
31
32
# File 'lib/test_data/wrap/webpacker_config.rb', line 29

def required_entries_missing_from_test_data_config
  missing_keys = builtin_config["development"].keys - user_config["test_data"].keys
  builtin_config["development"].slice(*missing_keys).presence
end

#user_configObject



16
17
18
# File 'lib/test_data/wrap/webpacker_config.rb', line 16

def user_config
  load_yaml(@user_config_path)
end

#webpacker_gem_spec_loaded?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/test_data/wrap/webpacker_config.rb', line 20

def webpacker_gem_spec_loaded?
  !!Gem.loaded_specs["webpacker"]
end