enumpath 0.1.2 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +180 -31
- data/lib/enumpath/operator/base.rb +26 -11
- data/lib/enumpath/operator/subscript_expression.rb +50 -1
- data/lib/enumpath/path.rb +10 -3
- data/lib/enumpath/resolver/object_inspector.rb +70 -0
- data/lib/enumpath/resolver/property.rb +227 -8
- data/lib/enumpath/resolver/simple.rb +35 -1
- data/lib/enumpath/version.rb +1 -1
- data/lib/enumpath.rb +13 -2
- metadata +43 -46
- data/.github/ISSUE_TEMPLATE/bug_report.md +0 -38
- data/.github/ISSUE_TEMPLATE/feature_request.md +0 -20
- data/.github/workflows/greetings.yml +0 -13
- data/.github/workflows/rubocop-analysis.yml +0 -47
- data/.github/workflows/ruby.yml +0 -35
- data/.gitignore +0 -15
- data/.rspec +0 -3
- data/.rubocop.yml +0 -12
- data/.yardopts +0 -1
- data/CONTRIBUTING.md +0 -96
- data/Gemfile +0 -8
- data/Gemfile.lock +0 -61
- data/Rakefile +0 -13
- data/bin/console +0 -15
- data/bin/setup +0 -8
- data/enumpath.gemspec +0 -45
|
@@ -2,21 +2,240 @@
|
|
|
2
2
|
|
|
3
3
|
module Enumpath
|
|
4
4
|
module Resolver
|
|
5
|
-
# A utility for resolving a string as a property of an object
|
|
5
|
+
# A utility for resolving a string as a property (a public method that expects no arguments) of an object.
|
|
6
|
+
#
|
|
7
|
+
# Which properties resolve is decided by a property resolver policy, set with the `:property_resolver` option of
|
|
8
|
+
# {Enumpath.apply}:
|
|
9
|
+
#
|
|
10
|
+
# - `:safe` (the default): read-only access only. See {.safe?}.
|
|
11
|
+
# - `:readers`: `:safe`, plus public methods written in Ruby (including those of installed gems) and
|
|
12
|
+
# ActiveModel-style `attributes`. See {.reader?}. This runs application and gem code and is not read-only.
|
|
13
|
+
# - `:none`: never call methods. Indexes, keys and Struct or Data members still resolve through
|
|
14
|
+
# {Resolver::Simple}.
|
|
15
|
+
# - `:all`: call any public method that expects no arguments. This was the behavior of version 0.1 and lets a
|
|
16
|
+
# path run mutating or destructive methods such as `clear`, `pop` or `destroy`. Only use it with trusted paths.
|
|
17
|
+
# - a callable (anything that responds to `call`, such as a lambda): called as `callable.call(object, name)` with
|
|
18
|
+
# the property name as a String; the method is called only when it returns a truthy value. The callable has
|
|
19
|
+
# full control: none of the checks of the other policies are applied. It can call {.safe?} or {.reader?} to
|
|
20
|
+
# build on them.
|
|
21
|
+
#
|
|
22
|
+
# The policy for the current {Enumpath.apply} call is kept in a fiber-local variable (`Thread.current`), so it
|
|
23
|
+
# reaches every operator without being passed through each one, and calls running in other threads or fibers do
|
|
24
|
+
# not see it. Outside of {Enumpath.apply}, and in a chained {Enumpath::Results#apply} that does not pass the
|
|
25
|
+
# option again, the default (`:safe`) applies.
|
|
6
26
|
class Property
|
|
27
|
+
# The policies accepted by the `:property_resolver` option, besides a callable
|
|
28
|
+
POLICIES = %i[safe readers none all].freeze
|
|
29
|
+
|
|
30
|
+
# The policy used when none is given
|
|
31
|
+
DEFAULT_POLICY = :safe
|
|
32
|
+
|
|
33
|
+
# Property names `:safe` and `:readers` will consider: plain identifiers, optionally ending in `?`. Names ending
|
|
34
|
+
# in `!` or `=`, operators and constant-like names are never called.
|
|
35
|
+
IDENTIFIER = /\A[a-z_][A-Za-z0-9_]*\??\z/.freeze
|
|
36
|
+
|
|
37
|
+
# Read-only methods `:safe` calls on {SAFE_RECEIVERS}. Each returns a new value and leaves the receiver
|
|
38
|
+
# unchanged in Ruby's own implementation. Mutating methods (`clear`, `pop`, `shift`, `delete`, `freeze`, any `!`
|
|
39
|
+
# method) are deliberately absent.
|
|
40
|
+
SAFE_METHODS = %w[
|
|
41
|
+
length size count empty? any? all? none? one?
|
|
42
|
+
first last min max minmax sum
|
|
43
|
+
keys values entries to_a to_h
|
|
44
|
+
reverse compact sort uniq flatten
|
|
45
|
+
to_s to_sym to_i to_f to_r to_c
|
|
46
|
+
nil? zero? nonzero? positive? negative? even? odd? finite? infinite? integer?
|
|
47
|
+
abs floor ceil round truncate next pred succ
|
|
48
|
+
upcase downcase capitalize swapcase strip lstrip rstrip chomp chop bytesize
|
|
49
|
+
].freeze
|
|
50
|
+
|
|
51
|
+
# The plain data classes on which `:safe` calls {SAFE_METHODS}. Other objects that define methods with the same
|
|
52
|
+
# names (an IO, an Enumerator, a database relation, a custom collection) could run arbitrary code or consume
|
|
53
|
+
# input. Range is left out because methods like `sum` and `sort` never return on an endless range.
|
|
54
|
+
SAFE_RECEIVERS = ([Array, Hash, String, Symbol, Numeric, NilClass, TrueClass, FalseClass, Struct] +
|
|
55
|
+
[Simple::DATA_CLASS].compact).freeze
|
|
56
|
+
|
|
57
|
+
# Modules whose implementation of a {SAFE_METHODS} name is trusted. A subclass of a {SAFE_RECEIVERS} class that
|
|
58
|
+
# overrides one of these methods is not trusted.
|
|
59
|
+
CORE_OWNERS = (SAFE_RECEIVERS + [Kernel, Comparable, Enumerable, Integer, Float, Rational, Complex]).freeze
|
|
60
|
+
|
|
61
|
+
# Instances of these classes are core objects: their instance variables never make a property resolvable, and
|
|
62
|
+
# `:readers` treats them exactly like `:safe`. Modules and classes are included because their instance
|
|
63
|
+
# variables are usually internal state (memoized values, configuration), not data.
|
|
64
|
+
CORE_CLASSES = (SAFE_RECEIVERS + [Range, Module, Proc, Method, UnboundMethod, IO, Enumerator, Thread]).freeze
|
|
65
|
+
|
|
66
|
+
# Common persistence verbs `:readers` refuses to call even when the object's class defines them. This is a
|
|
67
|
+
# safety net for ActiveRecord-style models, not a guarantee: `:readers` still runs any other public method that
|
|
68
|
+
# expects no arguments.
|
|
69
|
+
READERS_DENYLIST = %w[destroy delete save update reload touch delete_all destroy_all toggle].freeze
|
|
70
|
+
|
|
71
|
+
# The `Thread.current` key that holds the policy for the current {Enumpath.apply} call
|
|
72
|
+
THREAD_KEY = :enumpath_property_resolver
|
|
73
|
+
|
|
7
74
|
class << self
|
|
8
|
-
# Attempts to resolve a string as a property of an object
|
|
9
|
-
# expects no arguments.
|
|
75
|
+
# Attempts to resolve a string as a property of an object, as the policy allows
|
|
10
76
|
#
|
|
11
77
|
# @param property [String] the name of the property to attempt to resolve
|
|
12
78
|
# @param object [Object] the object to resolve the property against
|
|
13
|
-
# @
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
object
|
|
17
|
-
rescue ArgumentError, NoMethodError
|
|
79
|
+
# @param policy [Symbol, #call] the property resolver policy to apply; defaults to {.current_policy}
|
|
80
|
+
# @return the resolved property value, or nil if it could not be resolved or the policy does not allow it
|
|
81
|
+
def resolve(property, object, policy = current_policy)
|
|
82
|
+
access(policy, object, property.to_s)&.call
|
|
83
|
+
rescue ArgumentError, NoMethodError, TypeError, RangeError
|
|
18
84
|
nil
|
|
19
85
|
end
|
|
86
|
+
|
|
87
|
+
# The policy for the current {Enumpath.apply} call in this thread or fiber
|
|
88
|
+
#
|
|
89
|
+
# @return [Symbol, #call] the current policy, or {DEFAULT_POLICY} when none is set
|
|
90
|
+
def current_policy
|
|
91
|
+
Thread.current[THREAD_KEY] || DEFAULT_POLICY
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
# Runs the block with a policy as the {.current_policy}, then restores the previous policy, even if the block
|
|
95
|
+
# raises. Used by {Enumpath.apply}.
|
|
96
|
+
#
|
|
97
|
+
# @private
|
|
98
|
+
# @param policy [Symbol, #call, nil] the policy to use; nil means {DEFAULT_POLICY}
|
|
99
|
+
# @raise [ArgumentError] if the policy is not valid
|
|
100
|
+
# @return the value of the block
|
|
101
|
+
def with_policy(policy)
|
|
102
|
+
policy = validate_policy!(policy.nil? ? DEFAULT_POLICY : policy)
|
|
103
|
+
previous = Thread.current[THREAD_KEY]
|
|
104
|
+
Thread.current[THREAD_KEY] = policy
|
|
105
|
+
begin
|
|
106
|
+
yield
|
|
107
|
+
ensure
|
|
108
|
+
Thread.current[THREAD_KEY] = previous
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
# Whether the `:safe` policy resolves a property of an object. All of these must hold:
|
|
113
|
+
#
|
|
114
|
+
# - the name is a plain identifier (see {IDENTIFIER});
|
|
115
|
+
# - the object publicly responds to it and the method has no required arguments;
|
|
116
|
+
# - and either
|
|
117
|
+
# - the name is in {SAFE_METHODS}, the object is one of {SAFE_RECEIVERS}, and the method is Ruby's own
|
|
118
|
+
# (owned by one of {CORE_OWNERS}, not overridden), in which case the method is called; or
|
|
119
|
+
# - the object is not one of {CORE_CLASSES} and has an instance variable of the same name (`@name` for
|
|
120
|
+
# `name`), as an attr_reader on a plain Ruby object does. In that case the instance variable is read
|
|
121
|
+
# directly and the method itself is never called, so a method that merely shares its name with an
|
|
122
|
+
# instance variable cannot run.
|
|
123
|
+
#
|
|
124
|
+
# Struct and Data members are not handled here: they resolve as members through {Resolver::Simple}.
|
|
125
|
+
#
|
|
126
|
+
# A callable policy can build on this check to allow more methods while keeping the safe ones:
|
|
127
|
+
#
|
|
128
|
+
# @example Keep the safe defaults and allow specific methods per class
|
|
129
|
+
# ALLOWED = { 'Invoice' => %w[total due_on], 'Customer' => %w[name email] }.freeze
|
|
130
|
+
# policy = lambda do |object, name|
|
|
131
|
+
# Enumpath::Resolver::Property.safe?(object, name) || ALLOWED.fetch(object.class.name, []).include?(name)
|
|
132
|
+
# end
|
|
133
|
+
# Enumpath.apply('invoices.*.total', account, property_resolver: policy)
|
|
134
|
+
#
|
|
135
|
+
# @param object [Object] the object to read from
|
|
136
|
+
# @param name [String] the property name
|
|
137
|
+
# @return [true, false]
|
|
138
|
+
def safe?(object, name)
|
|
139
|
+
!safe_access(object, name).nil?
|
|
140
|
+
rescue StandardError
|
|
141
|
+
false
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
# Whether the `:readers` policy resolves a property of an object. Core objects (see {CORE_CLASSES}) are
|
|
145
|
+
# treated exactly like {.safe?}. For any other object, either
|
|
146
|
+
#
|
|
147
|
+
# - the name is a plain identifier (see {IDENTIFIER}), not in {READERS_DENYLIST}, and the object publicly
|
|
148
|
+
# responds to it with a method that expects no arguments and is written in Ruby outside of Ruby itself (see
|
|
149
|
+
# {ObjectInspector.application_method?}), so computed readers like `full_name` work; or
|
|
150
|
+
# - the object has an ActiveModel-style `attributes` method (no arguments, written in Ruby outside of Ruby
|
|
151
|
+
# itself) that returns a Hash with the name as a String key, so attributes like `email` work even before
|
|
152
|
+
# their reader methods are defined; or
|
|
153
|
+
# - {.safe?} allows it.
|
|
154
|
+
#
|
|
155
|
+
# In short, `:readers` runs any public method that expects no arguments and is written in Ruby, except Ruby's
|
|
156
|
+
# built-in methods, methods in the Ruby standard library directory, and {READERS_DENYLIST}. Methods
|
|
157
|
+
# implemented in C (core classes, StringIO, C-extension gems) are never called; objects of C-extension classes
|
|
158
|
+
# need a callable policy or `:all`. Methods from installed gems are called, including default and bundled gems
|
|
159
|
+
# such as Logger and CSV, and ActiveModel or ActiveRecord: for example `Logger#close` would run.
|
|
160
|
+
#
|
|
161
|
+
# So `:readers` is not read-only. Use it for data you trust or objects you built. For untrusted paths use
|
|
162
|
+
# `:safe`, or a callable that builds on {.safe?} with a per-class allowlist.
|
|
163
|
+
#
|
|
164
|
+
# @param object [Object] the object to read from
|
|
165
|
+
# @param name [String] the property name
|
|
166
|
+
# @return [true, false]
|
|
167
|
+
def reader?(object, name)
|
|
168
|
+
!reader_access(object, name).nil?
|
|
169
|
+
rescue StandardError
|
|
170
|
+
false
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
private
|
|
174
|
+
|
|
175
|
+
# Each *access method returns nil when the property may not be resolved, or a lambda that resolves it
|
|
176
|
+
def access(policy, object, name)
|
|
177
|
+
case policy
|
|
178
|
+
when :all then -> { object.public_send(name.to_sym) }
|
|
179
|
+
when :none then nil
|
|
180
|
+
when :safe then safe_access(object, name)
|
|
181
|
+
when :readers then reader_access(object, name)
|
|
182
|
+
else (-> { object.public_send(name.to_sym) } if policy.call(object, name))
|
|
183
|
+
end
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
def safe_access(object, name)
|
|
187
|
+
return unless name.match?(IDENTIFIER)
|
|
188
|
+
|
|
189
|
+
method = ObjectInspector.public_method_without_required_args(object, name)
|
|
190
|
+
return if method.nil?
|
|
191
|
+
return -> { object.public_send(name.to_sym) } if core_reader?(object, name, method)
|
|
192
|
+
|
|
193
|
+
instance_variable_access(object, name)
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
def reader_access(object, name)
|
|
197
|
+
return safe_access(object, name) if ObjectInspector.instance_of_any?(object, CORE_CLASSES)
|
|
198
|
+
return unless name.match?(IDENTIFIER)
|
|
199
|
+
return if READERS_DENYLIST.include?(name)
|
|
200
|
+
|
|
201
|
+
app_method_access(object, name) || attribute_access(object, name) || safe_access(object, name)
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
def app_method_access(object, name)
|
|
205
|
+
method = ObjectInspector.public_method_without_required_args(object, name)
|
|
206
|
+
return unless ObjectInspector.application_method?(method)
|
|
207
|
+
|
|
208
|
+
-> { object.public_send(name.to_sym) }
|
|
209
|
+
end
|
|
210
|
+
|
|
211
|
+
def attribute_access(object, name)
|
|
212
|
+
method = ObjectInspector.public_method_without_required_args(object, 'attributes')
|
|
213
|
+
return unless ObjectInspector.application_method?(method)
|
|
214
|
+
|
|
215
|
+
attributes = object.public_send(:attributes)
|
|
216
|
+
-> { attributes[name] } if attributes.is_a?(Hash) && attributes.key?(name)
|
|
217
|
+
end
|
|
218
|
+
|
|
219
|
+
def validate_policy!(policy)
|
|
220
|
+
return policy if POLICIES.include?(policy) || policy.respond_to?(:call)
|
|
221
|
+
|
|
222
|
+
raise ArgumentError, "Invalid property_resolver #{policy.inspect}: use :#{POLICIES.join(', :')} or a callable"
|
|
223
|
+
end
|
|
224
|
+
|
|
225
|
+
def core_reader?(object, name, method)
|
|
226
|
+
SAFE_METHODS.include?(name) &&
|
|
227
|
+
ObjectInspector.instance_of_any?(object, SAFE_RECEIVERS) &&
|
|
228
|
+
CORE_OWNERS.include?(method.owner)
|
|
229
|
+
end
|
|
230
|
+
|
|
231
|
+
def instance_variable_access(object, name)
|
|
232
|
+
return if name.end_with?('?') || ObjectInspector.instance_of_any?(object, CORE_CLASSES)
|
|
233
|
+
|
|
234
|
+
ivar = "@#{name}"
|
|
235
|
+
return unless ObjectInspector.kernel(object, :instance_variable_defined?, ivar)
|
|
236
|
+
|
|
237
|
+
-> { ObjectInspector.kernel(object, :instance_variable_get, ivar) }
|
|
238
|
+
end
|
|
20
239
|
end
|
|
21
240
|
end
|
|
22
241
|
end
|
|
@@ -6,8 +6,13 @@ module Enumpath
|
|
|
6
6
|
class Simple
|
|
7
7
|
NUMERIC_INDEX_TEST = /\A\-?(?:0|[1-9][0-9]*)\z/
|
|
8
8
|
|
|
9
|
+
# Ruby's `Data` class (3.2 and later), or nil on older Rubies. Older Rubies have an unrelated, deprecated `Data`
|
|
10
|
+
# constant, so it is only looked up on 3.2 and later.
|
|
11
|
+
DATA_CLASS = ((RUBY_VERSION.split('.').map(&:to_i) <=> [3, 2]) >= 0 ? Object.const_get(:Data) : nil)
|
|
12
|
+
|
|
9
13
|
class << self
|
|
10
|
-
# Attempts to resolve a string as an index, key, or member of an enumerable
|
|
14
|
+
# Attempts to resolve a string as an index, key, or member of an enumerable. Members of `Data` objects
|
|
15
|
+
# (Ruby 3.2 and later) resolve like Struct members.
|
|
11
16
|
#
|
|
12
17
|
# @param variable [String] the value to attempt to resolve
|
|
13
18
|
# @param enum [Enumerable] the enumerable to resolve the value against
|
|
@@ -17,11 +22,40 @@ module Enumpath
|
|
|
17
22
|
value = rescued_dig(enum, variable.to_i) if variable =~ NUMERIC_INDEX_TEST
|
|
18
23
|
value = rescued_dig(enum, variable) if value.nil?
|
|
19
24
|
value = rescued_dig(enum, variable.to_sym) if value.nil?
|
|
25
|
+
value = data_member(enum, variable) if value.nil?
|
|
20
26
|
value
|
|
21
27
|
end
|
|
22
28
|
|
|
29
|
+
# Whether an object is a `Data` object (Ruby 3.2 and later)
|
|
30
|
+
#
|
|
31
|
+
# @private
|
|
32
|
+
# @param object [Object]
|
|
33
|
+
# @return [true, false]
|
|
34
|
+
def data?(object)
|
|
35
|
+
!DATA_CLASS.nil? && Kernel.instance_method(:is_a?).bind(object).call(DATA_CLASS)
|
|
36
|
+
rescue TypeError
|
|
37
|
+
false
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# The member names of a `Data` object, read without calling any method the object's class defines
|
|
41
|
+
#
|
|
42
|
+
# @private
|
|
43
|
+
# @param object [Data]
|
|
44
|
+
# @return [Array<Symbol>]
|
|
45
|
+
def data_members(object)
|
|
46
|
+
DATA_CLASS.instance_method(:members).bind(object).call
|
|
47
|
+
end
|
|
48
|
+
|
|
23
49
|
private
|
|
24
50
|
|
|
51
|
+
# Reads a member of a `Data` object through Data#to_h, which reads the stored values directly, so a member
|
|
52
|
+
# reader overridden in the class is not called
|
|
53
|
+
def data_member(enum, variable)
|
|
54
|
+
return unless data?(enum) && data_members(enum).include?(variable.to_sym)
|
|
55
|
+
|
|
56
|
+
DATA_CLASS.instance_method(:to_h).bind(enum).call[variable.to_sym]
|
|
57
|
+
end
|
|
58
|
+
|
|
25
59
|
def rescued_dig(enum, typecast_variable)
|
|
26
60
|
enum.dig(typecast_variable)
|
|
27
61
|
rescue NoMethodError, TypeError
|
data/lib/enumpath/version.rb
CHANGED
data/lib/enumpath.rb
CHANGED
|
@@ -5,6 +5,7 @@ require 'enumpath/logger'
|
|
|
5
5
|
require 'enumpath/operator'
|
|
6
6
|
require 'enumpath/path'
|
|
7
7
|
require 'enumpath/results'
|
|
8
|
+
require 'enumpath/resolver/object_inspector'
|
|
8
9
|
require 'enumpath/resolver/simple'
|
|
9
10
|
require 'enumpath/resolver/property'
|
|
10
11
|
require 'enumpath/version'
|
|
@@ -28,11 +29,21 @@ module Enumpath
|
|
|
28
29
|
# @param options [optional, Hash]
|
|
29
30
|
# @option options [Symbol] :result_type (:value) The type of results to return, `:value` or `:path`
|
|
30
31
|
# @option options [true, false] :verbose (false) Whether to enable additional output for debugging
|
|
32
|
+
# @option options [Symbol, #call] :property_resolver (:safe) Which methods a path may call on an object when a
|
|
33
|
+
# segment is not an index, key, or member: `:safe` (read-only methods only), `:readers` (`:safe` plus public
|
|
34
|
+
# no-argument methods written in Ruby, including those of installed gems, and ActiveModel-style `attributes`;
|
|
35
|
+
# not read-only, for trusted data only), `:none`, `:all` (any public method that expects no arguments, the
|
|
36
|
+
# behavior of version 0.1), or a callable `->(object, name) { ... }` that returns true to allow the call.
|
|
37
|
+
# Applies only to this call; a chained {Enumpath::Results#apply} uses the default unless the option is passed
|
|
38
|
+
# again. See {Enumpath::Resolver::Property}.
|
|
39
|
+
# @raise [ArgumentError] if `:property_resolver` is not one of the values above
|
|
31
40
|
# @return (see Enumpath::Path#apply)
|
|
32
41
|
def apply(path, enum, options = {})
|
|
33
42
|
logger.level = 0
|
|
34
|
-
@verbose = options
|
|
35
|
-
Enumpath::
|
|
43
|
+
@verbose = options[:verbose] || false
|
|
44
|
+
Enumpath::Resolver::Property.with_policy(options[:property_resolver]) do
|
|
45
|
+
Enumpath::Path.new(path, result_type: options[:result_type]).apply(enum)
|
|
46
|
+
end
|
|
36
47
|
end
|
|
37
48
|
|
|
38
49
|
# The {Enumpath::Logger} instance to use with verbose mode
|
metadata
CHANGED
|
@@ -1,15 +1,28 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: enumpath
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1
|
|
4
|
+
version: 0.2.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Chris Bloom
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: logger
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
- - ">="
|
|
17
|
+
- !ruby/object:Gem::Version
|
|
18
|
+
version: '1.4'
|
|
19
|
+
type: :runtime
|
|
20
|
+
prerelease: false
|
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
22
|
+
requirements:
|
|
23
|
+
- - ">="
|
|
24
|
+
- !ruby/object:Gem::Version
|
|
25
|
+
version: '1.4'
|
|
13
26
|
- !ruby/object:Gem::Dependency
|
|
14
27
|
name: mini_cache
|
|
15
28
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -39,117 +52,117 @@ dependencies:
|
|
|
39
52
|
- !ruby/object:Gem::Version
|
|
40
53
|
version: 0.2.1
|
|
41
54
|
- !ruby/object:Gem::Dependency
|
|
42
|
-
name:
|
|
55
|
+
name: null-logger
|
|
43
56
|
requirement: !ruby/object:Gem::Requirement
|
|
44
57
|
requirements:
|
|
45
58
|
- - "~>"
|
|
46
59
|
- !ruby/object:Gem::Version
|
|
47
|
-
version: '
|
|
60
|
+
version: '0.1'
|
|
48
61
|
type: :development
|
|
49
62
|
prerelease: false
|
|
50
63
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
64
|
requirements:
|
|
52
65
|
- - "~>"
|
|
53
66
|
- !ruby/object:Gem::Version
|
|
54
|
-
version: '
|
|
67
|
+
version: '0.1'
|
|
55
68
|
- !ruby/object:Gem::Dependency
|
|
56
|
-
name:
|
|
69
|
+
name: pry-byebug
|
|
57
70
|
requirement: !ruby/object:Gem::Requirement
|
|
58
71
|
requirements:
|
|
59
72
|
- - "~>"
|
|
60
73
|
- !ruby/object:Gem::Version
|
|
61
|
-
version: '
|
|
74
|
+
version: '3.9'
|
|
62
75
|
type: :development
|
|
63
76
|
prerelease: false
|
|
64
77
|
version_requirements: !ruby/object:Gem::Requirement
|
|
65
78
|
requirements:
|
|
66
79
|
- - "~>"
|
|
67
80
|
- !ruby/object:Gem::Version
|
|
68
|
-
version: '
|
|
81
|
+
version: '3.9'
|
|
69
82
|
- !ruby/object:Gem::Dependency
|
|
70
|
-
name:
|
|
83
|
+
name: rake
|
|
71
84
|
requirement: !ruby/object:Gem::Requirement
|
|
72
85
|
requirements:
|
|
73
86
|
- - "~>"
|
|
74
87
|
- !ruby/object:Gem::Version
|
|
75
|
-
version: '
|
|
88
|
+
version: '13.0'
|
|
76
89
|
type: :development
|
|
77
90
|
prerelease: false
|
|
78
91
|
version_requirements: !ruby/object:Gem::Requirement
|
|
79
92
|
requirements:
|
|
80
93
|
- - "~>"
|
|
81
94
|
- !ruby/object:Gem::Version
|
|
82
|
-
version: '
|
|
95
|
+
version: '13.0'
|
|
83
96
|
- !ruby/object:Gem::Dependency
|
|
84
|
-
name:
|
|
97
|
+
name: redcarpet
|
|
85
98
|
requirement: !ruby/object:Gem::Requirement
|
|
86
99
|
requirements:
|
|
87
100
|
- - "~>"
|
|
88
101
|
- !ruby/object:Gem::Version
|
|
89
|
-
version: '
|
|
102
|
+
version: '3.5'
|
|
90
103
|
type: :development
|
|
91
104
|
prerelease: false
|
|
92
105
|
version_requirements: !ruby/object:Gem::Requirement
|
|
93
106
|
requirements:
|
|
94
107
|
- - "~>"
|
|
95
108
|
- !ruby/object:Gem::Version
|
|
96
|
-
version: '
|
|
109
|
+
version: '3.5'
|
|
97
110
|
- !ruby/object:Gem::Dependency
|
|
98
|
-
name:
|
|
111
|
+
name: rspec_junit_formatter
|
|
99
112
|
requirement: !ruby/object:Gem::Requirement
|
|
100
113
|
requirements:
|
|
101
114
|
- - "~>"
|
|
102
115
|
- !ruby/object:Gem::Version
|
|
103
|
-
version: '
|
|
116
|
+
version: '0.4'
|
|
104
117
|
type: :development
|
|
105
118
|
prerelease: false
|
|
106
119
|
version_requirements: !ruby/object:Gem::Requirement
|
|
107
120
|
requirements:
|
|
108
121
|
- - "~>"
|
|
109
122
|
- !ruby/object:Gem::Version
|
|
110
|
-
version: '
|
|
123
|
+
version: '0.4'
|
|
111
124
|
- !ruby/object:Gem::Dependency
|
|
112
125
|
name: rspec-benchmark
|
|
113
126
|
requirement: !ruby/object:Gem::Requirement
|
|
114
127
|
requirements:
|
|
115
128
|
- - "~>"
|
|
116
129
|
- !ruby/object:Gem::Version
|
|
117
|
-
version: 0.
|
|
130
|
+
version: '0.6'
|
|
118
131
|
type: :development
|
|
119
132
|
prerelease: false
|
|
120
133
|
version_requirements: !ruby/object:Gem::Requirement
|
|
121
134
|
requirements:
|
|
122
135
|
- - "~>"
|
|
123
136
|
- !ruby/object:Gem::Version
|
|
124
|
-
version: 0.
|
|
137
|
+
version: '0.6'
|
|
125
138
|
- !ruby/object:Gem::Dependency
|
|
126
|
-
name:
|
|
139
|
+
name: rspec
|
|
127
140
|
requirement: !ruby/object:Gem::Requirement
|
|
128
141
|
requirements:
|
|
129
142
|
- - "~>"
|
|
130
143
|
- !ruby/object:Gem::Version
|
|
131
|
-
version: '
|
|
144
|
+
version: '3.10'
|
|
132
145
|
type: :development
|
|
133
146
|
prerelease: false
|
|
134
147
|
version_requirements: !ruby/object:Gem::Requirement
|
|
135
148
|
requirements:
|
|
136
149
|
- - "~>"
|
|
137
150
|
- !ruby/object:Gem::Version
|
|
138
|
-
version: '
|
|
151
|
+
version: '3.10'
|
|
139
152
|
- !ruby/object:Gem::Dependency
|
|
140
153
|
name: yard
|
|
141
154
|
requirement: !ruby/object:Gem::Requirement
|
|
142
155
|
requirements:
|
|
143
156
|
- - "~>"
|
|
144
157
|
- !ruby/object:Gem::Version
|
|
145
|
-
version: 0.9
|
|
158
|
+
version: '0.9'
|
|
146
159
|
type: :development
|
|
147
160
|
prerelease: false
|
|
148
161
|
version_requirements: !ruby/object:Gem::Requirement
|
|
149
162
|
requirements:
|
|
150
163
|
- - "~>"
|
|
151
164
|
- !ruby/object:Gem::Version
|
|
152
|
-
version: 0.9
|
|
165
|
+
version: '0.9'
|
|
153
166
|
description: |
|
|
154
167
|
Enumpath is an implementation of the JSONPath spec for Ruby objects,
|
|
155
168
|
plus some added sugar. It's like Ruby's native Enumerable#dig method,
|
|
@@ -164,24 +177,8 @@ executables: []
|
|
|
164
177
|
extensions: []
|
|
165
178
|
extra_rdoc_files: []
|
|
166
179
|
files:
|
|
167
|
-
- ".github/ISSUE_TEMPLATE/bug_report.md"
|
|
168
|
-
- ".github/ISSUE_TEMPLATE/feature_request.md"
|
|
169
|
-
- ".github/workflows/greetings.yml"
|
|
170
|
-
- ".github/workflows/rubocop-analysis.yml"
|
|
171
|
-
- ".github/workflows/ruby.yml"
|
|
172
|
-
- ".gitignore"
|
|
173
|
-
- ".rspec"
|
|
174
|
-
- ".rubocop.yml"
|
|
175
|
-
- ".yardopts"
|
|
176
|
-
- CONTRIBUTING.md
|
|
177
|
-
- Gemfile
|
|
178
|
-
- Gemfile.lock
|
|
179
180
|
- LICENSE
|
|
180
181
|
- README.md
|
|
181
|
-
- Rakefile
|
|
182
|
-
- bin/console
|
|
183
|
-
- bin/setup
|
|
184
|
-
- enumpath.gemspec
|
|
185
182
|
- lib/enumpath.rb
|
|
186
183
|
- lib/enumpath/logger.rb
|
|
187
184
|
- lib/enumpath/operator.rb
|
|
@@ -195,6 +192,7 @@ files:
|
|
|
195
192
|
- lib/enumpath/operator/wildcard.rb
|
|
196
193
|
- lib/enumpath/path.rb
|
|
197
194
|
- lib/enumpath/path/normalized_path.rb
|
|
195
|
+
- lib/enumpath/resolver/object_inspector.rb
|
|
198
196
|
- lib/enumpath/resolver/property.rb
|
|
199
197
|
- lib/enumpath/resolver/simple.rb
|
|
200
198
|
- lib/enumpath/results.rb
|
|
@@ -202,8 +200,8 @@ files:
|
|
|
202
200
|
homepage: https://github.com/chrisbloom7/enumpath
|
|
203
201
|
licenses:
|
|
204
202
|
- Apache-2.0
|
|
205
|
-
metadata:
|
|
206
|
-
|
|
203
|
+
metadata:
|
|
204
|
+
rubygems_mfa_required: 'true'
|
|
207
205
|
rdoc_options: []
|
|
208
206
|
require_paths:
|
|
209
207
|
- lib
|
|
@@ -211,15 +209,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
211
209
|
requirements:
|
|
212
210
|
- - ">="
|
|
213
211
|
- !ruby/object:Gem::Version
|
|
214
|
-
version: 2.
|
|
212
|
+
version: 2.6.0
|
|
215
213
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
216
214
|
requirements:
|
|
217
215
|
- - ">="
|
|
218
216
|
- !ruby/object:Gem::Version
|
|
219
217
|
version: '0'
|
|
220
218
|
requirements: []
|
|
221
|
-
rubygems_version: 3.
|
|
222
|
-
signing_key:
|
|
219
|
+
rubygems_version: 3.6.9
|
|
223
220
|
specification_version: 4
|
|
224
221
|
summary: A JSONPath-compatible library for navigating nested Ruby objects using path
|
|
225
222
|
expressions
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: Bug report
|
|
3
|
-
about: Create a report to help us improve Enumpath
|
|
4
|
-
title: ''
|
|
5
|
-
labels: ''
|
|
6
|
-
assignees: chrisbloom7
|
|
7
|
-
|
|
8
|
-
---
|
|
9
|
-
|
|
10
|
-
**Describe the bug**
|
|
11
|
-
A clear and concise description of what the bug is.
|
|
12
|
-
|
|
13
|
-
**To Reproduce**
|
|
14
|
-
Steps to reproduce the behavior:
|
|
15
|
-
1. Go to '...'
|
|
16
|
-
2. Click on '....'
|
|
17
|
-
3. Scroll down to '....'
|
|
18
|
-
4. See error
|
|
19
|
-
|
|
20
|
-
**Expected behavior**
|
|
21
|
-
A clear and concise description of what you expected to happen.
|
|
22
|
-
|
|
23
|
-
**Screenshots**
|
|
24
|
-
If applicable, add screenshots to help explain your problem.
|
|
25
|
-
|
|
26
|
-
**Desktop (please complete the following information):**
|
|
27
|
-
- OS: [e.g. iOS]
|
|
28
|
-
- Browser [e.g. chrome, safari]
|
|
29
|
-
- Version [e.g. 22]
|
|
30
|
-
|
|
31
|
-
**Smartphone (please complete the following information):**
|
|
32
|
-
- Device: [e.g. iPhone6]
|
|
33
|
-
- OS: [e.g. iOS8.1]
|
|
34
|
-
- Browser [e.g. stock browser, safari]
|
|
35
|
-
- Version [e.g. 22]
|
|
36
|
-
|
|
37
|
-
**Additional context**
|
|
38
|
-
Add any other context about the problem here.
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: Feature request
|
|
3
|
-
about: Suggest an idea for Enumpath
|
|
4
|
-
title: ''
|
|
5
|
-
labels: ''
|
|
6
|
-
assignees: chrisbloom7
|
|
7
|
-
|
|
8
|
-
---
|
|
9
|
-
|
|
10
|
-
**Is your feature request related to a problem? Please describe.**
|
|
11
|
-
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
|
12
|
-
|
|
13
|
-
**Describe the solution you'd like**
|
|
14
|
-
A clear and concise description of what you want to happen.
|
|
15
|
-
|
|
16
|
-
**Describe alternatives you've considered**
|
|
17
|
-
A clear and concise description of any alternative solutions or features you've considered.
|
|
18
|
-
|
|
19
|
-
**Additional context**
|
|
20
|
-
Add any other context or screenshots about the feature request here.
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
name: Greetings
|
|
2
|
-
|
|
3
|
-
on: [pull_request, issues]
|
|
4
|
-
|
|
5
|
-
jobs:
|
|
6
|
-
greeting:
|
|
7
|
-
runs-on: ubuntu-latest
|
|
8
|
-
steps:
|
|
9
|
-
- uses: actions/first-interaction@v1
|
|
10
|
-
with:
|
|
11
|
-
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
|
12
|
-
# issue-message: 'TODO: Message that will be displayed on users'' first issue'
|
|
13
|
-
pr-message: 'Thanks for being interested in improving Enumpath! We welcome all kinds of contributions. There are a couple of things you should know before contributing to this repository, so be sure to [read our contributing guide](https://github.com/chrisbloom7/enumpath/blob/master/CONTRIBUTING.md) while awaiting feedback.'
|