Module: Enumpath
- Defined in:
- lib/enumpath.rb,
lib/enumpath/path.rb,
lib/enumpath/logger.rb,
lib/enumpath/results.rb,
lib/enumpath/version.rb,
lib/enumpath/operator.rb,
lib/enumpath/path_cache.rb,
lib/enumpath/operator/base.rb,
lib/enumpath/regexp_parser.rb,
lib/enumpath/operator/child.rb,
lib/enumpath/operator/slice.rb,
lib/enumpath/operator/union.rb,
lib/enumpath/regexp_timeout.rb,
lib/enumpath/resolver/simple.rb,
lib/enumpath/operator/wildcard.rb,
lib/enumpath/resolver/property.rb,
lib/enumpath/path/normalized_path.rb,
lib/enumpath/resolver/object_inspector.rb,
lib/enumpath/operator/filter_expression.rb,
lib/enumpath/operator/recursive_descent.rb,
lib/enumpath/operator/subscript_expression.rb
Overview
TODO: Investigate supporting anchored paths ($.foo.bar..., @.foo.bar...)
Defined Under Namespace
Modules: Operator, RegexpParser, RegexpTimeout, Resolver Classes: Path, PathCache, Results
Constant Summary collapse
- VERBOSE_KEY =
The
Thread.currentkey that holds the:verboseoption of the current apply call :enumpath_verbose- VERSION =
'0.4.0'
Class Attribute Summary collapse
-
.verbose ⇒ true, false
Whether verbose mode is enabled.
Class Method Summary collapse
-
.apply(path, enum, options = {}) ⇒ Object
Resolve a path expression against an enumerable.
Class Attribute Details
.verbose ⇒ true, false
Whether verbose mode is enabled. When enabled, the Logger will print
information to the logging stream to assist in debugging path expressions. During an apply call this
is the call's :verbose option, if it has one, and only in that call's thread; otherwise it is the default set
with verbose=. Defaults to false
43 44 45 46 47 48 |
# File 'lib/enumpath.rb', line 43 def verbose return @verbose if @verbose_overrides.zero? override = Thread.current[VERBOSE_KEY] override.nil? ? @verbose : override end |
Class Method Details
.apply(path, enum, options = {}) ⇒ Object
Resolve a path expression against an enumerable
72 73 74 75 76 77 78 79 80 81 |
# File 'lib/enumpath.rb', line 72 def apply(path, enum, = {}) with_verbose([:verbose]) do logger.level = 0 if verbose Enumpath::Resolver::Property.with_policy([:property_resolver]) do Enumpath::RegexpTimeout.with_limit(.fetch(:regexp_timeout, Enumpath::RegexpTimeout::DEFAULT)) do Enumpath::Path.new(path, result_type: [:result_type]).apply(enum) end end end end |