slim_lint 0.4.0 → 0.5.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3389992065a4202ee3f1541ccade01b424df4115
4
- data.tar.gz: 27e0e7ef9d0155dd54b5729ecf237b72f4b24464
3
+ metadata.gz: e6369991d47446420b433e59002ca420cb12ffec
4
+ data.tar.gz: a6c4a34cffad4c9e8c3296e28c08b47ae558acdf
5
5
  SHA512:
6
- metadata.gz: f419a7cd896f9dec484719c95e4b7ceb6fac3b3c37cdf7432de40ce9581381256d4b108dc20da1e30391bf6128bbe3519ae6cfac6875669dac7b39e4851779ef
7
- data.tar.gz: adc31508f162b7182d79eb81641d8ac5648f498d43f4decbbd38240fd720def57349979cfb9eba76504a9e3c4f97336b9d65fe7d9a25b14530762661a817fb28
6
+ metadata.gz: 87d930b8e8514e0233e94ba2ace9c2d8fb338429f6d3846f566b95a54daceadb0a6840d5af893dd6e885d0af254bf17ace8033704e9adb609612d862effeb12e
7
+ data.tar.gz: c29bebcc2db97f8908130338ad4922af655646a7eed40c36b9019b56e427a7b6a324daf468ff6a2acb3b9777294e157700e48b620538898a88303ee11eb9f5fc
@@ -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(%w[--format SlimLint::OffenseCollector] << file)
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
- "#{offense.cop_name}: #{offense.message}")
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
@@ -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 options [Hash]
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)
@@ -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
@@ -1,4 +1,4 @@
1
1
  # Defines the gem version.
2
2
  module SlimLint
3
- VERSION = '0.4.0'
3
+ VERSION = '0.5.0'
4
4
  end
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.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-04 00:00:00.000000000 Z
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: 2.0.0
152
+ version: 1.9.3
153
153
  required_rubygems_version: !ruby/object:Gem::Requirement
154
154
  requirements:
155
155
  - - ">="