Module: Dapp::Dapp::DappConfig
- Included in:
- Dapp::Dapp
- Defined in:
- lib/dapp/dapp/dapp_config.rb
Constant Summary collapse
- SUPPORTED_CONFIG_OPTIONS =
{ verbose: [FalseClass, TrueClass], quiet: [FalseClass, TrueClass], dev: [FalseClass, TrueClass], time: [FalseClass, TrueClass], dry_run: [FalseClass, TrueClass], build_dir: [String], color: [String] }
Instance Method Summary collapse
- #config_options ⇒ Object
- #option_color ⇒ Object
- #option_dev ⇒ Object
- #validate_config_options! ⇒ Object
Instance Method Details
#config_options ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/dapp/dapp/dapp_config.rb', line 36 def @config_options ||= begin config_search_paths = [] config_search_paths << File.join(Dir.home) config_search_paths << path if dappfile_exists? config_search_paths.reduce({}) do |, dir| if ( = make_path(dir, '.dapp_config')).file? = begin yaml_load_file().tap do || .merge!(.in_depth_merge(['ci'] || {})) if ENV['GITLAB_CI'] || ENV['TRAVIS'] .delete('ci') end rescue Psych::SyntaxError => e raise Error::Dapp, code: :dapp_config_file_incorrect, data: { message: e. } end .in_depth_merge() else end end.symbolize_keys end end |
#option_color ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/dapp/dapp/dapp_config.rb', line 20 def option_color if [:color] == 'auto' [:color] || 'auto' else [:color] end end |
#option_dev ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/dapp/dapp/dapp_config.rb', line 28 def option_dev if [:dev].nil? config._dev_mode || [:dev] else [:dev] end end |
#validate_config_options! ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/dapp/dapp/dapp_config.rb', line 60 def data_list_format = proc { |list| list.map { |e| "'#{e}'" }.join(', ') } unless (unsupported_keys = .select { |k, _| !SUPPORTED_CONFIG_OPTIONS.keys.include?(k) }.keys).empty? log_warning(desc: { code: :unsupported_dapp_config_options, data: { options: data_list_format.call(unsupported_keys), supported_options: data_list_format.call(SUPPORTED_CONFIG_OPTIONS.keys) } }) end .each do |k, v| next unless SUPPORTED_CONFIG_OPTIONS.keys.include?(k) if k == :color raise Error::Dapp, code: :incorrect_dapp_config_option_color, data: { value: v, expected: data_list_format.call(%w(auto on off)) } unless %w(auto on off).member?(v) elsif !SUPPORTED_CONFIG_OPTIONS[k].member? v.class raise Error::Dapp, code: :incorrect_dapp_config_option, data: { option: k, value: v, expected: data_list_format.call(SUPPORTED_CONFIG_OPTIONS[k]) } end end end |