source
stringclasses
1 value
repo
stringlengths
5
63
repo_url
stringlengths
24
82
path
stringlengths
5
167
language
stringclasses
1 value
license
stringclasses
5 values
stars
int64
10
51.4k
ref
stringclasses
23 values
size_bytes
int64
200
258k
text
stringlengths
137
258k
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/matchers/node_name.rb
Ruby
mit
88
main
353
# frozen_string_literal: true module Leftovers module Matchers class NodeName include ComparableInstance attr_reader :matcher def initialize(matcher) @matcher = matcher freeze end def ===(node) name = node.name @matcher === name if name end...
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/matchers/path.rb
Ruby
mit
88
main
341
# frozen_string_literal: true module Leftovers module Matchers class Path include ComparableInstance def initialize(fast_ignore) @fast_ignore = fast_ignore freeze end def ===(path) @fast_ignore.allowed?(path, exists: true, directory: false) end free...
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/matchers/node_has_any_keyword_argument.rb
Ruby
mit
88
main
503
# frozen_string_literal: true module Leftovers module Matchers class NodeHasAnyKeywordArgument include ComparableInstance attr_reader :matcher def initialize(matcher) @matcher = matcher freeze end def ===(node) kwargs = node.kwargs kwargs.childre...
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/matchers/not.rb
Ruby
mit
88
main
291
# frozen_string_literal: true module Leftovers module Matchers class Not include ComparableInstance def initialize(matcher) @matcher = matcher freeze end def ===(value) !(@matcher === value) end freeze end end end
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/matchers/node_scalar_value.rb
Ruby
mit
88
main
456
# frozen_string_literal: true module Leftovers module Matchers class NodeScalarValue include ComparableInstance attr_reader :matcher def initialize(matcher) @matcher = matcher freeze end def ===(node) # can't just check to_scalar_value, it might be false/...
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/matchers/or.rb
Ruby
mit
88
main
343
# frozen_string_literal: true module Leftovers module Matchers class Or include ComparableInstance attr_reader :lhs, :rhs def initialize(lhs, rhs) @lhs = lhs @rhs = rhs freeze end def ===(value) @lhs === value || @rhs === value end fr...
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/matchers/node_pair_key.rb
Ruby
mit
88
main
328
# frozen_string_literal: true module Leftovers module Matchers class NodePairKey include ComparableInstance attr_reader :matcher def initialize(matcher) @matcher = matcher freeze end def ===(node) @matcher === node.first end freeze end ...
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/matchers/all.rb
Ruby
mit
88
main
369
# frozen_string_literal: true module Leftovers module Matchers class All include ComparableInstance attr_reader :matchers def initialize(matchers) @matchers = matchers freeze end def ===(value) @matchers.all? do |matcher| matcher === value ...
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/matchers/node_path.rb
Ruby
mit
88
main
324
# frozen_string_literal: true module Leftovers module Matchers class NodePath include ComparableInstance attr_reader :matcher def initialize(matcher) @matcher = matcher freeze end def ===(node) @matcher === node.path end freeze end end ...
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/matchers/node_privacy.rb
Ruby
mit
88
main
330
# frozen_string_literal: true module Leftovers module Matchers class NodePrivacy include ComparableInstance attr_reader :matcher def initialize(matcher) @matcher = matcher freeze end def ===(node) @matcher === node.privacy end freeze end ...
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/matchers/node_has_positional_argument_with_value.rb
Ruby
mit
88
main
482
# frozen_string_literal: true module Leftovers module Matchers class NodeHasPositionalArgumentWithValue include ComparableInstance def initialize(position, matcher) @position = position @matcher = matcher freeze end def ===(node) args = node.positional_a...
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/matchers/node_has_receiver.rb
Ruby
mit
88
main
375
# frozen_string_literal: true module Leftovers module Matchers class NodeHasReceiver include ComparableInstance attr_reader :matcher def initialize(matcher) @matcher = matcher freeze end def ===(node) receiver = node.receiver @matcher === receiver...
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/matchers/node_pair_value.rb
Ruby
mit
88
main
331
# frozen_string_literal: true module Leftovers module Matchers class NodePairValue include ComparableInstance attr_reader :matcher def initialize(matcher) @matcher = matcher freeze end def ===(node) @matcher === node.second end freeze end...
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/matchers/node_has_any_positional_argument_with_value.rb
Ruby
mit
88
main
372
# frozen_string_literal: true module Leftovers module Matchers class NodeHasAnyPositionalArgumentWithValue include ComparableInstance attr_reader :matcher def initialize(matcher) @matcher = matcher freeze end def ===(node) node.positional_arguments&.any?(...
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/matchers/node_has_positional_argument.rb
Ruby
mit
88
main
367
# frozen_string_literal: true module Leftovers module Matchers class NodeHasPositionalArgument include ComparableInstance def initialize(position) @position = position freeze end def ===(node) args = node.positional_arguments args.length > @position if ...
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/matchers/and.rb
Ruby
mit
88
main
344
# frozen_string_literal: true module Leftovers module Matchers class And include ComparableInstance attr_reader :lhs, :rhs def initialize(lhs, rhs) @lhs = lhs @rhs = rhs freeze end def ===(value) @lhs === value && @rhs === value end f...
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/ast/array_node.rb
Ruby
mit
88
main
225
# frozen_string_literal: true module Leftovers module AST class ArrayNode < Node include HasArguments alias_method :arguments, :children alias_method :as_arguments_list, :arguments end end end
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/ast/nil_node.rb
Ruby
mit
88
main
272
# frozen_string_literal: true module Leftovers module AST class NilNode < Node def to_scalar_value nil end def scalar? true end def to_s '' end def to_sym :nil end end end end
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/ast/send_node.rb
Ruby
mit
88
main
776
# frozen_string_literal: true module Leftovers module AST class SendNode < Node include HasArguments alias_method :receiver, :first alias_method :name, :second alias_method :to_sym, :second def to_s name.to_s end def arguments @memo[:arguments] ||= if ...
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/ast/has_arguments.rb
Ruby
mit
88
main
624
# frozen_string_literal: true module Leftovers module AST module HasArguments def positional_arguments @memo.fetch(:positional_arguments) do @memo[:positional_arguments] = begin if kwargs arguments[0...-1] else arguments end ...
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/ast/builder.rb
Ruby
mit
88
main
1,215
# frozen_string_literal: true require 'parser' module Leftovers module AST class Builder < ::Parser::Builders::Default def n(type, children, source_map) # leftovers:keep self.class.node_class(type).new(type, children, location: source_map) end def self.node_class(type) # rubocop:disab...
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/ast/hash_node.rb
Ruby
mit
88
main
240
# frozen_string_literal: true module Leftovers module AST class HashNode < Node include HasArguments def arguments @memo[:arguments] ||= [self] end def hash? true end end end end
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/ast/var_node.rb
Ruby
mit
88
main
216
# frozen_string_literal: true module Leftovers module AST class VarNode < Node alias_method :name, :first alias_method :to_sym, :first def to_s name.to_s end end end end
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/ast/numeric_node.rb
Ruby
mit
88
main
337
# frozen_string_literal: true module Leftovers module AST class NumericNode < Node alias_method :to_scalar_value, :first def scalar? true end def to_s to_scalar_value.to_s end alias_method :to_literal_s, :to_s def to_sym to_s.to_sym end ...
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/ast/defs_node.rb
Ruby
mit
88
main
259
# frozen_string_literal: true module Leftovers module AST class DefsNode < Node alias_method :name, :second alias_method :to_sym, :second def to_s name.to_s end alias_method :to_literal_s, :to_s end end end
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/ast/node.rb
Ruby
mit
88
main
1,824
# frozen_string_literal: true require 'parser' module Leftovers module AST class Node < ::Parser::AST::Node def initialize(type, children = [], properties = {}) # ::AST::Node#initialize freezes itself. # so can't use normal memoizations @memo = {} super end # ...
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/ast/def_node.rb
Ruby
mit
88
main
256
# frozen_string_literal: true module Leftovers module AST class DefNode < Node alias_method :name, :first alias_method :to_sym, :first def to_s name.to_s end alias_method :to_literal_s, :to_s end end end
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/ast/const_node.rb
Ruby
mit
88
main
257
# frozen_string_literal: true module Leftovers module AST class ConstNode < Node alias_method :receiver, :first alias_method :name, :second alias_method :to_sym, :second def to_s name.to_s end end end end
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/ast/true_node.rb
Ruby
mit
88
main
319
# frozen_string_literal: true module Leftovers module AST class TrueNode < Node def to_scalar_value true end def scalar? true end def to_s 'true' end alias_method :to_literal_s, :to_s def to_sym :true end end end end
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/ast/module_node.rb
Ruby
mit
88
main
229
# frozen_string_literal: true module Leftovers module AST class ModuleNode < Node def name first.name end alias_method :to_sym, :name def to_s name.to_s end end end end
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/ast/casgn_node.rb
Ruby
mit
88
main
317
# frozen_string_literal: true module Leftovers module AST class CasgnNode < Node include HasArguments alias_method :name, :second alias_method :to_sym, :second def to_s name.to_s end def arguments children[2].as_arguments_list end end end end
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/ast/sym_node.rb
Ruby
mit
88
main
382
# frozen_string_literal: true module Leftovers module AST class SymNode < Node alias_method :name, :first alias_method :to_scalar_value, :first alias_method :to_sym, :first def scalar? true end def to_s name.to_s end alias_method :to_literal_s, :...
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/ast/str_node.rb
Ruby
mit
88
main
359
# frozen_string_literal: true module Leftovers module AST class StrNode < Node alias_method :to_scalar_value, :first def name first.to_sym end alias_method :to_s, :first alias_method :to_literal_s, :to_s def to_sym to_s.to_sym end def scalar? ...
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/ast/vasgn_node.rb
Ruby
mit
88
main
310
# frozen_string_literal: true module Leftovers module AST class VasgnNode < Node include HasArguments alias_method :name, :first alias_method :to_sym, :first def to_s name.to_s end def arguments second.as_arguments_list end end end end
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/ast/false_node.rb
Ruby
mit
88
main
323
# frozen_string_literal: true module Leftovers module AST class FalseNode < Node def to_scalar_value false end def scalar? true end def to_s 'false' end alias_method :to_literal_s, :to_s def to_sym :false end end end e...
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/processor_builders/transform_set.rb
Ruby
mit
88
main
768
# frozen_string_literal: true module Leftovers module ProcessorBuilders module TransformSet class << self def build(transforms, final_processor) each_builder(final_processor).each_or_self(transforms) do |transform| case transform when ::Hash, ::Symbol then Transfor...
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/processor_builders/action.rb
Ruby
mit
88
main
2,863
# frozen_string_literal: true module Leftovers module ProcessorBuilders module Action class << self def build(patterns, final_processor) Each.each_or_self(patterns) do |pattern| case pattern when ::String, ::Integer then Argument.build(pattern, final_processor) ...
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/processor_builders/transform_chain.rb
Ruby
mit
88
main
795
# frozen_string_literal: true module Leftovers module ProcessorBuilders module TransformChain class << self def build(transforms, next_transform) case transforms when ::Hash then build_from_hash(transforms, next_transform) when ::Symbol then Transform.build(transforms,...
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/processor_builders/each.rb
Ruby
mit
88
main
2,719
# frozen_string_literal: true module Leftovers module ProcessorBuilders class Each class << self def each_or_self(value, &block) case value when nil then nil when ::Array then build(value.map(&block)) else build([yield(value)]) end end ...
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/processor_builders/dynamic.rb
Ruby
mit
88
main
1,522
# frozen_string_literal: true module Leftovers module ProcessorBuilders module Dynamic class << self def build(dynamic_rules) Each.each_or_self(dynamic_rules) do |dynamic| build_processors(**dynamic) end end private def build_processors( # r...
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/processor_builders/receiver.rb
Ruby
mit
88
main
231
# frozen_string_literal: true module Leftovers module ProcessorBuilders module Receiver def self.build(true_arg, then_processor) Processors::Receiver.new(then_processor) if true_arg end end end end
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/processor_builders/each_for_definition_set.rb
Ruby
mit
88
main
261
# frozen_string_literal: true module Leftovers module ProcessorBuilders class EachForDefinitionSet < Each class << self private def processor_class Processors::EachForDefinitionSet end end end end end
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/processor_builders/value.rb
Ruby
mit
88
main
284
# frozen_string_literal: true module Leftovers module ProcessorBuilders module Value def self.build(values, then_processor) Each.each_or_self(values) do |value| Processors::ReplaceValue.new(value, then_processor) end end end end end
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/processor_builders/argument.rb
Ruby
mit
88
main
1,159
# frozen_string_literal: true module Leftovers module ProcessorBuilders module Argument class << self def build(patterns, processor) # rubocop:disable Metrics/MethodLength Each.each_or_self(patterns) do |pat| case pat when ::Integer then Processors::PositionalArgum...
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/processor_builders/add_prefix.rb
Ruby
mit
88
main
729
# frozen_string_literal: true module Leftovers module ProcessorBuilders module AddPrefix class << self def build(argument, then_processor) case argument when ::Hash then build_hash(argument, then_processor) when ::String then Processors::AddPrefix.new(argument, then_pr...
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/processor_builders/keyword_argument.rb
Ruby
mit
88
main
364
# frozen_string_literal: true module Leftovers module ProcessorBuilders module KeywordArgument def self.build(pattern, then_processor) Processors::KeywordArgument.new( MatcherBuilders::NodePairKey.build( MatcherBuilders::NodeName.build(pattern) ), then_proc...
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/processor_builders/itself.rb
Ruby
mit
88
main
227
# frozen_string_literal: true module Leftovers module ProcessorBuilders module Itself def self.build(true_arg, then_processor) Processors::Itself.new(then_processor) if true_arg end end end end
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/processor_builders/keyword.rb
Ruby
mit
88
main
610
# frozen_string_literal: true module Leftovers module ProcessorBuilders module Keyword def self.build(value, then_processor) return unless value then_processor = case value when true, '**' then then_processor when ::String, ::Hash, ::Array Processors::MatchCurrent...
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/processor_builders/add_suffix.rb
Ruby
mit
88
main
729
# frozen_string_literal: true module Leftovers module ProcessorBuilders module AddSuffix class << self def build(argument, then_processor) case argument when ::Hash then build_hash(argument, then_processor) when ::String then Processors::AddSuffix.new(argument, then_pr...
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/processor_builders/transform.rb
Ruby
mit
88
main
2,227
# frozen_string_literal: true module Leftovers module ProcessorBuilders module Transform def self.build(transform, arguments, then_processor) # rubocop:disable Metrics case transform when :original, nil then then_processor when :downcase then Processors::Downcase.new(then_processor)...
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/config_loader/suggester.rb
Ruby
mit
88
main
510
# frozen_string_literal: true module Leftovers class ConfigLoader class Suggester def initialize(words) @words = words @did_you_mean = ::DidYouMean::SpellChecker.new(dictionary: words) if defined?(::DidYouMean) end def suggest(word) suggestions = did_you_mean.correct(wo...
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/config_loader/privacy_processor_schema.rb
Ruby
mit
88
main
254
# frozen_string_literal: true module Leftovers class ConfigLoader class PrivacyProcessorSchema < ObjectSchema inherit_attributes_from ValueProcessorSchema attribute :to, PrivacySchema, require_group: :privacy_setting end end end
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/config_loader/regexp_schema.rb
Ruby
mit
88
main
634
# frozen_string_literal: true module Leftovers class ConfigLoader class RegexpSchema < StringSchema class << self def validate(node) validate_string(node) && validate_regexp(node) end def validate_string(node) error(node, 'be a string with a valid ruby regexp') ...
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/config_loader/keyword_argument_schema.rb
Ruby
mit
88
main
427
# frozen_string_literal: true module Leftovers class ConfigLoader class KeywordArgumentSchema < ValueOrObjectSchema inherit_attributes_from StringPatternSchema, except: :unless attribute :type, ValueOrArraySchema[ValueTypeSchema], require_group: :matcher attribute :unless, ValueOrArraySchema[Ke...
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/config_loader/string_schema.rb
Ruby
mit
88
main
261
# frozen_string_literal: true module Leftovers class ConfigLoader class StringSchema < Schema class << self def validate(node) error(node, 'be a string') unless node.string? super end end end end end
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/config_loader/keep_test_only_schema.rb
Ruby
mit
88
main
402
# frozen_string_literal: true module Leftovers class ConfigLoader class KeepTestOnlySchema < ValueOrObjectSchema inherit_attributes_from StringPatternSchema, except: :unless inherit_attributes_from RulePatternSchema, except: :unless attribute :unless, ValueOrArraySchema[KeepTestOnlySchema], req...
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/config_loader/precompiler_schema.rb
Ruby
mit
88
main
254
# frozen_string_literal: true module Leftovers class ConfigLoader class PrecompilerSchema < ValueOrObjectSchema attribute :custom, StringSchema, require_group: :custom self.or_value_schema = BuiltInPrecompilerSchema end end end
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/config_loader/scalar_value_schema.rb
Ruby
mit
88
main
432
# frozen_string_literal: true module Leftovers class ConfigLoader class ScalarValueSchema < Schema class << self def validate(node) error(node, 'be any scalar value') unless node.scalar? super end def to_ruby(node) if node.to_ruby.nil? :_le...
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/config_loader/document_schema.rb
Ruby
mit
88
main
2,167
# frozen_string_literal: true module Leftovers class ConfigLoader class DocumentSchema < ObjectSchema attribute :include_paths, ValueOrArraySchema[StringSchema], aliases: :include_path attribute :exclude_paths, ValueOrArraySchema[StringSchema], aliases: :exclude_path attribute :test_paths, Valu...
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/config_loader/value_or_array_schema.rb
Ruby
mit
88
main
652
# frozen_string_literal: true module Leftovers class ConfigLoader class ValueOrArraySchema < ArraySchema def validate(node) if node.array? validate_length(node) && validate_values(node) else validate_or_schema(node) end end def to_ruby(node) ...
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/config_loader/value_processor_schema.rb
Ruby
mit
88
main
414
# frozen_string_literal: true module Leftovers class ConfigLoader class ValueProcessorSchema < ValueOrObjectSchema inherit_attributes_from ValueMatcherSchema attribute :transforms, ValueOrArraySchema[TransformSchema], aliases: :transform inherit_attributes_from TransformSchema, require_group: ...
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/config_loader/string_pattern_schema.rb
Ruby
mit
88
main
487
# frozen_string_literal: true module Leftovers class ConfigLoader class StringPatternSchema < ValueOrObjectSchema attribute :match, RegexpSchema, aliases: :matches, require_group: :matcher attribute :has_prefix, StringSchema, require_group: :matcher attribute :has_suffix, StringSchema, require_...
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/config_loader/value_matcher_schema.rb
Ruby
mit
88
main
818
# frozen_string_literal: true module Leftovers class ConfigLoader class ValueMatcherSchema < ValueOrObjectSchema attribute :arguments, ValueOrArraySchema[ArgumentPositionSchema], aliases: :argument, require_group: :matcher attribute :keywords, ValueOrArraySchema[StringPatternSchema], aliases:...
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/config_loader/object_schema.rb
Ruby
mit
88
main
3,658
# frozen_string_literal: true module Leftovers class ConfigLoader class ObjectSchema < Schema class << self def inherit_attributes_from(schema, require_group: true, except: nil) attributes_and_schemas_to_inherit_from << InheritSchemaAttributes.new( schema, require_group: requi...
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/config_loader/node.rb
Ruby
mit
88
main
2,095
# frozen_string_literal: true module Leftovers class ConfigLoader class Node class_loader = ::Psych::ClassLoader::Restricted.new([], []) TO_RUBY_INSTANCE = ::Psych::Visitors::ToRuby.new( ::Psych::ScalarScanner.new(class_loader), class_loader ) attr_reader :node, :file, :n...
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/config_loader/transform_schema.rb
Ruby
mit
88
main
1,417
# frozen_string_literal: true module Leftovers class ConfigLoader class TransformSchema < ValueOrObjectSchema ArgumentlessTransformSchema.each_value do |transform| attribute( transform, TrueSchema, aliases: ArgumentlessTransformSchema.aliases_for(transform), require_gr...
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/config_loader/require_schema.rb
Ruby
mit
88
main
236
# frozen_string_literal: true module Leftovers class ConfigLoader class RequireSchema < ValueOrObjectSchema attribute :quiet, StringSchema, require_group: :quiet self.or_value_schema = StringSchema end end end
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/config_loader/string_enum_schema.rb
Ruby
mit
88
main
1,364
# frozen_string_literal: true module Leftovers class ConfigLoader class StringEnumSchema < Schema class << self def value(value, aliases: nil) values << value Array(aliases).each do |alias_name| self.aliases[alias_name] = value end end def ...
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/config_loader/value_or_object_schema.rb
Ruby
mit
88
main
898
# frozen_string_literal: true module Leftovers class ConfigLoader class ValueOrObjectSchema < ObjectSchema class << self attr_accessor :or_value_schema def validate(node) if node.hash? super(node) else validate_or_value_schema(node) end...
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/config_loader/dynamic_schema.rb
Ruby
mit
88
main
697
# frozen_string_literal: true module Leftovers class ConfigLoader class DynamicSchema < ObjectSchema inherit_attributes_from RulePatternSchema attribute :call, ValueOrArraySchema[ValueProcessorSchema], aliases: :calls, require_group: :processor attribute :define, ValueOrArraySchema[Val...
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/config_loader/array_schema.rb
Ruby
mit
88
main
1,035
# frozen_string_literal: true module Leftovers class ConfigLoader class ArraySchema < Schema class << self def [](value_schema) new(value_schema) end end attr_reader :value_schema def initialize(value_schema) @value_schema = value_schema super(...
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/config_loader/argumentless_transform_schema.rb
Ruby
mit
88
main
489
# frozen_string_literal: true module Leftovers class ConfigLoader class ArgumentlessTransformSchema < StringEnumSchema value :original value :pluralize value :singularize value :camelize, aliases: :camelcase value :underscore value :titleize, aliases: :titlecase value :d...
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/config_loader/precompile_schema.rb
Ruby
mit
88
main
344
# frozen_string_literal: true module Leftovers class ConfigLoader class PrecompileSchema < ObjectSchema attribute :paths, ValueOrArraySchema[StringSchema], aliases: %i{path include_paths include_path}, require_group: :paths attribute :format, PrecompilerSchema, require_group: :precom...
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/config_loader/schema.rb
Ruby
mit
88
main
600
# frozen_string_literal: true module Leftovers class ConfigLoader class Schema class << self def error(node, requirement) node.error = "#{node.name_}must #{requirement}" false end def validate(node) node.valid? end def to_ruby(node) ...
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/config_loader/inherit_schema_attributes.rb
Ruby
mit
88
main
519
# frozen_string_literal: true module Leftovers class ConfigLoader class InheritSchemaAttributes def initialize(schema, require_group: true, except: nil) @schema = schema @use_require_groups = require_group @except = Array(except) end def attributes @schema.attri...
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/config_loader/attribute.rb
Ruby
mit
88
main
1,033
# frozen_string_literal: true module Leftovers class ConfigLoader class Attribute attr_reader( :name, :aliases, :schema # leftovers:test_only ) attr_accessor :require_group def initialize(name, schema, aliases: nil, require_group: nil, suggest: true) @name = name...
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/config_loader/rule_pattern_schema.rb
Ruby
mit
88
main
1,102
# frozen_string_literal: true module Leftovers class ConfigLoader class RulePatternSchema < ObjectSchema attribute :names, ValueOrArraySchema[StringPatternSchema], aliases: :name, require_group: :matcher attribute :paths, ValueOrArraySchema[StringSchema], aliases: :path, require_group: :match...
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/config_loader/privacy_schema.rb
Ruby
mit
88
main
255
# frozen_string_literal: true module Leftovers class ConfigLoader class PrivacySchema < StringEnumSchema value :public value :protected value :private def self.to_ruby(node) super.to_sym end end end end
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/config_loader/bool_schema.rb
Ruby
mit
88
main
426
# frozen_string_literal: true module Leftovers class ConfigLoader class BoolSchema < Schema class << self def validate(node) error(node, 'be true or false') if to_ruby(node).nil? super end def to_ruby(node) case node.to_ruby when true, 'true'...
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/config_loader/argument_position_schema.rb
Ruby
mit
88
main
436
# frozen_string_literal: true module Leftovers class ConfigLoader class ArgumentPositionSchema < ValueOrObjectSchema inherit_attributes_from StringPatternSchema, except: :unless attribute :type, ValueOrArraySchema[ValueTypeSchema], require_group: :matcher attribute :unless, ValueOrArraySchema[K...
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/config_loader/has_argument_schema.rb
Ruby
mit
88
main
453
# frozen_string_literal: true module Leftovers class ConfigLoader class HasArgumentSchema < ValueOrObjectSchema attribute :at, ValueOrArraySchema[ArgumentPositionSchema], require_group: :matcher attribute :has_value, ValueOrArraySchema[HasValueSchema], require_group: :matcher attribute :unless,...
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/config_loader/has_receiver_schema.rb
Ruby
mit
88
main
441
# frozen_string_literal: true module Leftovers class ConfigLoader class HasReceiverSchema < ValueOrObjectSchema inherit_attributes_from HasValueSchema, except: :unless attribute :literal, ValueOrArraySchema[ScalarValueSchema], require_group: :matcher attribute :unless, ValueOrA...
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/config_loader/built_in_precompiler_schema.rb
Ruby
mit
88
main
230
# frozen_string_literal: true module Leftovers class ConfigLoader class BuiltInPrecompilerSchema < StringEnumSchema value :erb value :yaml value :json value :slim value :haml end end end
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/config_loader/value_matcher_condition_schema.rb
Ruby
mit
88
main
502
# frozen_string_literal: true module Leftovers class ConfigLoader class ValueMatcherConditionSchema < ObjectSchema attribute :has_arguments, ValueOrArraySchema[HasArgumentSchema], aliases: :has_argument attribute :has_receiver, ValueOrArraySchema[HasReceiverSchema] attribute :unless, ValueOrArr...
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/config_loader/value_type_schema.rb
Ruby
mit
88
main
309
# frozen_string_literal: true module Leftovers class ConfigLoader class ValueTypeSchema < StringEnumSchema value :String value :Symbol value :Integer value :Float value :Array value :Hash value :Proc value :Method value :Constant end end end
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/config_loader/string_value_processor_schema.rb
Ruby
mit
88
main
240
# frozen_string_literal: true module Leftovers class ConfigLoader class StringValueProcessorSchema < ValueOrObjectSchema inherit_attributes_from ValueProcessorSchema self.or_value_schema = StringSchema end end end
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/config_loader/scalar_argument_schema.rb
Ruby
mit
88
main
300
# frozen_string_literal: true module Leftovers class ConfigLoader class ScalarArgumentSchema < Schema class << self def validate(node) error(node, 'be a string or an integer') unless node.string? || node.integer? super end end end end end
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/config_loader/true_schema.rb
Ruby
mit
88
main
352
# frozen_string_literal: true module Leftovers class ConfigLoader class TrueSchema < Schema class << self def validate(node) error(node, 'be true') unless to_ruby(node) super end def to_ruby(node) node.to_ruby == true || node.to_ruby == 'true' ...
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/config_loader/has_value_schema.rb
Ruby
mit
88
main
931
# frozen_string_literal: true module Leftovers class ConfigLoader class HasValueSchema < ValueOrObjectSchema attribute :names, ValueOrArraySchema[StringPatternSchema], aliases: :name, require_group: :matcher inherit_attributes_from StringPatternSchema, except: :unless attribute :has_arg...
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/file_collector/comments_processor.rb
Ruby
mit
88
main
2,244
# frozen_string_literal: true module Leftovers class FileCollector module CommentsProcessor class << self def process(comments, collector) comments.each do |comment| process_leftovers_keep_comment(comment, collector) process_leftovers_test_comment(comment, collecto...
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/file_collector/node_processor.rb
Ruby
mit
88
main
3,301
# frozen_string_literal: true require 'parser' module Leftovers class FileCollector class NodeProcessor < ::Parser::AST::Processor # rubocop:disable Metrics/ClassLength include Autoloader def process(ast) super rescue FileCollector::Error raise rescue StandardError => e ...
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/file_collector/node_processor/error.rb
Ruby
mit
88
main
301
# frozen_string_literal: true module Leftovers class FileCollector class NodeProcessor class Error < ::Leftovers::FileCollector::Error attr_reader :node def initialize(message, node) super(message) @node = node end end end end end
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/matcher_builders/node_name.rb
Ruby
mit
88
main
251
# frozen_string_literal: true module Leftovers module MatcherBuilders module NodeName def self.build(name_pattern) matcher = Name.build(name_pattern) Matchers::NodeName.new(matcher) if matcher end end end end
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/matcher_builders/name.rb
Ruby
mit
88
main
665
# frozen_string_literal: true module Leftovers module MatcherBuilders module Name class << self def build(patterns) Or.each_or_self(patterns) do |pat| case pat when ::String then String.build(pat) when ::Hash then build_from_hash(**pat) # :n...
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/matcher_builders/or.rb
Ruby
mit
88
main
2,487
# frozen_string_literal: true require 'set' module Leftovers module MatcherBuilders module Or class << self def each_or_self(value, &block) case value when nil then nil when ::Array then build(value.map(&block)) else build([yield(value)]) end ...
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/matcher_builders/string_pattern.rb
Ruby
mit
88
main
888
# frozen_string_literal: true module Leftovers module MatcherBuilders module StringPattern def self.build(match: nil, has_prefix: nil, has_suffix: nil) # rubocop:disable Metrics has_prefix = ::Regexp.escape(has_prefix) if has_prefix has_suffix = ::Regexp.escape(has_suffix) if has_suffix ...
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/matcher_builders/node_has_receiver.rb
Ruby
mit
88
main
514
# frozen_string_literal: true module Leftovers module MatcherBuilders module NodeHasReceiver class << self def build(pattern) case pattern when true Matchers::NodeHasAnyReceiver when false, :_leftovers_nil_value Matchers::Not.new(Matchers::NodeH...
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/matcher_builders/node_has_block.rb
Ruby
mit
88
main
347
# frozen_string_literal: true module Leftovers module MatcherBuilders module NodeHasBlock class << self def build(has_block) if has_block Matchers::NodeHasBlock elsif has_block == false Matchers::Not.new(Matchers::NodeHasBlock) end end ...
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/matcher_builders/node_has_keyword_argument.rb
Ruby
mit
88
main
761
# frozen_string_literal: true module Leftovers module MatcherBuilders module NodeHasKeywordArgument class << self def build(keywords, value_matcher) value_matcher = NodePairValue.build(value_matcher) keyword_matcher = build_keyword_matcher(keywords) pair_matcher = And....
github
robotdana/leftovers
https://github.com/robotdana/leftovers
lib/leftovers/matcher_builders/document.rb
Ruby
mit
88
main
218
# frozen_string_literal: true module Leftovers module MatcherBuilders module Document def self.build(true_arg) Matchers::NodeName.new(:__leftovers_document) if true_arg end end end end