haml_lint 0.15.0 → 0.15.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: fa23a0a6cf7859c1d52147bb83dffea555ca12ef
4
- data.tar.gz: f68ba67d32f4d76cb0632b69ff10e3d801f4e0e8
3
+ metadata.gz: 11dfd8283a78d7d9464e3a003a7f97446178b76f
4
+ data.tar.gz: de67f6e626da0bd9e3f91e1183af9d88af54d369
5
5
  SHA512:
6
- metadata.gz: adbaa7dba069ef58a9522a8b5ad7ce39f21aa54a9aa3fe132799f6f2fee929f7510df2029bb6e55d2a4776a8fb1e091c5896ece3a3b1b73ffcc897df44b15c64
7
- data.tar.gz: 8e8246c549c8322a202885179c301f98e5e818aefdb2badc9c0fa83ee4974366d88dee6da61f2a0df571df05829950be26e8ada196e00c4f3ad90ce024235655
6
+ metadata.gz: bd464c7c0f1542a93a3bf3fa1b017117ffef544dbc6b5c95cd05c7a2ff99ff78362786d23b024b3608596acc8cc165eb3e3791d659a3752e87f6aff7506d702c
7
+ data.tar.gz: 41b5410fc090a6151476edfdadc7d3f24eb7f2d0ed8e7d7065463901d382e412fc017694a6725532546095e08dc8b9eaa05274d30f99b93eb05786159e6465af
@@ -22,6 +22,8 @@ module HamlLint
22
22
  # @raise [HamlLint::Exceptions::InvalidFilePath]
23
23
  # @return [Array<String>] list of actual files
24
24
  def find(patterns, excluded_patterns)
25
+ excluded_patterns = excluded_patterns.map { |pattern| normalize_path(pattern) }
26
+
25
27
  extract_files_from(patterns).reject do |file|
26
28
  excluded_patterns.any? do |exclusion_glob|
27
29
  HamlLint::Utils.any_glob_matches?(exclusion_glob, file)
@@ -62,7 +64,15 @@ module HamlLint
62
64
  end
63
65
  end
64
66
 
65
- files.uniq.sort
67
+ files.uniq.sort.map { |file| normalize_path(file) }
68
+ end
69
+
70
+ # Trim "./" from the front of relative paths.
71
+ #
72
+ # @param path [String]
73
+ # @return [String]
74
+ def normalize_path(path)
75
+ path.start_with?(".#{File::SEPARATOR}") ? path[2..-1] : path
66
76
  end
67
77
 
68
78
  # Whether the given file should be treated as a Haml file.
@@ -14,13 +14,14 @@ module HamlLint
14
14
  visit_children(node) if descend == :children
15
15
  end
16
16
 
17
- method = "visit_#{node_name(node)}"
18
- send(method, node, &block) if respond_to?(method, true)
17
+ safe_send("visit_#{node_name(node)}", node, &block)
19
18
 
20
19
  # Visit all children by default unless the block was invoked (indicating
21
20
  # the user intends to not recurse further, or wanted full control over
22
21
  # when the children were visited).
23
22
  visit_children(node) unless block_called
23
+
24
+ safe_send("after_visit_#{node_name(node)}", node, &block)
24
25
  end
25
26
 
26
27
  def visit_children(parent)
@@ -32,5 +33,9 @@ module HamlLint
32
33
  def node_name(node)
33
34
  node.type
34
35
  end
36
+
37
+ def safe_send(name, *args, &block)
38
+ send(name, *args, &block) if respond_to?(name, true)
39
+ end
35
40
  end
36
41
  end
@@ -13,7 +13,7 @@ module HamlLint
13
13
  },
14
14
  'space' => {
15
15
  start_regex: /\A\{ [^ ]/,
16
- end_regex: /[^ ] \}\z/,
16
+ end_regex: /[^ ] \}\z/,
17
17
  start_message: 'Hash attribute should start with one space after the opening brace',
18
18
  end_message: 'Hash attribute should end with one space before the closing brace'
19
19
  }
@@ -84,6 +84,11 @@ module HamlLint
84
84
  add_line(code, node) unless code.empty?
85
85
  end
86
86
 
87
+ def after_visit_tag(node)
88
+ # We add a dummy puts statement for closing tag.
89
+ add_line("puts # #{node.tag_name}/", node)
90
+ end
91
+
87
92
  def visit_script(node)
88
93
  code = node.text
89
94
  add_line(code.strip, node)
@@ -164,7 +169,7 @@ module HamlLint
164
169
  end
165
170
 
166
171
  def anonymous_block?(text)
167
- text =~ /\bdo\s*(\|\s*[^\|]*\s*\|)?\z/
172
+ text =~ /\bdo\s*(\|\s*[^\|]*\s*\|)?(\s*#.*)?\z/
168
173
  end
169
174
 
170
175
  START_BLOCK_KEYWORDS = %w[if unless case begin for until while]
@@ -1,4 +1,4 @@
1
1
  # Defines the gem version.
2
2
  module HamlLint
3
- VERSION = '0.15.0'
3
+ VERSION = '0.15.1'
4
4
  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.15.0
4
+ version: 0.15.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: 2015-06-24 00:00:00.000000000 Z
12
+ date: 2015-09-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: haml
@@ -171,7 +171,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
171
171
  version: '0'
172
172
  requirements: []
173
173
  rubyforge_project:
174
- rubygems_version: 2.4.5
174
+ rubygems_version: 2.4.8
175
175
  signing_key:
176
176
  specification_version: 4
177
177
  summary: HAML lint tool