Class: JpStringsFinder::Config
- Inherits:
-
Object
- Object
- JpStringsFinder::Config
- Defined in:
- lib/jp_strings_finder/config.rb
Constant Summary collapse
- DEFAULT =
{ "exclude" => [] }
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#exclude_files ⇒ Object
readonly
Returns the value of attribute exclude_files.
Instance Method Summary collapse
- #exclude?(file_path) ⇒ Boolean
-
#initialize(config_file: nil) ⇒ Config
constructor
A new instance of Config.
Constructor Details
#initialize(config_file: nil) ⇒ Config
Returns a new instance of Config.
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/jp_strings_finder/config.rb', line 11 def initialize(config_file: nil) if config_file loaded_config = YAML.load_file(config_file) @config = DEFAULT.merge(loaded_config) else @config = DEFAULT end @exclude_files = @config["exclude"].inject([]) do |acc, elem| acc << Dir.glob(elem).map { |e| File.(e) } acc.flatten.uniq end end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
9 10 11 |
# File 'lib/jp_strings_finder/config.rb', line 9 def config @config end |
#exclude_files ⇒ Object (readonly)
Returns the value of attribute exclude_files.
9 10 11 |
# File 'lib/jp_strings_finder/config.rb', line 9 def exclude_files @exclude_files end |
Instance Method Details
#exclude?(file_path) ⇒ Boolean
25 26 27 |
# File 'lib/jp_strings_finder/config.rb', line 25 def exclude?(file_path) @exclude_files.include?(file_path) end |