haml_lint 0.22.0 → 0.22.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b7cae686b1a15d37a81d966b3c80c41fe51fbe2e
4
- data.tar.gz: e1997a13d2721bedc442891b8a215e8e825180bf
3
+ metadata.gz: 74bd3e8d2dca346948dee6f5f3518cf8f4427bcf
4
+ data.tar.gz: 26f4cf58f23e0a19f480a0d3df8693f28663d709
5
5
  SHA512:
6
- metadata.gz: 62926eeddd753e8af645a8db5cc621cbf3807362453b6913a5f47060b8e13baaa9a8e4dcaa54f32111bc927c53ad08ccfa3ad71c141150c800aacd50a01afac7
7
- data.tar.gz: 8c77947ce1117683f9386724b01a9447f3d5964e958026f872c89d0eff1c7cd70455506ce109041d72a2caaaa83c63e52cdbdb46085707adf81dbe6d6f646b51
6
+ metadata.gz: 8e9472a1c06a1ae244499ce15226afa4afcc17024dfe7951461194365e5f3ea4733f2c50310d701f676f2666703bc1753495e24a6fda4024d0452d0bd1d14282
7
+ data.tar.gz: b29a2894391ca05d84919f22899cf4853297b0048acab726c70217dc4941bd62d49e2e118b5dfd420b9e9cd8fc23d68f65dcd118530ec05613bd8383ced1828d
data/lib/haml_lint/cli.rb CHANGED
@@ -111,11 +111,7 @@ module HamlLint
111
111
  def print_available_reporters
112
112
  log.info 'Available reporters:'
113
113
 
114
- reporter_names = HamlLint::Reporter.descendants.map do |reporter|
115
- reporter.name.split('::').last.sub(/Reporter$/, '').downcase
116
- end
117
-
118
- reporter_names.sort.each do |reporter_name|
114
+ HamlLint::Reporter.available.map(&:cli_name).sort.each do |reporter_name|
119
115
  log.log " - #{reporter_name}"
120
116
  end
121
117
  end
@@ -14,6 +14,7 @@ module HamlLint
14
14
  parser.banner = "Usage: #{APP_NAME} [options] [file1, file2, ...]"
15
15
 
16
16
  add_linter_options parser
17
+ add_report_options parser
17
18
  add_file_options parser
18
19
  add_logger_options parser
19
20
  add_info_options parser
@@ -41,9 +42,13 @@ module HamlLint
41
42
  "Specify which linters you don't want to run") do |linters|
42
43
  @options[:excluded_linters] = linters
43
44
  end
45
+ end
44
46
 
47
+ def add_report_options(parser)
48
+ reporters = HamlLint::Reporter.available.map(&:cli_name).sort
45
49
  parser.on('-r', '--reporter reporter', String,
46
- 'Specify which reporter you want to use to generate the output') do |reporter|
50
+ 'Specify which reporter you want to use to generate the output. One of:',
51
+ *reporters.map { |name| " - #{name}" }) do |reporter|
47
52
  @options[:reporter] = load_reporter_class(reporter.capitalize)
48
53
  end
49
54
 
@@ -1,6 +1,13 @@
1
1
  module HamlLint
2
2
  # Outputs report as a Ruby Hash for easy use by other tools.
3
3
  class Reporter::HashReporter < Reporter
4
+ # Disables this reporter on the CLI since it doesn't output anything.
5
+ #
6
+ # @return [false]
7
+ def self.available?
8
+ false
9
+ end
10
+
4
11
  def display_report(report)
5
12
  lints = report.lints
6
13
  grouped = lints.group_by(&:filename)
@@ -1,6 +1,15 @@
1
+ require 'haml_lint/reporter/hash_reporter'
2
+
1
3
  module HamlLint
2
4
  # Outputs report as a JSON document.
3
5
  class Reporter::JsonReporter < Reporter::HashReporter
6
+ # Ensures that the CLI is able to use the the reporter.
7
+ #
8
+ # @return [true]
9
+ def self.available?
10
+ true
11
+ end
12
+
4
13
  def display_report(report)
5
14
  log.log super.to_json
6
15
  end
@@ -8,6 +8,31 @@ module HamlLint
8
8
  class Reporter
9
9
  include Reporter::Hooks
10
10
 
11
+ # The CLI names of all configured reporters.
12
+ #
13
+ # @return [Array<String>]
14
+ def self.available
15
+ descendants.flat_map do |reporter|
16
+ available = reporter.available
17
+ available.unshift(reporter) if reporter.available?
18
+ available
19
+ end
20
+ end
21
+
22
+ # A flag for whether to show the reporter on the command line.
23
+ #
24
+ # @return [Boolean]
25
+ def self.available?
26
+ true
27
+ end
28
+
29
+ # The name of the reporter as passed from the CLI.
30
+ #
31
+ # @return [String]
32
+ def self.cli_name
33
+ name.split('::').last.sub(/Reporter$/, '').downcase
34
+ end
35
+
11
36
  # Creates the reporter that will display the given report.
12
37
  #
13
38
  # @param logger [HamlLint::Logger]
@@ -2,5 +2,5 @@
2
2
 
3
3
  # Defines the gem version.
4
4
  module HamlLint
5
- VERSION = '0.22.0'.freeze
5
+ VERSION = '0.22.1'.freeze
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: haml_lint
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.22.0
4
+ version: 0.22.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brigade Engineering
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-03-07 00:00:00.000000000 Z
12
+ date: 2017-03-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: haml