haml_lint 0.23.1 → 0.23.2

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: e58b8dc5ec0023cca7778fb8b23f4427d652dc34
4
- data.tar.gz: 7a8856c5bb83a40e5e3b0533d23d4c7fcbe47405
3
+ metadata.gz: 5e1e7727e9ee3dadac7fe5fbc6ba6e4a42e482b5
4
+ data.tar.gz: 7176808267f479eeb56757133e8c0015c4841b77
5
5
  SHA512:
6
- metadata.gz: 5f73d54e14c88415a11459229b6b3e5400e6fd7ffe166c24c74baabfbad4219016117bc675b98cb351a46b46d996f6976892c867f0352c25b80e332f6dad9240
7
- data.tar.gz: ad18b07001c9a25283777c3f6048d991cbe9604b7dc034e1ad57e323c3c9f1a56828e6a279a9b810374fed4440b301b6e7c7eb249a794c40a99b2ff41b36d417
6
+ metadata.gz: c944db1432ca3b9133769fde9173b0dee6ec253f0ac1d16d5d194fce086bfce9952ae49603a196b3d9fc30dbd93572d067169490483ee01b14c36433cdb49c32
7
+ data.tar.gz: e533c56866c2ad9702be3461068cb2aab5fe73c1a39eaf059bfae0850628a1145c67e832eae29f663f6b336d96bff8851d0dcafd8feebb1972767af8c89c6e67
@@ -43,7 +43,7 @@ module HamlLint
43
43
  def process_source(source)
44
44
  @source = process_encoding(source)
45
45
  @source = strip_frontmatter(source)
46
- @source_lines = @source.split("\n")
46
+ @source_lines = @source.split(/\r\n|\r|\n/)
47
47
 
48
48
  @tree = process_tree(HamlLint::Adapter.detect_class.new(@source).parse)
49
49
  rescue Haml::Error => ex
@@ -5,6 +5,11 @@ module HamlLint
5
5
  class Linter::LineLength < Linter
6
6
  include LinterRegistry
7
7
 
8
+ # A marker for a line within a multiline node.
9
+ #
10
+ # @api private
11
+ DummyNode = Struct.new(:line)
12
+
8
13
  MSG = 'Line is too long. [%d/%d]'.freeze
9
14
 
10
15
  def visit_root(root)
@@ -15,7 +20,7 @@ module HamlLint
15
20
 
16
21
  node = root.node_for_line(index + 1)
17
22
  unless node.disabled?(self)
18
- record_lint(node, format(MSG, line.length, max_length))
23
+ record_lint(DummyNode.new(index + 1), format(MSG, line.length, max_length))
19
24
  end
20
25
  end
21
26
  end
@@ -85,6 +85,26 @@ module HamlLint::Tree
85
85
  "#<#{self.class.name}>"
86
86
  end
87
87
 
88
+ # The lines of text, if any, that are contained in the node.
89
+ #
90
+ # @api public
91
+ # @return [Array<String>]
92
+ def lines
93
+ return [] unless @value && text
94
+
95
+ text.split(/\r\n|\r|\n/)
96
+ end
97
+
98
+ # The line numbers that are contained within the node.
99
+ #
100
+ # @api public
101
+ # @return [Range]
102
+ def line_numbers
103
+ return (line..line) unless @value && text
104
+
105
+ (line..line + lines.count)
106
+ end
107
+
88
108
  # The previous node to be traversed in the tree.
89
109
  #
90
110
  # @return [HamlLint::Tree::Node, nil]
@@ -15,7 +15,7 @@ module HamlLint::Tree
15
15
  # @param line [Integer] the line number of the node
16
16
  # @return [HamlLint::Node]
17
17
  def node_for_line(line)
18
- find(-> { HamlLint::Tree::NullNode.new }) { |node| node.line == line }
18
+ find(-> { HamlLint::Tree::NullNode.new }) { |node| node.line_numbers.cover?(line) }
19
19
  end
20
20
  end
21
21
  end
@@ -2,5 +2,5 @@
2
2
 
3
3
  # Defines the gem version.
4
4
  module HamlLint
5
- VERSION = '0.23.1'.freeze
5
+ VERSION = '0.23.2'.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.23.1
4
+ version: 0.23.2
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-11 00:00:00.000000000 Z
12
+ date: 2017-03-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: haml