leftovers 0.11.1 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -0
- data/README.md +1 -0
- data/docs/Configuration.md +7 -0
- data/exe/leftovers +3 -1
- data/leftovers.gemspec +3 -4
- data/lib/config/activesupport.yml +1 -1
- data/lib/config/rspec.yml +21 -0
- data/lib/leftovers/ast/array_node.rb +2 -2
- data/lib/leftovers/ast/block_node.rb +1 -1
- data/lib/leftovers/ast/builder.rb +19 -18
- data/lib/leftovers/ast/casgn_node.rb +2 -2
- data/lib/leftovers/ast/const_node.rb +1 -1
- data/lib/leftovers/ast/def_node.rb +1 -1
- data/lib/leftovers/ast/defs_node.rb +1 -1
- data/lib/leftovers/ast/false_node.rb +1 -1
- data/lib/leftovers/ast/hash_node.rb +2 -2
- data/lib/leftovers/ast/module_node.rb +1 -1
- data/lib/leftovers/ast/nil_node.rb +1 -1
- data/lib/leftovers/ast/node.rb +13 -1
- data/lib/leftovers/ast/numeric_node.rb +1 -1
- data/lib/leftovers/ast/send_node.rb +16 -3
- data/lib/leftovers/ast/str_node.rb +1 -1
- data/lib/leftovers/ast/sym_node.rb +1 -1
- data/lib/leftovers/ast/true_node.rb +1 -1
- data/lib/leftovers/ast/var_node.rb +1 -1
- data/lib/leftovers/ast/vasgn_node.rb +2 -2
- data/lib/leftovers/ast.rb +2 -21
- data/lib/leftovers/autoloader.rb +36 -0
- data/lib/leftovers/cli.rb +64 -45
- data/lib/leftovers/collection.rb +66 -0
- data/lib/leftovers/collector.rb +17 -27
- data/lib/leftovers/config.rb +17 -5
- data/lib/leftovers/config_loader/attribute.rb +2 -2
- data/lib/leftovers/config_loader/bool_schema.rb +21 -0
- data/lib/leftovers/config_loader/document_schema.rb +2 -2
- data/lib/leftovers/config_loader/inherit_schema_attributes.rb +1 -1
- data/lib/leftovers/config_loader/node.rb +8 -8
- data/lib/leftovers/config_loader/regexp_schema.rb +1 -1
- data/lib/leftovers/config_loader/rule_pattern_schema.rb +1 -0
- data/lib/leftovers/config_loader/schema.rb +1 -1
- data/lib/leftovers/config_loader/string_enum_schema.rb +1 -1
- data/lib/leftovers/config_loader/value_or_array_schema.rb +1 -1
- data/lib/leftovers/config_loader.rb +8 -48
- data/lib/leftovers/definition.rb +4 -4
- data/lib/leftovers/definition_collection.rb +3 -3
- data/lib/leftovers/definition_node.rb +2 -2
- data/lib/leftovers/definition_node_set.rb +1 -1
- data/lib/leftovers/definition_set.rb +4 -4
- data/lib/leftovers/definition_to_add.rb +2 -2
- data/lib/leftovers/error.rb +6 -0
- data/lib/leftovers/file.rb +4 -4
- data/lib/leftovers/file_collector/comments_processor.rb +23 -18
- data/lib/leftovers/file_collector/node_processor/error.rb +16 -0
- data/lib/leftovers/file_collector/node_processor.rb +19 -2
- data/lib/leftovers/file_collector.rb +28 -20
- data/lib/leftovers/file_list.rb +4 -6
- data/lib/leftovers/matcher_builders/and.rb +5 -5
- data/lib/leftovers/matcher_builders/document.rb +1 -3
- data/lib/leftovers/matcher_builders/name.rb +4 -7
- data/lib/leftovers/matcher_builders/node.rb +21 -35
- data/lib/leftovers/matcher_builders/node_has_argument.rb +17 -29
- data/lib/leftovers/matcher_builders/node_has_block.rb +17 -0
- data/lib/leftovers/matcher_builders/node_has_keyword_argument.rb +7 -9
- data/lib/leftovers/matcher_builders/node_has_positional_argument.rb +10 -10
- data/lib/leftovers/matcher_builders/node_has_receiver.rb +6 -8
- data/lib/leftovers/matcher_builders/node_name.rb +3 -5
- data/lib/leftovers/matcher_builders/node_pair_key.rb +4 -4
- data/lib/leftovers/matcher_builders/node_pair_value.rb +4 -4
- data/lib/leftovers/matcher_builders/node_path.rb +3 -4
- data/lib/leftovers/matcher_builders/node_privacy.rb +3 -3
- data/lib/leftovers/matcher_builders/node_type.rb +18 -13
- data/lib/leftovers/matcher_builders/node_value.rb +18 -31
- data/lib/leftovers/matcher_builders/or.rb +10 -10
- data/lib/leftovers/matcher_builders/path.rb +3 -3
- data/lib/leftovers/matcher_builders/string_pattern.rb +2 -0
- data/lib/leftovers/matcher_builders/unless.rb +1 -3
- data/lib/leftovers/matcher_builders.rb +2 -22
- data/lib/leftovers/matchers/node_has_block.rb +13 -0
- data/lib/leftovers/matchers/node_scalar_value.rb +1 -1
- data/lib/leftovers/matchers.rb +2 -27
- data/lib/leftovers/merged_config.rb +16 -17
- data/lib/leftovers/parser.rb +1 -1
- data/lib/leftovers/precompile_error.rb +31 -0
- data/lib/leftovers/precompilers/haml.rb +23 -3
- data/lib/leftovers/precompilers/json.rb +1 -1
- data/lib/leftovers/precompilers/precompiler.rb +3 -3
- data/lib/leftovers/precompilers/slim.rb +1 -1
- data/lib/leftovers/precompilers/yaml/builder.rb +62 -0
- data/lib/leftovers/precompilers/yaml.rb +3 -56
- data/lib/leftovers/precompilers.rb +11 -16
- data/lib/leftovers/processor_builders/action.rb +15 -19
- data/lib/leftovers/processor_builders/add_prefix.rb +4 -6
- data/lib/leftovers/processor_builders/add_suffix.rb +4 -6
- data/lib/leftovers/processor_builders/argument.rb +10 -15
- data/lib/leftovers/processor_builders/dynamic.rb +12 -30
- data/lib/leftovers/processor_builders/each.rb +63 -76
- data/lib/leftovers/processor_builders/each_for_definition_set.rb +15 -0
- data/lib/leftovers/processor_builders/itself.rb +2 -4
- data/lib/leftovers/processor_builders/keyword.rb +4 -4
- data/lib/leftovers/processor_builders/keyword_argument.rb +4 -4
- data/lib/leftovers/processor_builders/receiver.rb +2 -4
- data/lib/leftovers/processor_builders/transform.rb +26 -49
- data/lib/leftovers/processor_builders/transform_chain.rb +4 -7
- data/lib/leftovers/processor_builders/transform_set.rb +6 -7
- data/lib/leftovers/processor_builders/value.rb +2 -2
- data/lib/leftovers/processor_builders.rb +2 -15
- data/lib/leftovers/processors/add_definition_node.rb +2 -2
- data/lib/leftovers/processors/camelize.rb +3 -3
- data/lib/leftovers/processors/deconstantize.rb +3 -3
- data/lib/leftovers/processors/demodulize.rb +3 -3
- data/lib/leftovers/processors/each_for_definition_set.rb +2 -2
- data/lib/leftovers/processors/eval.rb +1 -1
- data/lib/leftovers/processors/parameterize.rb +3 -3
- data/lib/leftovers/processors/placeholder.rb +1 -1
- data/lib/leftovers/processors/pluralize.rb +3 -3
- data/lib/leftovers/processors/set_default_privacy.rb +1 -1
- data/lib/leftovers/processors/set_privacy.rb +1 -1
- data/lib/leftovers/processors/singularize.rb +3 -3
- data/lib/leftovers/processors/titleize.rb +3 -3
- data/lib/leftovers/processors/underscore.rb +3 -3
- data/lib/leftovers/processors.rb +2 -44
- data/lib/leftovers/rake_task.rb +2 -2
- data/lib/leftovers/reporter.rb +44 -42
- data/lib/leftovers/runner.rb +40 -0
- data/lib/leftovers/todo_reporter.rb +96 -94
- data/lib/leftovers/unexpected_case.rb +8 -0
- data/lib/leftovers/version.rb +1 -1
- data/lib/leftovers.rb +23 -108
- metadata +15 -18
- data/lib/leftovers/matcher_builders/and_not.rb +0 -16
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Leftovers
|
4
4
|
module ProcessorBuilders
|
@@ -7,10 +7,9 @@ module Leftovers
|
|
7
7
|
def build(transforms, next_transform)
|
8
8
|
case transforms
|
9
9
|
when ::Hash then build_from_hash(transforms, next_transform)
|
10
|
-
when ::Symbol
|
11
|
-
::Leftovers::ProcessorBuilders::Transform.build(transforms, true, next_transform)
|
10
|
+
when ::Symbol then Transform.build(transforms, true, next_transform)
|
12
11
|
# :nocov:
|
13
|
-
else raise
|
12
|
+
else raise UnexpectedCase, "Unhandled value #{transforms.inspect}"
|
14
13
|
# :nocov:
|
15
14
|
end
|
16
15
|
end
|
@@ -19,9 +18,7 @@ module Leftovers
|
|
19
18
|
|
20
19
|
def build_from_hash(transforms, next_transform)
|
21
20
|
transforms.reverse_each do |(transform, transform_arg)|
|
22
|
-
next_transform =
|
23
|
-
transform, transform_arg, next_transform
|
24
|
-
)
|
21
|
+
next_transform = Transform.build(transform, transform_arg, next_transform)
|
25
22
|
end
|
26
23
|
|
27
24
|
next_transform
|
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Leftovers
|
4
4
|
module ProcessorBuilders
|
@@ -7,10 +7,9 @@ module Leftovers
|
|
7
7
|
def build(transforms, final_processor)
|
8
8
|
each_builder(final_processor).each_or_self(transforms) do |transform|
|
9
9
|
case transform
|
10
|
-
when ::Hash, ::Symbol
|
11
|
-
::Leftovers::ProcessorBuilders::TransformChain.build(transform, final_processor)
|
10
|
+
when ::Hash, ::Symbol then TransformChain.build(transform, final_processor)
|
12
11
|
# :nocov:
|
13
|
-
else raise
|
12
|
+
else raise UnexpectedCase, "Unhandled value #{transform.inspect}"
|
14
13
|
# :nocov:
|
15
14
|
end
|
16
15
|
end
|
@@ -19,10 +18,10 @@ module Leftovers
|
|
19
18
|
private
|
20
19
|
|
21
20
|
def each_builder(final_processor)
|
22
|
-
if final_processor ==
|
23
|
-
|
21
|
+
if final_processor == Processors::AddDefinitionNode
|
22
|
+
EachForDefinitionSet
|
24
23
|
else
|
25
|
-
|
24
|
+
Each
|
26
25
|
end
|
27
26
|
end
|
28
27
|
end
|
@@ -4,8 +4,8 @@ module Leftovers
|
|
4
4
|
module ProcessorBuilders
|
5
5
|
module Value
|
6
6
|
def self.build(values, then_processor)
|
7
|
-
|
8
|
-
|
7
|
+
Each.each_or_self(values) do |value|
|
8
|
+
Processors::ReplaceValue.new(value, then_processor)
|
9
9
|
end
|
10
10
|
end
|
11
11
|
end
|
@@ -1,20 +1,7 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Leftovers
|
4
4
|
module ProcessorBuilders
|
5
|
-
|
6
|
-
autoload(:AddPrefix, "#{__dir__}/processor_builders/add_prefix")
|
7
|
-
autoload(:AddSuffix, "#{__dir__}/processor_builders/add_suffix")
|
8
|
-
autoload(:Argument, "#{__dir__}/processor_builders/argument")
|
9
|
-
autoload(:Dynamic, "#{__dir__}/processor_builders/dynamic")
|
10
|
-
autoload(:Each, "#{__dir__}/processor_builders/each")
|
11
|
-
autoload(:Itself, "#{__dir__}/processor_builders/itself")
|
12
|
-
autoload(:Keyword, "#{__dir__}/processor_builders/keyword")
|
13
|
-
autoload(:KeywordArgument, "#{__dir__}/processor_builders/keyword_argument")
|
14
|
-
autoload(:Receiver, "#{__dir__}/processor_builders/receiver")
|
15
|
-
autoload(:TransformChain, "#{__dir__}/processor_builders/transform_chain")
|
16
|
-
autoload(:TransformSet, "#{__dir__}/processor_builders/transform_set")
|
17
|
-
autoload(:Transform, "#{__dir__}/processor_builders/transform")
|
18
|
-
autoload(:Value, "#{__dir__}/processor_builders/value")
|
5
|
+
include Autoloader
|
19
6
|
end
|
20
7
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Leftovers
|
4
4
|
module Processors
|
@@ -7,7 +7,7 @@ module Leftovers
|
|
7
7
|
return unless str
|
8
8
|
return if str.empty?
|
9
9
|
|
10
|
-
acc.add_definition_node
|
10
|
+
acc.add_definition_node DefinitionNode.new(current_node, name: str.to_sym)
|
11
11
|
end
|
12
12
|
|
13
13
|
freeze
|
@@ -15,9 +15,9 @@ module Leftovers
|
|
15
15
|
return unless str
|
16
16
|
|
17
17
|
@then_processor.process(str.camelize, current_node, matched_node, acc)
|
18
|
-
rescue NoMethodError
|
19
|
-
Leftovers.error <<~MESSAGE
|
20
|
-
Tried using the String#camelize method, but the activesupport gem was not available and/or not required
|
18
|
+
rescue ::NoMethodError
|
19
|
+
::Leftovers.error <<~MESSAGE
|
20
|
+
Tried using the ::String#camelize method, but the activesupport gem was not available and/or not required
|
21
21
|
`gem install activesupport`, and/or add `requires: ['active_support', 'active_support/core_ext/string']` to your .leftovers.yml
|
22
22
|
MESSAGE
|
23
23
|
end
|
@@ -15,9 +15,9 @@ module Leftovers
|
|
15
15
|
return unless str
|
16
16
|
|
17
17
|
@then_processor.process(str.deconstantize, current_node, matched_node, acc)
|
18
|
-
rescue NoMethodError
|
19
|
-
Leftovers.error <<~MESSAGE
|
20
|
-
Tried using the String#deconstantize method, but the activesupport gem was not available and/or not required
|
18
|
+
rescue ::NoMethodError
|
19
|
+
::Leftovers.error <<~MESSAGE
|
20
|
+
Tried using the ::String#deconstantize method, but the activesupport gem was not available and/or not required
|
21
21
|
`gem install activesupport`, and/or add `requires: ['active_support', 'active_support/core_ext/string']` to your .leftovers.yml
|
22
22
|
MESSAGE
|
23
23
|
end
|
@@ -15,9 +15,9 @@ module Leftovers
|
|
15
15
|
return unless str
|
16
16
|
|
17
17
|
@then_processor.process(str.demodulize, current_node, matched_node, acc)
|
18
|
-
rescue NoMethodError
|
19
|
-
Leftovers.error <<~MESSAGE
|
20
|
-
Tried using the String#demodulize method, but the activesupport gem was not available and/or not required
|
18
|
+
rescue ::NoMethodError
|
19
|
+
::Leftovers.error <<~MESSAGE
|
20
|
+
Tried using the ::String#demodulize method, but the activesupport gem was not available and/or not required
|
21
21
|
`gem install activesupport`, and/or add `requires: ['active_support', 'active_support/core_ext/string']` to your .leftovers.yml
|
22
22
|
MESSAGE
|
23
23
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Leftovers
|
4
4
|
module Processors
|
@@ -14,7 +14,7 @@ module Leftovers
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def process(str, current_node, matched_node, acc)
|
17
|
-
set =
|
17
|
+
set = DefinitionNodeSet.new
|
18
18
|
|
19
19
|
@processors.each do |processor|
|
20
20
|
processor.process(str, current_node, matched_node, set)
|
@@ -15,9 +15,9 @@ module Leftovers
|
|
15
15
|
return unless str
|
16
16
|
|
17
17
|
@then_processor.process(str.parameterize, current_node, matched_node, acc)
|
18
|
-
rescue NoMethodError
|
19
|
-
Leftovers.error <<~MESSAGE
|
20
|
-
Tried using the String#parameterize method, but the activesupport gem was not available and/or not required
|
18
|
+
rescue ::NoMethodError
|
19
|
+
::Leftovers.error <<~MESSAGE
|
20
|
+
Tried using the ::String#parameterize method, but the activesupport gem was not available and/or not required
|
21
21
|
`gem install activesupport`, and/or add `requires: ['active_support', 'active_support/core_ext/string']` to your .leftovers.yml
|
22
22
|
MESSAGE
|
23
23
|
end
|
@@ -15,9 +15,9 @@ module Leftovers
|
|
15
15
|
return unless str
|
16
16
|
|
17
17
|
@then_processor.process(str.pluralize, current_node, matched_node, acc)
|
18
|
-
rescue NoMethodError
|
19
|
-
Leftovers.error <<~MESSAGE
|
20
|
-
Tried using the String#pluralize method, but the activesupport gem was not available and/or not required
|
18
|
+
rescue ::NoMethodError
|
19
|
+
::Leftovers.error <<~MESSAGE
|
20
|
+
Tried using the ::String#pluralize method, but the activesupport gem was not available and/or not required
|
21
21
|
`gem install activesupport`, and/or add `requires: ['active_support', 'active_support/core_ext/string']` to your .leftovers.yml
|
22
22
|
MESSAGE
|
23
23
|
end
|
@@ -15,9 +15,9 @@ module Leftovers
|
|
15
15
|
return unless str
|
16
16
|
|
17
17
|
@then_processor.process(str.singularize, current_node, matched_node, acc)
|
18
|
-
rescue NoMethodError
|
19
|
-
Leftovers.error <<~MESSAGE
|
20
|
-
Tried using the String#singularize method, but the activesupport gem was not available and/or not required
|
18
|
+
rescue ::NoMethodError
|
19
|
+
::Leftovers.error <<~MESSAGE
|
20
|
+
Tried using the ::String#singularize method, but the activesupport gem was not available and/or not required
|
21
21
|
`gem install activesupport`, and/or add `requires: ['active_support', 'active_support/core_ext/string']` to your .leftovers.yml
|
22
22
|
MESSAGE
|
23
23
|
end
|
@@ -15,9 +15,9 @@ module Leftovers
|
|
15
15
|
return unless str
|
16
16
|
|
17
17
|
@then_processor.process(str.titleize, current_node, matched_node, acc)
|
18
|
-
rescue NoMethodError
|
19
|
-
Leftovers.error <<~MESSAGE
|
20
|
-
Tried using the String#titleize method, but the activesupport gem was not available and/or not required
|
18
|
+
rescue ::NoMethodError
|
19
|
+
::Leftovers.error <<~MESSAGE
|
20
|
+
Tried using the ::String#titleize method, but the activesupport gem was not available and/or not required
|
21
21
|
`gem install activesupport`, and/or add `requires: ['active_support', 'active_support/core_ext/string']` to your .leftovers.yml
|
22
22
|
MESSAGE
|
23
23
|
end
|
@@ -15,9 +15,9 @@ module Leftovers
|
|
15
15
|
return unless str
|
16
16
|
|
17
17
|
@then_processor.process(str.underscore, current_node, matched_node, acc)
|
18
|
-
rescue NoMethodError
|
19
|
-
Leftovers.error <<~MESSAGE
|
20
|
-
Tried using the String#underscore method, but the activesupport gem was not available and/or not required
|
18
|
+
rescue ::NoMethodError
|
19
|
+
::Leftovers.error <<~MESSAGE
|
20
|
+
Tried using the ::String#underscore method, but the activesupport gem was not available and/or not required
|
21
21
|
`gem install activesupport`, and/or add `requires: ['active_support', 'active_support/core_ext/string']` to your .leftovers.yml
|
22
22
|
MESSAGE
|
23
23
|
end
|
data/lib/leftovers/processors.rb
CHANGED
@@ -1,49 +1,7 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Leftovers
|
4
4
|
module Processors
|
5
|
-
|
6
|
-
autoload(:AddDefinitionNode, "#{__dir__}/processors/add_definition_node")
|
7
|
-
autoload(:AddDynamicPrefix, "#{__dir__}/processors/add_dynamic_prefix")
|
8
|
-
autoload(:AddDynamicSuffix, "#{__dir__}/processors/add_dynamic_suffix")
|
9
|
-
autoload(:AddPrefix, "#{__dir__}/processors/add_prefix")
|
10
|
-
autoload(:AddSuffix, "#{__dir__}/processors/add_suffix")
|
11
|
-
autoload(:AppendSym, "#{__dir__}/processors/append_sym")
|
12
|
-
autoload(:Camelize, "#{__dir__}/processors/camelize")
|
13
|
-
autoload(:Capitalize, "#{__dir__}/processors/capitalize")
|
14
|
-
autoload(:Deconstantize, "#{__dir__}/processors/deconstantize")
|
15
|
-
autoload(:DeleteAfter, "#{__dir__}/processors/delete_after")
|
16
|
-
autoload(:DeleteAfterLast, "#{__dir__}/processors/delete_after_last")
|
17
|
-
autoload(:DeleteBefore, "#{__dir__}/processors/delete_before")
|
18
|
-
autoload(:DeleteBeforeLast, "#{__dir__}/processors/delete_before_last")
|
19
|
-
autoload(:DeletePrefix, "#{__dir__}/processors/delete_prefix")
|
20
|
-
autoload(:DeleteSuffix, "#{__dir__}/processors/delete_suffix")
|
21
|
-
autoload(:Demodulize, "#{__dir__}/processors/demodulize")
|
22
|
-
autoload(:Downcase, "#{__dir__}/processors/downcase")
|
23
|
-
autoload(:Each, "#{__dir__}/processors/each")
|
24
|
-
autoload(:EachForDefinitionSet, "#{__dir__}/processors/each_for_definition_set")
|
25
|
-
autoload(:EachKeyword, "#{__dir__}/processors/each_keyword")
|
26
|
-
autoload(:EachKeywordArgument, "#{__dir__}/processors/each_keyword_argument")
|
27
|
-
autoload(:EachPositionalArgument, "#{__dir__}/processors/each_positional_argument")
|
28
|
-
autoload(:EachPositionalArgumentFrom, "#{__dir__}/processors/each_positional_argument_from")
|
29
|
-
autoload(:Eval, "#{__dir__}/processors/eval")
|
30
|
-
autoload(:Itself, "#{__dir__}/processors/itself")
|
31
|
-
autoload(:KeywordArgument, "#{__dir__}/processors/keyword_argument")
|
32
|
-
autoload(:MatchCurrentNode, "#{__dir__}/processors/match_current_node")
|
33
|
-
autoload(:MatchMatchedNode, "#{__dir__}/processors/match_matched_node")
|
34
|
-
autoload(:Parameterize, "#{__dir__}/processors/parameterize")
|
35
|
-
autoload(:Placeholder, "#{__dir__}/processors/placeholder")
|
36
|
-
autoload(:Pluralize, "#{__dir__}/processors/pluralize")
|
37
|
-
autoload(:PositionalArgument, "#{__dir__}/processors/positional_argument")
|
38
|
-
autoload(:Receiver, "#{__dir__}/processors/receiver")
|
39
|
-
autoload(:ReplaceValue, "#{__dir__}/processors/replace_value")
|
40
|
-
autoload(:SetDefaultPrivacy, "#{__dir__}/processors/set_default_privacy")
|
41
|
-
autoload(:SetPrivacy, "#{__dir__}/processors/set_privacy")
|
42
|
-
autoload(:Singularize, "#{__dir__}/processors/singularize")
|
43
|
-
autoload(:Split, "#{__dir__}/processors/split")
|
44
|
-
autoload(:Swapcase, "#{__dir__}/processors/swapcase")
|
45
|
-
autoload(:Titleize, "#{__dir__}/processors/titleize")
|
46
|
-
autoload(:Underscore, "#{__dir__}/processors/underscore")
|
47
|
-
autoload(:Upcase, "#{__dir__}/processors/upcase")
|
5
|
+
include Autoloader
|
48
6
|
end
|
49
7
|
end
|
data/lib/leftovers/rake_task.rb
CHANGED
@@ -27,7 +27,7 @@ module Leftovers
|
|
27
27
|
def escaped_argv(argv = @default_argv)
|
28
28
|
return if argv.empty?
|
29
29
|
|
30
|
-
Shellwords.shelljoin(argv)
|
30
|
+
::Shellwords.shelljoin(argv)
|
31
31
|
end
|
32
32
|
|
33
33
|
def describe_task
|
@@ -49,7 +49,7 @@ module Leftovers
|
|
49
49
|
end
|
50
50
|
|
51
51
|
def run(argv)
|
52
|
-
exitstatus =
|
52
|
+
exitstatus = CLI.new(argv: argv).run
|
53
53
|
|
54
54
|
exit exitstatus unless exitstatus == 0
|
55
55
|
end
|
data/lib/leftovers/reporter.rb
CHANGED
@@ -1,63 +1,65 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Leftovers
|
4
|
-
|
5
|
-
|
4
|
+
module Reporter
|
5
|
+
class << self
|
6
|
+
def prepare; end
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
def report(collection)
|
9
|
+
report_list('Only directly called in tests:', collection.with_tests)
|
10
|
+
report_list('Not directly called at all:', collection.without_tests)
|
11
|
+
report_instructions
|
11
12
|
|
12
|
-
|
13
|
-
|
13
|
+
1
|
14
|
+
end
|
14
15
|
|
15
|
-
|
16
|
-
|
16
|
+
def report_success
|
17
|
+
puts green('Everything is used')
|
17
18
|
|
18
|
-
|
19
|
-
|
19
|
+
0
|
20
|
+
end
|
20
21
|
|
21
|
-
|
22
|
+
private
|
22
23
|
|
23
|
-
|
24
|
-
|
24
|
+
def report_instructions
|
25
|
+
puts <<~HELP
|
25
26
|
|
26
|
-
|
27
|
-
|
28
|
-
|
27
|
+
how to resolve: #{green ::Leftovers.resolution_instructions_link}
|
28
|
+
HELP
|
29
|
+
end
|
29
30
|
|
30
|
-
|
31
|
-
|
31
|
+
def report_list(title, list)
|
32
|
+
return if list.empty?
|
32
33
|
|
33
|
-
|
34
|
-
|
35
|
-
|
34
|
+
puts red(title)
|
35
|
+
list.each { |d| print_definition(d) }
|
36
|
+
end
|
36
37
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
38
|
+
def print_definition(definition)
|
39
|
+
puts "#{aqua definition.location_s} " \
|
40
|
+
"#{definition} " \
|
41
|
+
"#{grey definition.highlighted_source("\e[33m", "\e[0;2m")}"
|
42
|
+
end
|
42
43
|
|
43
|
-
|
44
|
-
|
45
|
-
|
44
|
+
def puts(string)
|
45
|
+
::Leftovers.puts(string)
|
46
|
+
end
|
46
47
|
|
47
|
-
|
48
|
-
|
49
|
-
|
48
|
+
def red(string)
|
49
|
+
"\e[31m#{string}\e[0m"
|
50
|
+
end
|
50
51
|
|
51
|
-
|
52
|
-
|
53
|
-
|
52
|
+
def green(string)
|
53
|
+
"\e[32m#{string}\e[0m"
|
54
|
+
end
|
54
55
|
|
55
|
-
|
56
|
-
|
57
|
-
|
56
|
+
def aqua(string)
|
57
|
+
"\e[36m#{string}\e[0m"
|
58
|
+
end
|
58
59
|
|
59
|
-
|
60
|
-
|
60
|
+
def grey(string)
|
61
|
+
"\e[2m#{string}\e[0m"
|
62
|
+
end
|
61
63
|
end
|
62
64
|
end
|
63
65
|
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Leftovers
|
4
|
+
class Runner
|
5
|
+
attr_writer :reporter
|
6
|
+
|
7
|
+
def run
|
8
|
+
reporter.prepare
|
9
|
+
return reporter.report_success if collection.empty?
|
10
|
+
|
11
|
+
reporter.report(collection)
|
12
|
+
end
|
13
|
+
|
14
|
+
def parallel=(value)
|
15
|
+
collector.parallel = value
|
16
|
+
end
|
17
|
+
|
18
|
+
def progress=(value)
|
19
|
+
collector.progress = value
|
20
|
+
end
|
21
|
+
|
22
|
+
def collection
|
23
|
+
@collection ||= begin
|
24
|
+
collector.collect
|
25
|
+
|
26
|
+
collector.collection
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def reporter
|
33
|
+
@reporter ||= Reporter
|
34
|
+
end
|
35
|
+
|
36
|
+
def collector
|
37
|
+
@collector ||= Collector.new
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|