Class: Gemfilelint::Linter
- Inherits:
-
Object
- Object
- Gemfilelint::Linter
- Defined in:
- lib/gemfilelint.rb
Defined Under Namespace
Modules: ANSIColor
Instance Attribute Summary collapse
-
#ignore ⇒ Object
readonly
Returns the value of attribute ignore.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
Instance Method Summary collapse
-
#initialize(ignore: [], logger: nil) ⇒ Linter
constructor
A new instance of Linter.
-
#lint(*paths) ⇒ Object
rubocop:disable Metrics/AbcSize, Metrics/MethodLength.
Constructor Details
#initialize(ignore: [], logger: nil) ⇒ Linter
Returns a new instance of Linter.
126 127 128 129 |
# File 'lib/gemfilelint.rb', line 126 def initialize(ignore: [], logger: nil) @ignore = ignore @logger = logger || make_logger end |
Instance Attribute Details
#ignore ⇒ Object (readonly)
Returns the value of attribute ignore.
124 125 126 |
# File 'lib/gemfilelint.rb', line 124 def ignore @ignore end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
124 125 126 |
# File 'lib/gemfilelint.rb', line 124 def logger @logger end |
Instance Method Details
#lint(*paths) ⇒ Object
rubocop:disable Metrics/AbcSize, Metrics/MethodLength
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'lib/gemfilelint.rb', line 132 def lint(*paths) logger.info("Inspecting gemfiles at #{paths.join(', ')}\n") offenses = [] each_offense_for(paths) do |offense| if offense offenses << offense logger.info("W".colorize(:magenta)) else logger.info(".".colorize(:green)) end end logger.info("\n") if offenses.empty? true else = offenses.map { |offense| (offense) } logger.info("\nOffenses:\n\n#{.join("\n")}\n") false end end |