Class: Howzit::Config
- Inherits:
-
Object
- Object
- Howzit::Config
- Defined in:
- lib/howzit/config.rb
Overview
Config Class
Constant Summary collapse
- DEFAULTS =
Configuration defaults
{ color: true, config_editor: ENV['EDITOR'] || nil, editor: ENV['EDITOR'] || nil, header_format: 'border', highlight: true, highlighter: 'auto', include_upstream: false, log_level: 1, # 0: debug, 1: info, 2: warn, 3: error matching: 'partial', # exact, partial, fuzzy, beginswith multiple_matches: 'choose', output_title: false, pager: 'auto', paginate: true, show_all_code: false, show_all_on_error: false, wrap: 0 }.deep_freeze
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#editor ⇒ Object
Initiate the editor for the config.
-
#initialize ⇒ Config
constructor
Initialize a config object.
-
#should_ignore(filename) ⇒ Object
Test if a file should be ignored based on YAML file.
-
#template_folder ⇒ String
Find the template folder.
-
#write_config(config) ⇒ Object
Write a config to a file.
Constructor Details
#initialize ⇒ Config
Initialize a config object
29 30 31 |
# File 'lib/howzit/config.rb', line 29 def initialize end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
4 5 6 |
# File 'lib/howzit/config.rb', line 4 def @options end |
Instance Method Details
#editor ⇒ Object
Initiate the editor for the config
76 77 78 |
# File 'lib/howzit/config.rb', line 76 def editor edit_config end |
#should_ignore(filename) ⇒ Object
Test if a file should be ignored based on YAML file
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/howzit/config.rb', line 47 def should_ignore(filename) return false unless File.exist?(ignore_file) @ignore_patterns ||= YAML.safe_load(Util.read_file(ignore_file)) ignore = false @ignore_patterns.each do |pat| if filename =~ /#{pat}/ ignore = true break end end ignore end |
#template_folder ⇒ String
Find the template folder
69 70 71 |
# File 'lib/howzit/config.rb', line 69 def template_folder File.join(config_dir, 'templates') end |
#write_config(config) ⇒ Object
Write a config to a file
38 39 40 |
# File 'lib/howzit/config.rb', line 38 def write_config(config) File.open(config_file, 'w') { |f| f.puts config.to_yaml } end |