haml_lint 0.43.0 → 0.44.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: ba176a70407bd7ef377d16813fba194a6dc56875da03952116f09250362608cc
4
- data.tar.gz: 3cacf61ff442811b53be9c457519b435cda94e6dfc09bd0831e8bc4a8cc535ad
3
+ metadata.gz: bbda72cc37739238b7f8d4add64844eafa34e89381721b94863a55c401d07c3c
4
+ data.tar.gz: 9112d52034c50d6826c7b6574968eff1f09d648cc24618cedcfe83b120c72ea5
5
5
  SHA512:
6
- metadata.gz: 370beb82cc7d8391944be45c3490aaebef0da77f9eadb621d118a86800d54560e358309eba32f3ebd63ed7b5bcc5e5e069fa636b0d08c6ffc3121603496c6116
7
- data.tar.gz: 678c79722a1baae72336cf3b7d7013ae155a61c3b4389ddc2885aadd566f72b54ce692814f9e4da35b65688bdf34d899fe8acf1c05215a6e482aa8071c96e5a6
6
+ metadata.gz: 7725e42e8f37b2b34e41c203b21f88af876b4bacc8a250be12de431dae62ac48dd5192a8280094566bd51c2f5fcb150457c9deaad6203b0cc4b7c0be67da6ece
7
+ data.tar.gz: 13e48778febfc59d2440f95ca4e3793dc0a46fe4a4eb11dab84032d2d17b797d4a84dccbd73c408207bf73d90eaf633b0e57acc4c124bfcc7fac75338bd9916a
@@ -53,8 +53,13 @@ module HamlLint
53
53
  context[:exclude_files] ||= []
54
54
  config = load_from_file(file)
55
55
 
56
- [default_configuration, resolve_inheritance(config, context), config]
57
- .reduce { |acc, elem| acc.merge(elem) }
56
+ configs = if context[:loaded_files].any?
57
+ [resolve_inheritance(config, context), config]
58
+ else
59
+ [default_configuration, resolve_inheritance(config, context), config]
60
+ end
61
+
62
+ configs.reduce { |acc, elem| acc.merge(elem) }
58
63
  rescue Psych::SyntaxError, Errno::ENOENT => e
59
64
  raise HamlLint::Exceptions::ConfigurationError,
60
65
  "Unable to load configuration from '#{file}': #{e}",
@@ -91,6 +96,18 @@ module HamlLint
91
96
  hash['inherits_from'].concat(Array(hash.delete('inherit_from')))
92
97
  end
93
98
 
99
+ if hash.key?('inherit_gem')
100
+ hash['inherits_from'] ||= []
101
+
102
+ gems = hash.delete('inherit_gem')
103
+ (gems || {}).each_pair.reverse_each do |gem_name, config_path|
104
+ Array(config_path).reverse_each do |path|
105
+ # Put gem configuration first so local configuration overrides it.
106
+ hash['inherits_from'].unshift gem_config_path(gem_name, path)
107
+ end
108
+ end
109
+ end
110
+
94
111
  HamlLint::Configuration.new(hash, file)
95
112
  end
96
113
 
@@ -133,6 +150,24 @@ module HamlLint
133
150
  .compact
134
151
  .reduce { |acc, elem| acc.merge(elem) } || config
135
152
  end
153
+
154
+ # Resolves the config file path relative to a gem
155
+ #
156
+ # @param gem_name [String] name of the gem
157
+ # @param relative_config_path [String] path of the file to resolve, relative to the gem root
158
+ # @return [Stringg]
159
+ def gem_config_path(gem_name, relative_config_path)
160
+ if defined?(Bundler)
161
+ gem = Bundler.load.specs[gem_name].first
162
+ gem_path = gem.full_gem_path if gem
163
+ end
164
+
165
+ gem_path ||= Gem::Specification.find_by_name(gem_name).gem_dir
166
+
167
+ File.join(gem_path, relative_config_path)
168
+ rescue Gem::LoadError => e
169
+ raise Gem::LoadError, "Unable to find gem #{gem_name}; is the gem installed? #{e}"
170
+ end
136
171
  end
137
172
  end
138
173
  end
@@ -2,5 +2,5 @@
2
2
 
3
3
  # Defines the gem version.
4
4
  module HamlLint
5
- VERSION = '0.43.0'
5
+ VERSION = '0.44.0'
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: haml_lint
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.43.0
4
+ version: 0.44.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shane da Silva
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-12-16 00:00:00.000000000 Z
11
+ date: 2023-01-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: haml