Class: Hedra::Config
- Inherits:
-
Object
- Object
- Hedra::Config
- Defined in:
- lib/hedra/config.rb
Constant Summary collapse
- CONFIG_DIR =
File.('~/.hedra')
- CONFIG_FILE =
File.join(CONFIG_DIR, 'config.yml')
- DEFAULT_CONFIG =
{ 'timeout' => 10, 'concurrency' => 10, 'follow_redirects' => true, 'user_agent' => "Hedra/#{VERSION}", 'proxy' => nil, 'output_format' => 'table' }.freeze
Class Method Summary collapse
Class Method Details
.ensure_config_dir ⇒ Object
38 39 40 |
# File 'lib/hedra/config.rb', line 38 def self.ensure_config_dir FileUtils.mkdir_p(CONFIG_DIR) end |
.load ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/hedra/config.rb', line 20 def self.load ensure_config_dir if File.exist?(CONFIG_FILE) YAML.load_file(CONFIG_FILE) else DEFAULT_CONFIG end rescue StandardError => e warn "Failed to load config: #{e.message}" DEFAULT_CONFIG end |
.plugin_dir ⇒ Object
42 43 44 |
# File 'lib/hedra/config.rb', line 42 def self.plugin_dir File.join(CONFIG_DIR, 'plugins') end |
.save(config) ⇒ Object
33 34 35 36 |
# File 'lib/hedra/config.rb', line 33 def self.save(config) ensure_config_dir File.write(CONFIG_FILE, YAML.dump(config)) end |