Module: Leftovers
- Includes:
- Autoloader
- Defined in:
- lib/leftovers/unexpected_case.rb,
lib/leftovers.rb,
lib/leftovers/ast.rb,
lib/leftovers/cli.rb,
lib/leftovers/file.rb,
lib/leftovers/error.rb,
lib/leftovers/config.rb,
lib/leftovers/parser.rb,
lib/leftovers/runner.rb,
lib/leftovers/version.rb,
lib/leftovers/ast/node.rb,
lib/leftovers/matchers.rb,
lib/leftovers/reporter.rb,
lib/leftovers/collector.rb,
lib/leftovers/file_list.rb,
lib/leftovers/rake_task.rb,
lib/leftovers/autoloader.rb,
lib/leftovers/collection.rb,
lib/leftovers/definition.rb,
lib/leftovers/processors.rb,
lib/leftovers/ast/builder.rb,
lib/leftovers/matchers/or.rb,
lib/leftovers/ast/def_node.rb,
lib/leftovers/ast/nil_node.rb,
lib/leftovers/ast/str_node.rb,
lib/leftovers/ast/sym_node.rb,
lib/leftovers/ast/var_node.rb,
lib/leftovers/matchers/all.rb,
lib/leftovers/matchers/and.rb,
lib/leftovers/matchers/any.rb,
lib/leftovers/matchers/not.rb,
lib/leftovers/precompilers.rb,
lib/leftovers/ast/defs_node.rb,
lib/leftovers/ast/hash_node.rb,
lib/leftovers/ast/send_node.rb,
lib/leftovers/ast/true_node.rb,
lib/leftovers/config_loader.rb,
lib/leftovers/matchers/path.rb,
lib/leftovers/merged_config.rb,
lib/leftovers/todo_reporter.rb,
lib/leftovers/ast/array_node.rb,
lib/leftovers/ast/block_node.rb,
lib/leftovers/ast/casgn_node.rb,
lib/leftovers/ast/const_node.rb,
lib/leftovers/ast/false_node.rb,
lib/leftovers/ast/vasgn_node.rb,
lib/leftovers/definition_set.rb,
lib/leftovers/file_collector.rb,
lib/leftovers/ast/module_node.rb,
lib/leftovers/definition_node.rb,
lib/leftovers/processors/each.rb,
lib/leftovers/processors/eval.rb,
lib/leftovers/ast/numeric_node.rb,
lib/leftovers/matcher_builders.rb,
lib/leftovers/precompile_error.rb,
lib/leftovers/precompilers/erb.rb,
lib/leftovers/processors/split.rb,
lib/leftovers/ast/has_arguments.rb,
lib/leftovers/definition_to_add.rb,
lib/leftovers/precompilers/haml.rb,
lib/leftovers/precompilers/json.rb,
lib/leftovers/precompilers/slim.rb,
lib/leftovers/precompilers/yaml.rb,
lib/leftovers/processors/itself.rb,
lib/leftovers/processors/upcase.rb,
lib/leftovers/config_loader/node.rb,
lib/leftovers/matchers/node_name.rb,
lib/leftovers/matchers/node_path.rb,
lib/leftovers/matchers/node_type.rb,
lib/leftovers/processor_builders.rb,
lib/leftovers/comparable_instance.rb,
lib/leftovers/definition_node_set.rb,
lib/leftovers/matcher_builders/or.rb,
lib/leftovers/processors/add_call.rb,
lib/leftovers/processors/camelize.rb,
lib/leftovers/processors/downcase.rb,
lib/leftovers/processors/receiver.rb,
lib/leftovers/processors/swapcase.rb,
lib/leftovers/processors/titleize.rb,
lib/leftovers/config_loader/schema.rb,
lib/leftovers/matcher_builders/and.rb,
lib/leftovers/processors/pluralize.rb,
lib/leftovers/definition_collection.rb,
lib/leftovers/matcher_builders/name.rb,
lib/leftovers/matcher_builders/node.rb,
lib/leftovers/matcher_builders/path.rb,
lib/leftovers/matchers/node_is_proc.rb,
lib/leftovers/matchers/node_privacy.rb,
lib/leftovers/processors/add_prefix.rb,
lib/leftovers/processors/add_suffix.rb,
lib/leftovers/processors/append_sym.rb,
lib/leftovers/processors/capitalize.rb,
lib/leftovers/processors/demodulize.rb,
lib/leftovers/processors/underscore.rb,
lib/leftovers/matchers/node_pair_key.rb,
lib/leftovers/processors/placeholder.rb,
lib/leftovers/processors/set_privacy.rb,
lib/leftovers/processors/singularize.rb,
lib/leftovers/config_loader/attribute.rb,
lib/leftovers/config_loader/suggester.rb,
lib/leftovers/matcher_builders/string.rb,
lib/leftovers/matcher_builders/unless.rb,
lib/leftovers/matchers/node_has_block.rb,
lib/leftovers/processor_builders/each.rb,
lib/leftovers/processors/delete_after.rb,
lib/leftovers/processors/each_keyword.rb,
lib/leftovers/processors/parameterize.rb,
lib/leftovers/matchers/node_pair_value.rb,
lib/leftovers/precompilers/precompiler.rb,
lib/leftovers/processor_builders/value.rb,
lib/leftovers/processors/deconstantize.rb,
lib/leftovers/processors/delete_before.rb,
lib/leftovers/processors/delete_prefix.rb,
lib/leftovers/processors/delete_suffix.rb,
lib/leftovers/processors/replace_value.rb,
lib/leftovers/config_loader/bool_schema.rb,
lib/leftovers/config_loader/true_schema.rb,
lib/leftovers/matcher_builders/document.rb,
lib/leftovers/precompilers/yaml/builder.rb,
lib/leftovers/processor_builders/action.rb,
lib/leftovers/processor_builders/itself.rb,
lib/leftovers/config_loader/array_schema.rb,
lib/leftovers/matcher_builders/node_name.rb,
lib/leftovers/matcher_builders/node_path.rb,
lib/leftovers/matcher_builders/node_type.rb,
lib/leftovers/matchers/node_has_receiver.rb,
lib/leftovers/matchers/node_scalar_value.rb,
lib/leftovers/processor_builders/dynamic.rb,
lib/leftovers/processor_builders/keyword.rb,
lib/leftovers/config_loader/object_schema.rb,
lib/leftovers/config_loader/regexp_schema.rb,
lib/leftovers/config_loader/string_schema.rb,
lib/leftovers/matcher_builders/node_value.rb,
lib/leftovers/processor_builders/argument.rb,
lib/leftovers/processor_builders/receiver.rb,
lib/leftovers/processors/keyword_argument.rb,
lib/leftovers/config_loader/dynamic_schema.rb,
lib/leftovers/config_loader/privacy_schema.rb,
lib/leftovers/config_loader/require_schema.rb,
lib/leftovers/processor_builders/transform.rb,
lib/leftovers/processors/delete_after_last.rb,
lib/leftovers/config_loader/document_schema.rb,
lib/leftovers/file_collector/node_processor.rb,
lib/leftovers/matcher_builders/node_privacy.rb,
lib/leftovers/processor_builders/add_prefix.rb,
lib/leftovers/processor_builders/add_suffix.rb,
lib/leftovers/processors/add_dynamic_prefix.rb,
lib/leftovers/processors/add_dynamic_suffix.rb,
lib/leftovers/processors/delete_before_last.rb,
lib/leftovers/processors/match_current_node.rb,
lib/leftovers/processors/match_matched_node.rb,
lib/leftovers/config_loader/has_value_schema.rb,
lib/leftovers/config_loader/transform_schema.rb,
lib/leftovers/matcher_builders/node_pair_key.rb,
lib/leftovers/matchers/node_has_any_receiver.rb,
lib/leftovers/processors/add_definition_node.rb,
lib/leftovers/processors/positional_argument.rb,
lib/leftovers/processors/set_default_privacy.rb,
lib/leftovers/config_loader/precompile_schema.rb,
lib/leftovers/config_loader/value_type_schema.rb,
lib/leftovers/matcher_builders/node_has_block.rb,
lib/leftovers/matcher_builders/string_pattern.rb,
lib/leftovers/config_loader/precompiler_schema.rb,
lib/leftovers/config_loader/string_enum_schema.rb,
lib/leftovers/matcher_builders/node_pair_value.rb,
lib/leftovers/processor_builders/transform_set.rb,
lib/leftovers/processors/each_keyword_argument.rb,
lib/leftovers/config_loader/has_argument_schema.rb,
lib/leftovers/config_loader/has_receiver_schema.rb,
lib/leftovers/config_loader/rule_pattern_schema.rb,
lib/leftovers/config_loader/scalar_value_schema.rb,
lib/leftovers/file_collector/comments_processor.rb,
lib/leftovers/config_loader/value_matcher_schema.rb,
lib/leftovers/matcher_builders/node_has_argument.rb,
lib/leftovers/matcher_builders/node_has_receiver.rb,
lib/leftovers/processor_builders/transform_chain.rb,
lib/leftovers/processors/each_for_definition_set.rb,
lib/leftovers/config_loader/keep_test_only_schema.rb,
lib/leftovers/config_loader/string_pattern_schema.rb,
lib/leftovers/config_loader/value_or_array_schema.rb,
lib/leftovers/file_collector/node_processor/error.rb,
lib/leftovers/processor_builders/keyword_argument.rb,
lib/leftovers/processors/each_positional_argument.rb,
lib/leftovers/config_loader/scalar_argument_schema.rb,
lib/leftovers/config_loader/value_or_object_schema.rb,
lib/leftovers/config_loader/value_processor_schema.rb,
lib/leftovers/config_loader/keyword_argument_schema.rb,
lib/leftovers/matchers/node_has_positional_argument.rb,
lib/leftovers/config_loader/argument_position_schema.rb,
lib/leftovers/config_loader/privacy_processor_schema.rb,
lib/leftovers/matchers/node_has_any_keyword_argument.rb,
lib/leftovers/config_loader/inherit_schema_attributes.rb,
lib/leftovers/processors/each_positional_argument_from.rb,
lib/leftovers/config_loader/built_in_precompiler_schema.rb,
lib/leftovers/matcher_builders/node_has_keyword_argument.rb,
lib/leftovers/processor_builders/each_for_definition_set.rb,
lib/leftovers/config_loader/argumentless_transform_schema.rb,
lib/leftovers/config_loader/string_value_processor_schema.rb,
lib/leftovers/config_loader/value_matcher_condition_schema.rb,
lib/leftovers/matcher_builders/node_has_positional_argument.rb,
lib/leftovers/matchers/node_has_positional_argument_with_value.rb,
lib/leftovers/matchers/node_has_any_positional_argument_with_value.rb
Overview
Defined Under Namespace
Modules: AST, Autoloader, ComparableInstance, MatcherBuilders, Matchers, Parser, Precompilers, ProcessorBuilders, Processors, Reporter, TodoReporter
Classes: CLI, Collection, Collector, Config, ConfigLoader, Definition, DefinitionCollection, DefinitionNode, DefinitionNodeSet, DefinitionSet, DefinitionToAdd, Error, Exit, File, FileCollector, FileList, MergedConfig, PrecompileError, RakeTask, Runner, UnexpectedCase
Constant Summary
collapse
- MEMOIZED_IVARS =
%i{
@config
@try_require_cache
@stdout
@stderr
@pwd
}.freeze
- VERSION =
'0.12.2'
Constants included
from Autoloader
Autoloader::ALL_CAPS_NAMES
Class Attribute Summary collapse
Class Method Summary
collapse
Methods included from Autoloader
class_from_path, dir_path_from_class, glob_children, included, root
Class Attribute Details
.stderr ⇒ Object
30
31
32
|
# File 'lib/leftovers.rb', line 30
def stderr
@stderr ||= ::StringIO.new
end
|
.stdout ⇒ Object
26
27
28
|
# File 'lib/leftovers.rb', line 26
def stdout
@stdout ||= ::StringIO.new
end
|
Class Method Details
.config ⇒ Object
34
35
36
|
# File 'lib/leftovers.rb', line 34
def config
@config ||= MergedConfig.new(load_defaults: true)
end
|
.error(message, did_you_mean = nil) ⇒ Object
52
53
54
55
56
|
# File 'lib/leftovers.rb', line 52
def error(message, did_you_mean = nil)
warn("\e[31m#{message}\e[0m")
warn("\n#{did_you_mean}") if did_you_mean
raise Exit, 1
end
|
.exit(status = 0) ⇒ Object
70
71
72
|
# File 'lib/leftovers.rb', line 70
def exit(status = 0)
raise Exit, status
end
|
.print(message) ⇒ Object
62
63
64
|
# File 'lib/leftovers.rb', line 62
def print(message)
stdout.print("\e[2K#{message}\r")
end
|
.puts(message) ⇒ Object
58
59
60
|
# File 'lib/leftovers.rb', line 58
def puts(message)
stdout.puts("\e[2K#{message}")
end
|
.pwd ⇒ Object
66
67
68
|
# File 'lib/leftovers.rb', line 66
def pwd
@pwd ||= ::Pathname.new(::Dir.pwd + '/')
end
|
.reset ⇒ Object
38
39
40
41
42
|
# File 'lib/leftovers.rb', line 38
def reset
MEMOIZED_IVARS.each do |ivar|
remove_instance_variable(ivar) if instance_variable_get(ivar)
end
end
|
.resolution_instructions_link ⇒ Object
44
45
46
|
# File 'lib/leftovers.rb', line 44
def resolution_instructions_link
"https://github.com/robotdana/leftovers/tree/v#{VERSION}/README.md#how-to-resolve"
end
|
.try_require(requirable, message: nil) ⇒ Object
74
75
76
77
|
# File 'lib/leftovers.rb', line 74
def try_require(requirable, message: nil)
warn message if !try_require_cache(requirable) && message
try_require_cache(requirable)
end
|
.unwrap_array(array) ⇒ Object
87
88
89
90
91
92
93
|
# File 'lib/leftovers.rb', line 87
def unwrap_array(array)
if array.length <= 1
array.first
else
array
end
end
|
.warn(message) ⇒ Object
48
49
50
|
# File 'lib/leftovers.rb', line 48
def warn(message)
stderr.puts("\e[2K#{message}")
end
|
.wrap_array(value) ⇒ Object
79
80
81
82
83
84
85
|
# File 'lib/leftovers.rb', line 79
def wrap_array(value)
case value
when nil then []
when ::Array then value
else [value]
end
end
|