Class: Gry::Formatter
- Inherits:
-
Object
- Object
- Gry::Formatter
- Defined in:
- lib/gry/formatter.rb
Instance Method Summary collapse
-
#format(laws) ⇒ String
A yaml string.
-
#initialize(display_disabled_cops:) ⇒ Formatter
constructor
A new instance of Formatter.
Constructor Details
#initialize(display_disabled_cops:) ⇒ Formatter
Returns a new instance of Formatter.
3 4 5 |
# File 'lib/gry/formatter.rb', line 3 def initialize(display_disabled_cops:) @display_disabled_cops = display_disabled_cops end |
Instance Method Details
#format(laws) ⇒ String
Returns a yaml string.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/gry/formatter.rb', line 9 def format(laws) confs = laws.map do |law| if law.letter letter = {law.name => law.letter} else if @display_disabled_cops letter = {law.name => {'Enabled' => false}} else next end end comment = RubocopAdapter.metrics_cop?(law.name) ? '' : to_comment(law.bill) yaml = to_yaml(letter) comment + yaml end.compact to_yaml(RubocopAdapter.config_base) + "\n" + confs.join("\n") end |