chutney 3.6.0 → 3.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0badc9f82efb1e59bc755597c4ef3f7a4f973e37fec2fc25d4b93192319a75eb
4
- data.tar.gz: 9459b41ac94999efc721d07f54e8e14b3c83c4f00786f003937a65dd2054fb9f
3
+ metadata.gz: 07c1a6a4a0afe29926cdb6c12fd189f6d30fe10e2a5d728478144ff3707ddee2
4
+ data.tar.gz: b6e39a2d58ed3a4f8a67c04e3f55522d068192b7d4d8975f9f03ad8d8385a1da
5
5
  SHA512:
6
- metadata.gz: 404c7bd04be47d2c2fb6c71e9d44bc317b5d0a9abe1a3362945ce2841a76f9cc25eb7703cc39134c2065dfcc8c83d5f615f24e035160cd10aab09178e8f8d6fe
7
- data.tar.gz: 29150aae2c605d2ce489dd3a41b914ad7bc67dc53867122c7c11b67830d5fe82771a433d0b6250c926d0e7bd34c0fa8af53941c734e32d5d8db3f435153f8c0f
6
+ metadata.gz: 04d16c6f3be6ce96f57df7db2c6a2e7c3bc1cd3946f676400df989c0fb6afb07b02519248b2b22c873705d362b05af2cd214f849e234252116e215427ac067be
7
+ data.tar.gz: c00827961589bd8ca1b47a4c7b0c229ba5fa7505830fc061891c461ceb28c4af9cfb98b660bbef47d30eac725c86b9ebc61f1eb7bf7ed6f7d4d7a024c478df84
data/exe/chutney CHANGED
@@ -9,6 +9,7 @@ require 'chutney/formatter/rainbow_formatter'
9
9
  require 'optparse'
10
10
 
11
11
  formatters = Set.new
12
+ quiet = false
12
13
 
13
14
  # rubocop:disable Metrics/BlockLength
14
15
  OptionParser.new do |opts|
@@ -21,6 +22,12 @@ OptionParser.new do |opts|
21
22
  formatters << formatter
22
23
  end
23
24
 
25
+ opts.on('-q',
26
+ '--quiet',
27
+ 'Disable chutney usage warnings. Does not affect the output of the formatters.') do
28
+ quiet = true
29
+ end
30
+
24
31
  opts.on('-v', '--version', 'Display the version.') do
25
32
  puts Chutney::VERSION
26
33
  exit
@@ -28,7 +35,7 @@ OptionParser.new do |opts|
28
35
 
29
36
  opts.on('-l',
30
37
  '--linters',
31
- 'List the linter status by this configuration and exit') do
38
+ 'List the linter status by this configuration and exit.') do
32
39
  pastel = Pastel.new
33
40
  chutney_config = Chutney::ChutneyLint.new.configuration
34
41
  max_name_length = chutney_config.keys.map(&:length).max + 1
@@ -43,6 +50,24 @@ OptionParser.new do |opts|
43
50
  end
44
51
  exit
45
52
  end
53
+
54
+ opts.on('--init',
55
+ 'Install a `chutney.yml` configuration file.') do
56
+ config_dest = if File.exist?('config') && File.directory?('config')
57
+ 'config'
58
+ else
59
+ '.'
60
+ end
61
+ config_path = File.join(config_dest, 'chutney.yml')
62
+ default_path = Chutney::ChutneyLint.new.configuration.default_configuration_path
63
+ if File.exist?(config_path)
64
+ puts "#{config_path} already exists - remove it first if you want to overwrite."
65
+ else
66
+ FileUtils.cp(default_path, config_path)
67
+ puts "#{config_path} created."
68
+ end
69
+ exit
70
+ end
46
71
  end.parse!
47
72
  # rubocop:enable Metrics/BlockLength
48
73
 
@@ -52,6 +77,7 @@ files = ARGV.map { |pattern| Dir.glob(pattern) }.flatten
52
77
  files = Dir.glob('features/**/*.feature') if ARGV.empty?
53
78
 
54
79
  linter = Chutney::ChutneyLint.new(*files)
80
+ linter.configuration.quiet! if quiet
55
81
  report = linter.analyse
56
82
 
57
83
  formatters.each do |formatter|
@@ -5,19 +5,17 @@ require 'delegate'
5
5
  module Chutney
6
6
  # gherkin_lint configuration object
7
7
  class Configuration < SimpleDelegator
8
+ attr_accessor :default_configuration_path, :user_configuration_path
9
+
8
10
  def initialize(path)
9
- @path = path
11
+ @default_configuration_path = path
10
12
  @config = load_configuration || {}
11
13
  load_user_configuration
12
14
  super(@config)
13
15
  end
14
16
 
15
- def configuration_path
16
- @path
17
- end
18
-
19
17
  def load_configuration
20
- YAML.load_file configuration_path || '' if configuration_path
18
+ YAML.load_file default_configuration_path || '' if default_configuration_path
21
19
  end
22
20
 
23
21
  def load_user_configuration
@@ -25,8 +23,29 @@ module Chutney
25
23
  Dir.glob(File.join(Dir.pwd, '**', fname))
26
24
  end.flatten
27
25
 
28
- config_file = config_files.first
29
- merge_config(config_file) if !config_file.nil? && File.exist?(config_file)
26
+ self.user_configuration_path = config_files.first
27
+ return unless !user_configuration_path.nil? && File.exist?(user_configuration_path)
28
+
29
+ begin
30
+ merge_config(user_configuration_path)
31
+ rescue TypeError
32
+ unless quiet?
33
+ warn("Chutney: configuration file `#{user_configuration_path}` is not correctly formatted YAML, " \
34
+ 'falling back to gem defaults.')
35
+ end
36
+ end
37
+ end
38
+
39
+ def using_user_configuration?
40
+ !user_configuration_path.nil?
41
+ end
42
+
43
+ def quiet?
44
+ @config.fetch('quiet', false)
45
+ end
46
+
47
+ def quiet!
48
+ @config['quiet'] = true
30
49
  end
31
50
 
32
51
  private
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Chutney
4
- VERSION = '3.6.0'
4
+ VERSION = '3.7.0'
5
5
  end
data/lib/chutney.rb CHANGED
@@ -47,8 +47,6 @@ require 'chutney/version'
47
47
 
48
48
  require 'cuke_modeler'
49
49
  require 'forwardable'
50
- # require 'gherkin/dialect'
51
- # require 'gherkin/parser'
52
50
  require 'i18n'
53
51
  require 'set'
54
52
  require 'yaml'
@@ -91,6 +89,14 @@ module Chutney
91
89
  end
92
90
 
93
91
  def analyse
92
+ if configuration.respond_to?(:using_user_configuration?) &&
93
+ !configuration.quiet? &&
94
+ !configuration.using_user_configuration?
95
+ warn('Chutney: no local configuration found, using gem defaults. Run `chutney -l` to list enabled ' \
96
+ 'enabled linters, `chutney --init` to install a local configuration file or `chutney --quiet` ' \
97
+ 'to disable this message.')
98
+ end
99
+
94
100
  files.each do |f|
95
101
  lint(f)
96
102
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chutney
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.6.0
4
+ version: 3.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nigel Brookes-Thomas
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: exe
13
13
  cert_chain: []
14
- date: 2023-07-18 00:00:00.000000000 Z
14
+ date: 2023-12-07 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: amatch