Class: Kotoshu::ProjectConfig
- Inherits:
-
Object
- Object
- Kotoshu::ProjectConfig
- Defined in:
- lib/kotoshu/project_config.rb
Overview
Project configuration for .kotoshu file.
Auto-discovers .kotoshu file by searching up directory tree.
Constant Summary collapse
- CONFIG_FILE =
".kotoshu"
Class Method Summary collapse
-
.exists?(start_path = Dir.pwd) ⇒ Boolean
Check if project config exists.
-
.ignore_patterns(start_path = Dir.pwd) ⇒ Hash
Get ignore patterns from project config.
-
.load(start_path = Dir.pwd) ⇒ Hash?
Load project config for given path.
Class Method Details
.exists?(start_path = Dir.pwd) ⇒ Boolean
Check if project config exists.
26 27 28 |
# File 'lib/kotoshu/project_config.rb', line 26 def exists?(start_path = Dir.pwd) !find_config_file(start_path).nil? end |
.ignore_patterns(start_path = Dir.pwd) ⇒ Hash
Get ignore patterns from project config.
34 35 36 37 38 39 40 |
# File 'lib/kotoshu/project_config.rb', line 34 def ignore_patterns(start_path = Dir.pwd) config = load(start_path) || {} { words: config["ignore_words"] || [], patterns: (config["ignore_patterns"] || []).map { |p| Regexp.new(p) } } end |
.load(start_path = Dir.pwd) ⇒ Hash?
Load project config for given path.
15 16 17 18 19 20 |
# File 'lib/kotoshu/project_config.rb', line 15 def load(start_path = Dir.pwd) path = find_config_file(start_path) return nil unless path parse_config_file(path) end |