Class: CssClassDuplicates::Config
- Inherits:
-
Object
- Object
- CssClassDuplicates::Config
- Defined in:
- lib/css_class_duplicates/config.rb
Overview
This class represents the configuration of the gem. A Config is associated with a YAML configuration file from which it was read.
Constant Summary collapse
- PROJECT_CONFIG =
'.css_class_duplicates.yml'- DEFAULT_CONFIG =
File.('../../config/default.yml', __dir__)
Instance Method Summary collapse
- #files ⇒ Object
- #filter ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #merger ⇒ Object
- #parser ⇒ Object
- #printer ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
14 15 16 17 |
# File 'lib/css_class_duplicates/config.rb', line 14 def initialize filename = File.exist?(PROJECT_CONFIG) ? PROJECT_CONFIG : DEFAULT_CONFIG @config = YAML.load_file(filename) end |
Instance Method Details
#files ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/css_class_duplicates/config.rb', line 19 def files Rake::FileList.new.tap do |file_list| if (files = @config['files']) if (include = files['include']) file_list.include(include) end if (exclude = files['exclude']) file_list.exclude(exclude) end else file_list.include('**/*') end end end |
#filter ⇒ Object
42 43 44 |
# File 'lib/css_class_duplicates/config.rb', line 42 def filter @filter ||= Filter.new(@config['filters']) end |
#merger ⇒ Object
38 39 40 |
# File 'lib/css_class_duplicates/config.rb', line 38 def merger @merger ||= Merger.new(@config['matches']) end |
#parser ⇒ Object
34 35 36 |
# File 'lib/css_class_duplicates/config.rb', line 34 def parser @parser ||= Parser.new(@config['filters']) end |
#printer ⇒ Object
46 47 48 |
# File 'lib/css_class_duplicates/config.rb', line 46 def printer @printer ||= Printer.new end |