haml_lint 0.20.0 → 0.21.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/haml_lint/linter/rubocop.rb +21 -13
- data/lib/haml_lint/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9343eacc913a5864ba1b9537bffc6bdcd657deaf
|
4
|
+
data.tar.gz: 1aa917703eea3279812a58dfea38a4f342078bd7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0915d21c8eb959014d5253dde8a71fc4b24b11146f02a1562abc47c38ec94da67ae829991131e27a029c8f3809cc4c2de1e2e05379c2093530063678ff2583d4
|
7
|
+
data.tar.gz: a890450c449514de7114891ce762354652ffb1b6d5a9811844906022706f6017a73fc296e7e0fe35622c0565e2e5dde95dc782d0ff544d64044eaa097f5a7e1b
|
@@ -1,6 +1,5 @@
|
|
1
1
|
require 'haml_lint/ruby_extractor'
|
2
2
|
require 'rubocop'
|
3
|
-
require 'tempfile'
|
4
3
|
|
5
4
|
module HamlLint
|
6
5
|
# Runs RuboCop on Ruby code contained within HAML templates.
|
@@ -27,18 +26,10 @@ module HamlLint
|
|
27
26
|
def find_lints(ruby, source_map)
|
28
27
|
rubocop = ::RuboCop::CLI.new
|
29
28
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
Tempfile.open(filename, directory) do |f|
|
35
|
-
begin
|
36
|
-
f.write(ruby)
|
37
|
-
f.close
|
38
|
-
extract_lints_from_offenses(lint_file(rubocop, f.path), source_map)
|
39
|
-
ensure
|
40
|
-
f.unlink
|
41
|
-
end
|
29
|
+
filename = document.file || 'ruby_script'
|
30
|
+
|
31
|
+
with_ruby_from_stdin(ruby) do
|
32
|
+
extract_lints_from_offenses(lint_file(rubocop, filename), source_map)
|
42
33
|
end
|
43
34
|
end
|
44
35
|
|
@@ -72,8 +63,25 @@ module HamlLint
|
|
72
63
|
def rubocop_flags
|
73
64
|
flags = %w[--format HamlLint::OffenseCollector]
|
74
65
|
flags += ['--config', ENV['HAML_LINT_RUBOCOP_CONF']] if ENV['HAML_LINT_RUBOCOP_CONF']
|
66
|
+
flags += ['--stdin']
|
75
67
|
flags
|
76
68
|
end
|
69
|
+
|
70
|
+
# Overrides the global stdin to allow RuboCop to read Ruby code from it.
|
71
|
+
#
|
72
|
+
# @param ruby [String] the Ruby code to write to the overridden stdin
|
73
|
+
# @param _block [Block] the block to perform with the overridden stdin
|
74
|
+
# @return [void]
|
75
|
+
def with_ruby_from_stdin(ruby, &_block)
|
76
|
+
original_stdin = $stdin
|
77
|
+
stdin = StringIO.new
|
78
|
+
stdin.write(ruby)
|
79
|
+
stdin.rewind
|
80
|
+
$stdin = stdin
|
81
|
+
yield
|
82
|
+
ensure
|
83
|
+
$stdin = original_stdin
|
84
|
+
end
|
77
85
|
end
|
78
86
|
|
79
87
|
# Collects offenses detected by RuboCop.
|
data/lib/haml_lint/version.rb
CHANGED
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.
|
4
|
+
version: 0.21.0
|
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-
|
12
|
+
date: 2017-02-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: haml
|
@@ -165,8 +165,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
165
165
|
version: '0'
|
166
166
|
requirements: []
|
167
167
|
rubyforge_project:
|
168
|
-
rubygems_version: 2.5.
|
168
|
+
rubygems_version: 2.4.5.1
|
169
169
|
signing_key:
|
170
170
|
specification_version: 4
|
171
171
|
summary: HAML lint tool
|
172
172
|
test_files: []
|
173
|
+
has_rdoc:
|