Class: Chutney::ChutneyLint
- Inherits:
-
Object
- Object
- Chutney::ChutneyLint
- Extended by:
- Forwardable
- Defined in:
- lib/chutney.rb
Overview
gherkin linter
Instance Attribute Summary collapse
-
#files ⇒ Object
readonly
Returns the value of attribute files.
-
#results ⇒ Object
readonly
Returns the value of attribute results.
-
#verbose ⇒ Object
Returns the value of attribute verbose.
Instance Method Summary collapse
- #analyse ⇒ Object (also: #analyze)
- #configuration ⇒ Object
- #configuration=(config) ⇒ Object
-
#initialize(*files) ⇒ ChutneyLint
constructor
A new instance of ChutneyLint.
- #linters ⇒ Object
- #linters=(*linters) ⇒ Object
Constructor Details
#initialize(*files) ⇒ ChutneyLint
Returns a new instance of ChutneyLint.
66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/chutney.rb', line 66 def initialize(*files) @files = files @results = Hash.new { |h, k| h[k] = [] } i18n_paths = Dir[File.(File.join(__dir__, 'config/locales')) + '/*.yml'] i18n_paths.each do |path| next if I18n.load_path.include?(path) I18n.load_path << path I18n.backend.reload! end end |
Instance Attribute Details
#files ⇒ Object (readonly)
Returns the value of attribute files.
62 63 64 |
# File 'lib/chutney.rb', line 62 def files @files end |
#results ⇒ Object (readonly)
Returns the value of attribute results.
62 63 64 |
# File 'lib/chutney.rb', line 62 def results @results end |
#verbose ⇒ Object
Returns the value of attribute verbose.
61 62 63 |
# File 'lib/chutney.rb', line 61 def verbose @verbose end |
Instance Method Details
#analyse ⇒ Object Also known as: analyze
92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/chutney.rb', line 92 def analyse if configuration.respond_to?(:using_user_configuration?) && !configuration.quiet? && !configuration.using_user_configuration? warn('Chutney: no local configuration found, using gem defaults. Run `chutney -l` to list enabled ' \ 'enabled linters, `chutney --init` to install a local configuration file or `chutney --quiet` ' \ 'to disable this message.') end files.each do |f| lint(f) end @results end |
#configuration ⇒ Object
79 80 81 82 83 84 85 86 |
# File 'lib/chutney.rb', line 79 def configuration unless @config default_file = [File.('..', __dir__), '**/config', 'chutney_defaults.yml'] config_file = Dir.glob(File.join(default_file)).first.freeze @config = Configuration.new(config_file) end @config end |
#configuration=(config) ⇒ Object
88 89 90 |
# File 'lib/chutney.rb', line 88 def configuration=(config) @config = config end |
#linters ⇒ Object
110 111 112 |
# File 'lib/chutney.rb', line 110 def linters @linters ||= Linter.descendants.filter { |l| configuration.dig(l.linter_name, 'Enabled') } end |
#linters=(*linters) ⇒ Object
114 115 116 |
# File 'lib/chutney.rb', line 114 def linters=(*linters) @linters = linters end |