slim_lint 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/slim_lint/document.rb +1 -1
- data/lib/slim_lint/linter/rubocop.rb +11 -2
- data/lib/slim_lint/linter_selector.rb +3 -0
- data/lib/slim_lint/runner.rb +6 -6
- data/lib/slim_lint/utils.rb +14 -0
- data/lib/slim_lint/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e6369991d47446420b433e59002ca420cb12ffec
|
4
|
+
data.tar.gz: a6c4a34cffad4c9e8c3296e28c08b47ae558acdf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 87d930b8e8514e0233e94ba2ace9c2d8fb338429f6d3846f566b95a54daceadb0a6840d5af893dd6e885d0af254bf17ace8033704e9adb609612d862effeb12e
|
7
|
+
data.tar.gz: c29bebcc2db97f8908130338ad4922af655646a7eed40c36b9019b56e427a7b6a324daf468ff6a2acb3b9777294e157700e48b620538898a88303ee11eb9f5fc
|
data/lib/slim_lint/document.rb
CHANGED
@@ -23,7 +23,7 @@ module SlimLint
|
|
23
23
|
#
|
24
24
|
# @param source [String] Slim code to parse
|
25
25
|
# @param options [Hash]
|
26
|
-
# @option file [String] file name of document that was parsed
|
26
|
+
# @option options :file [String] file name of document that was parsed
|
27
27
|
# @raise [Slim::Parser::Error] if there was a problem parsing the document
|
28
28
|
def initialize(source, options)
|
29
29
|
@config = options[:config]
|
@@ -51,7 +51,7 @@ module SlimLint
|
|
51
51
|
# @param file [String]
|
52
52
|
# @return [Array<RuboCop::Cop::Offense>]
|
53
53
|
def lint_file(rubocop, file)
|
54
|
-
rubocop.run(
|
54
|
+
rubocop.run(rubocop_flags << file)
|
55
55
|
OffenseCollector.offenses
|
56
56
|
end
|
57
57
|
|
@@ -66,9 +66,18 @@ module SlimLint
|
|
66
66
|
@lints << Lint.new(self,
|
67
67
|
document.file,
|
68
68
|
source_map[offense.line],
|
69
|
-
|
69
|
+
offense.message)
|
70
70
|
end
|
71
71
|
end
|
72
|
+
|
73
|
+
# Returns flags that will be passed to RuboCop CLI.
|
74
|
+
#
|
75
|
+
# @return [Array<String>]
|
76
|
+
def rubocop_flags
|
77
|
+
flags = %w[--format SlimLint::OffenseCollector]
|
78
|
+
flags += ['--config', ENV['SLIM_LINT_RUBOCOP_CONF']] if ENV['SLIM_LINT_RUBOCOP_CONF']
|
79
|
+
flags
|
80
|
+
end
|
72
81
|
end
|
73
82
|
|
74
83
|
# Collects offenses detected by RuboCop.
|
@@ -2,6 +2,9 @@ module SlimLint
|
|
2
2
|
# Chooses the appropriate linters to run given the specified configuration.
|
3
3
|
class LinterSelector
|
4
4
|
# Creates a selector using the given configuration and additional options.
|
5
|
+
#
|
6
|
+
# @param config [SlimLint::Configuration]
|
7
|
+
# @param options [Hash]
|
5
8
|
def initialize(config, options)
|
6
9
|
@config = config
|
7
10
|
@options = options
|
data/lib/slim_lint/runner.rb
CHANGED
@@ -4,12 +4,12 @@ module SlimLint
|
|
4
4
|
# Runs the appropriate linters against the desired files given the specified
|
5
5
|
# options.
|
6
6
|
#
|
7
|
-
# @param
|
8
|
-
# @option config_file [String] path of configuration file to load
|
9
|
-
# @option config [SlimLint::Configuration] configuration to use
|
10
|
-
# @option excluded_files [Array<String>]
|
11
|
-
# @option included_linters [Array<String>]
|
12
|
-
# @option excluded_linters [Array<String>]
|
7
|
+
# @param [Hash] options
|
8
|
+
# @option options :config_file [String] path of configuration file to load
|
9
|
+
# @option options :config [SlimLint::Configuration] configuration to use
|
10
|
+
# @option options :excluded_files [Array<String>]
|
11
|
+
# @option options :included_linters [Array<String>]
|
12
|
+
# @option options :excluded_linters [Array<String>]
|
13
13
|
# @return [SlimLint::Report] a summary of all lints found
|
14
14
|
def run(options = {})
|
15
15
|
config = load_applicable_config(options)
|
data/lib/slim_lint/utils.rb
CHANGED
@@ -62,5 +62,19 @@ module SlimLint
|
|
62
62
|
count += 1 while (offset + count < items.count) && block.call(items[offset + count])
|
63
63
|
count
|
64
64
|
end
|
65
|
+
|
66
|
+
# Calls a block of code with a modified set of environment variables,
|
67
|
+
# restoring them once the code has executed.
|
68
|
+
def with_environment(env)
|
69
|
+
old_env = {}
|
70
|
+
env.each do |var, value|
|
71
|
+
old_env[var] = ENV[var.to_s]
|
72
|
+
ENV[var.to_s] = value
|
73
|
+
end
|
74
|
+
|
75
|
+
yield
|
76
|
+
ensure
|
77
|
+
old_env.each { |var, value| ENV[var.to_s] = value }
|
78
|
+
end
|
65
79
|
end
|
66
80
|
end
|
data/lib/slim_lint/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slim_lint
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.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: 2015-05-
|
11
|
+
date: 2015-05-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: slim
|
@@ -149,7 +149,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
149
149
|
requirements:
|
150
150
|
- - ">="
|
151
151
|
- !ruby/object:Gem::Version
|
152
|
-
version:
|
152
|
+
version: 1.9.3
|
153
153
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
154
154
|
requirements:
|
155
155
|
- - ">="
|