leftovers 0.5.3 → 0.5.4

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
  SHA256:
3
- metadata.gz: 8bd5a1759f2b1f26facd015571005bb0bbc3a015ad6feeb28a5b79ec368edf73
4
- data.tar.gz: dbebde9858cd4566a8ca0b2d3770ae97d7904934fe735cce07a287a1c99c55a3
3
+ metadata.gz: cc87c83e3671055ddbbd445768b73d55576676da6cfff8d83f5ceb57eb1d78e8
4
+ data.tar.gz: a3cc4945b1d4158817d0a6b5a0c0cc8bc8ad1d2e7a402d0b0a3221cebba7dc02
5
5
  SHA512:
6
- metadata.gz: 5e81ea69d2763105ba675d36a60c09b6274c625426f92088c2b560cf2890dffb714d56574af91dc51bbdaa64c6e419fff497415a847dc86c239fc19db3c4b026
7
- data.tar.gz: db7bf18379a515c2b53bcc912b7e97e7b44e8bbb75ee1f76db2c729f08f6617852df69c0d7dce4a16d284b31026d5d8da07ec1ff5c655693bf0dfc9ea4ebc523
6
+ metadata.gz: 450162ef45051251a698a5cfbd0451ac50d175339b2a9888edd7790e29071a4360f7677ca4f8d6b927bfdc004b0e4fde747884804c8e480659b76a5b39d0f8e3
7
+ data.tar.gz: 6ae0474561c71a1eddd0f6ecb0ba184de668eaca4aea36da0460fbeec313f9f095533f913863913de89ad192903b1cadaaffb3231432136138b2720df094f636
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ # 0.5.4
2
+ - Add support for slim templates #13 - thanks @veganstraightedge
3
+ - fix the #how-to-resolve link #11 - thanks @veganstraightedge
4
+
1
5
  # v0.5.3
2
6
  - fix incompatibility with activesupport 7.
3
7
 
data/README.md CHANGED
@@ -57,7 +57,7 @@ Not directly called at all:
57
57
  lib/hello_world.rb:6:6 generated_method= attr_accessor :generated_method
58
58
  lib/hello_world.rb:6:6 generated_method attr_accessor :generated_method
59
59
 
60
- how to resolve: https://github.com/robotdana/leftovers/tree/main/Readme.md#how_to_resolve
60
+ how to resolve: https://github.com/robotdana/leftovers/tree/main/Readme.md#how-to-resolve
61
61
  ```
62
62
 
63
63
  if there is an overwhelming number of results, try using [`--write-todo`](#write-todo)
@@ -163,7 +163,7 @@ see the [built in config files](https://github.com/robotdana/leftovers/tree/main
163
163
 
164
164
  Add the method/pattern to the `dynamic:` list with `skip: true` in the `.leftovers.yml`, or add an inline comment with the list of possibilities `# leftovers:call my_method_1, my_method_2`.
165
165
  - Leftovers compares by name only, so multiple definitions with the same name will count as used even if only one is.
166
- - haml & erb line and column numbers will be wrong as the files have to be precompiled before checking.
166
+ - haml, slim & erb line and column numbers will be wrong as the files have to be precompiled before checking.
167
167
 
168
168
  ## Other tools
169
169
 
@@ -7,6 +7,7 @@ Its presence is optional and all of these settings are optional.
7
7
  - [`exclude_paths:`](#exclude_paths)
8
8
  - [`test_paths:`](#test_paths)
9
9
  - [`haml_paths:`](#haml_paths)
10
+ - [`slim_paths:`](#slim_paths)
10
11
  - [`erb_paths:`](#erb_paths)
11
12
  - [`requires:`](#requires)
12
13
  - [`gems:`](#gems)
@@ -92,6 +93,18 @@ haml_paths:
92
93
 
93
94
  Arrays are not necessary for single values. `*.haml` is recognized by default
94
95
 
96
+ ## `slim_paths:`
97
+
98
+ list filenames/paths of test directories that are in the slim format
99
+ Defined using the [.gitignore pattern format](https://git-scm.com/docs/gitignore#_pattern_format)
100
+
101
+ ```yml
102
+ slim_paths:
103
+ - '*.slim'
104
+ ```
105
+
106
+ Arrays are not necessary for single values. `*.slim` is recognized by default
107
+
95
108
  ## `erb_paths:`
96
109
 
97
110
  list filenames/paths of test directories that are in the erb format
data/leftovers.gemspec CHANGED
@@ -42,6 +42,7 @@ Gem::Specification.new do |spec|
42
42
  spec.add_development_dependency 'rubocop-rspec', '~> 1.44.1'
43
43
  spec.add_development_dependency 'simplecov', '>= 0.18.5'
44
44
  spec.add_development_dependency 'simplecov-console'
45
+ spec.add_development_dependency 'slim'
45
46
  spec.add_development_dependency 'timecop'
46
47
  spec.add_development_dependency 'tty_string', '>= 0.2.1'
47
48
 
data/lib/config/ruby.yml CHANGED
@@ -20,6 +20,9 @@ erb_paths:
20
20
  haml_paths:
21
21
  - '*.haml'
22
22
 
23
+ slim_paths:
24
+ - '*.slim'
25
+
23
26
  keep:
24
27
  - initialize # called by new
25
28
  - inspect # called by repl, to_s
@@ -0,0 +1,4 @@
1
+ include_paths:
2
+ - '*.slim'
3
+ slim_paths:
4
+ - '*.slim'
@@ -36,6 +36,10 @@ module Leftovers
36
36
  @haml_paths ||= Array(yaml[:haml_paths])
37
37
  end
38
38
 
39
+ def slim_paths
40
+ @slim_paths ||= Array(yaml[:slim_paths])
41
+ end
42
+
39
43
  def erb_paths
40
44
  @erb_paths ||= Array(yaml[:erb_paths])
41
45
  end
@@ -517,6 +517,7 @@ module Leftovers
517
517
  'exclude_paths' => { '$ref' => '#/definitions/stringList' },
518
518
  'test_paths' => { '$ref' => '#/definitions/stringList' },
519
519
  'haml_paths' => { '$ref' => '#/definitions/stringList' },
520
+ 'slim_paths' => { '$ref' => '#/definitions/stringList' },
520
521
  'erb_paths' => { '$ref' => '#/definitions/stringList' },
521
522
  'requires' => { '$ref' => '#/definitions/stringList' },
522
523
  'gems' => { '$ref' => '#/definitions/stringList' },
data/lib/leftovers/erb.rb CHANGED
@@ -4,7 +4,7 @@ require 'erb'
4
4
 
5
5
  module Leftovers
6
6
  class ERB < ::ERB::Compiler
7
- def self.precompile(erb)
7
+ def self.precompile(erb, _name)
8
8
  @compiler ||= new('-')
9
9
  @compiler.compile(erb).first
10
10
  end
@@ -15,12 +15,18 @@ module Leftovers
15
15
  end
16
16
 
17
17
  def ruby
18
+ precompiler&.precompile(read, self) || read
19
+ end
20
+
21
+ private
22
+
23
+ def precompiler
18
24
  if Leftovers.config.haml_paths.allowed?(relative_path)
19
- ::Leftovers::Haml.precompile(read, self)
25
+ ::Leftovers::Haml
26
+ elsif Leftovers.config.slim_paths.allowed?(relative_path)
27
+ ::Leftovers::Slim
20
28
  elsif Leftovers.config.erb_paths.allowed?(relative_path)
21
- ::Leftovers::ERB.precompile(read)
22
- else
23
- read
29
+ ::Leftovers::ERB
24
30
  end
25
31
  end
26
32
  end
@@ -37,14 +37,22 @@ module Leftovers
37
37
  Leftovers::Config.new(:'.leftovers_todo.yml', path: Leftovers.pwd + '.leftovers_todo.yml')
38
38
  end
39
39
 
40
- def unmemoize # rubocop:disable Metrics/CyclomaticComplexity
41
- remove_instance_variable(:@exclude_paths) if defined?(@exclude_paths)
42
- remove_instance_variable(:@include_paths) if defined?(@include_paths)
43
- remove_instance_variable(:@test_paths) if defined?(@test_paths)
44
- remove_instance_variable(:@haml_paths) if defined?(@haml_paths)
45
- remove_instance_variable(:@erb_paths) if defined?(@erb_paths)
46
- remove_instance_variable(:@dynamic) if defined?(@dynamic)
47
- remove_instance_variable(:@keep) if defined?(@keep)
40
+ MEMOIZED_IVARS = %i{
41
+ @exclude_paths
42
+ @include_paths
43
+ @test_paths
44
+ @haml_paths
45
+ @slim_paths
46
+ @erb_paths
47
+ @dynamic
48
+ @keep
49
+ @test_only
50
+ }.freeze
51
+
52
+ def unmemoize
53
+ MEMOIZED_IVARS.each do |ivar|
54
+ remove_instance_variable(ivar) if instance_variable_get(ivar)
55
+ end
48
56
  end
49
57
 
50
58
  def exclude_paths
@@ -71,6 +79,14 @@ module Leftovers
71
79
  )
72
80
  end
73
81
 
82
+ def slim_paths
83
+ @slim_paths ||= FastIgnore.new(
84
+ include_rules: @configs.flat_map(&:slim_paths),
85
+ gitignore: false,
86
+ root: Leftovers.pwd
87
+ )
88
+ end
89
+
74
90
  def erb_paths
75
91
  @erb_paths ||= FastIgnore.new(
76
92
  include_rules: @configs.flat_map(&:erb_paths),
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Leftovers
4
+ module Slim
5
+ module_function
6
+
7
+ def precompile(file, name)
8
+ return '' unless Leftovers.try_require('slim', message: <<~MESSAGE) # rubocop:disable Layout/EmptyLineAfterGuardClause
9
+ Skipped parsing #{name.relative_path}, because the slim gem was not available
10
+ `gem install slim`
11
+ MESSAGE
12
+
13
+ begin
14
+ ::Slim::Engine.new(file: file).call(file)
15
+ rescue ::Slim::Parser::SyntaxError => e
16
+ Leftovers.warn "#{e.class}: \"#{e.error}\" #{name.relative_path}:#{e.lineno}:#{e.column}"
17
+ ''
18
+ end
19
+ end
20
+ end
21
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Leftovers
4
- VERSION = '0.5.3'
4
+ VERSION = '0.5.4'
5
5
  end
data/lib/leftovers.rb CHANGED
@@ -24,6 +24,7 @@ module Leftovers # rubocop:disable Metrics/ModuleLength
24
24
  autoload(:ProcessorBuilders, "#{__dir__}/leftovers/processor_builders")
25
25
  autoload(:RakeTask, "#{__dir__}/leftovers/rake_task")
26
26
  autoload(:Reporter, "#{__dir__}/leftovers/reporter")
27
+ autoload(:Slim, "#{__dir__}/leftovers/slim")
27
28
  autoload(:TodoReporter, "#{__dir__}/leftovers/todo_reporter")
28
29
  autoload(:DynamicProcessors, "#{__dir__}/leftovers/dynamic_processors")
29
30
  autoload(:ValueProcessors, "#{__dir__}/leftovers/value_processors")
@@ -93,7 +94,7 @@ module Leftovers # rubocop:disable Metrics/ModuleLength
93
94
  end
94
95
 
95
96
  def resolution_instructions_link
96
- "https://github.com/robotdana/leftovers/tree/v#{Leftovers::VERSION}/README.md#how_to_resolve"
97
+ "https://github.com/robotdana/leftovers/tree/v#{Leftovers::VERSION}/README.md#how-to-resolve"
97
98
  end
98
99
 
99
100
  def warn(message)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: leftovers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.3
4
+ version: 0.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dana Sherson
@@ -178,6 +178,20 @@ dependencies:
178
178
  - - ">="
179
179
  - !ruby/object:Gem::Version
180
180
  version: '0'
181
+ - !ruby/object:Gem::Dependency
182
+ name: slim
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - ">="
186
+ - !ruby/object:Gem::Version
187
+ version: '0'
188
+ type: :development
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - ">="
193
+ - !ruby/object:Gem::Version
194
+ version: '0'
181
195
  - !ruby/object:Gem::Dependency
182
196
  name: timecop
183
197
  requirement: !ruby/object:Gem::Requirement
@@ -323,6 +337,7 @@ files:
323
337
  - lib/config/selenium-webdriver.yml
324
338
  - lib/config/sidekiq.yml
325
339
  - lib/config/simplecov.yml
340
+ - lib/config/slim.yml
326
341
  - lib/config/will_paginate.yml
327
342
  - lib/leftovers.rb
328
343
  - lib/leftovers/ast.rb
@@ -407,6 +422,7 @@ files:
407
422
  - lib/leftovers/processor_builders/value.rb
408
423
  - lib/leftovers/rake_task.rb
409
424
  - lib/leftovers/reporter.rb
425
+ - lib/leftovers/slim.rb
410
426
  - lib/leftovers/todo_reporter.rb
411
427
  - lib/leftovers/value_processors.rb
412
428
  - lib/leftovers/value_processors/add_dynamic_prefix.rb