haml_lint 0.43.0 → 0.45.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 +4 -4
- data/lib/haml_lint/configuration_loader.rb +41 -4
- data/lib/haml_lint/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8d47102747f37b5169cf47af34064ea1346df32e5e530cc1d1f17c293de9a34e
|
4
|
+
data.tar.gz: aebecb2a1f37c6c0b20c67ec176c488bce59f667340d4f5a6cbe43736d7532bc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e428d39889b5ab2857560151bea5e233d49ce80bac3fb1dc454e7f042567de7ec05471488c60d774e9506ce72399ac2e4d821d3e106126539740eafa78f2ab0f
|
7
|
+
data.tar.gz: efea4f7dbd70a5669f56f57871ffa29bdac38120e90943c3393ab941421ffd4cbfaf941226d71d707bbbda4800966d317350cb24f9cc15528a6418c42d4bd702
|
@@ -50,11 +50,18 @@ module HamlLint
|
|
50
50
|
# @return [HamlLint::Configuration]
|
51
51
|
def load_file(file, context = {})
|
52
52
|
context[:loaded_files] ||= []
|
53
|
+
context[:loaded_files].map! { |config_file| File.expand_path(config_file) }
|
53
54
|
context[:exclude_files] ||= []
|
54
|
-
|
55
|
+
context[:exclude_files].map! { |config_file| File.expand_path(config_file) }
|
56
|
+
config = load_from_file(File.expand_path(file))
|
55
57
|
|
56
|
-
|
57
|
-
|
58
|
+
configs = if context[:loaded_files].any?
|
59
|
+
[resolve_inheritance(config, context), config]
|
60
|
+
else
|
61
|
+
[default_configuration, resolve_inheritance(config, context), config]
|
62
|
+
end
|
63
|
+
|
64
|
+
configs.reduce { |acc, elem| acc.merge(elem) }
|
58
65
|
rescue Psych::SyntaxError, Errno::ENOENT => e
|
59
66
|
raise HamlLint::Exceptions::ConfigurationError,
|
60
67
|
"Unable to load configuration from '#{file}': #{e}",
|
@@ -91,6 +98,18 @@ module HamlLint
|
|
91
98
|
hash['inherits_from'].concat(Array(hash.delete('inherit_from')))
|
92
99
|
end
|
93
100
|
|
101
|
+
if hash.key?('inherit_gem')
|
102
|
+
hash['inherits_from'] ||= []
|
103
|
+
|
104
|
+
gems = hash.delete('inherit_gem')
|
105
|
+
(gems || {}).each_pair.reverse_each do |gem_name, config_path|
|
106
|
+
Array(config_path).reverse_each do |path|
|
107
|
+
# Put gem configuration first so local configuration overrides it.
|
108
|
+
hash['inherits_from'].unshift gem_config_path(gem_name, path)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
94
113
|
HamlLint::Configuration.new(hash, file)
|
95
114
|
end
|
96
115
|
|
@@ -129,10 +148,28 @@ module HamlLint
|
|
129
148
|
# @return [HamlLint::Configuration]
|
130
149
|
def resolve_inheritance(config, context)
|
131
150
|
Array(config['inherits_from'])
|
132
|
-
.map { |config_file| resolve(config_file, context) }
|
151
|
+
.map { |config_file| resolve(File.expand_path(config_file), context) }
|
133
152
|
.compact
|
134
153
|
.reduce { |acc, elem| acc.merge(elem) } || config
|
135
154
|
end
|
155
|
+
|
156
|
+
# Resolves the config file path relative to a gem
|
157
|
+
#
|
158
|
+
# @param gem_name [String] name of the gem
|
159
|
+
# @param relative_config_path [String] path of the file to resolve, relative to the gem root
|
160
|
+
# @return [Stringg]
|
161
|
+
def gem_config_path(gem_name, relative_config_path)
|
162
|
+
if defined?(Bundler)
|
163
|
+
gem = Bundler.load.specs[gem_name].first
|
164
|
+
gem_path = gem.full_gem_path if gem
|
165
|
+
end
|
166
|
+
|
167
|
+
gem_path ||= Gem::Specification.find_by_name(gem_name).gem_dir
|
168
|
+
|
169
|
+
File.join(gem_path, relative_config_path)
|
170
|
+
rescue Gem::LoadError => e
|
171
|
+
raise Gem::LoadError, "Unable to find gem #{gem_name}; is the gem installed? #{e}"
|
172
|
+
end
|
136
173
|
end
|
137
174
|
end
|
138
175
|
end
|
data/lib/haml_lint/version.rb
CHANGED
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.
|
4
|
+
version: 0.45.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:
|
11
|
+
date: 2023-01-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: haml
|