object_inspector 0.6.2 → 0.6.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,132 +1,141 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module ObjectInspector
4
- # ObjectInspector::Scope defines a predicate method that matches {#name} and
5
- # responds with `true`. This is a prettier way to test for a given type of
6
- # "scope" within objects.
7
- #
8
- # It is possible to pass in multiple scope names to match on.
9
- # `:all` is a "wild card" scope name, and will match on all scope names.
10
- # Passing a block to a scope predicate falls back to the out-of-scope
11
- # placeholder (`*` by default) if the scope does not match.
12
- #
13
- # @see ActiveSupport::StringInquirer
14
- # http://api.rubyonrails.org/classes/ActiveSupport/StringInquirer.html
3
+ # :reek:TooManyMethods
4
+
5
+ # ObjectInspector::Scope defines a predicate method that matches {#names} and
6
+ # responds with `true`. This is a prettier way to test for a given type of
7
+ # "scope" within objects.
8
+ #
9
+ # It is possible to pass in multiple scope names to match on.
10
+ #
11
+ # `:all` is a "wild card" scope name, and will match on all scope names.
12
+ #
13
+ # Passing a block to a scope predicate falls back to the out-of-scope
14
+ # placeholder (`*` by default) if the scope does not match.
15
+ #
16
+ # @see ActiveSupport::StringInquirer
17
+ # http://api.rubyonrails.org/classes/ActiveSupport/StringInquirer.html
18
+ #
19
+ # @attr names [Array<#to_s>]
20
+ class ObjectInspector::Scope
21
+ attr_reader :names
22
+
23
+ def initialize(names = %w[self])
24
+ @names = Array(names).map { |name| String(name) }
25
+ end
26
+
27
+ # Join the passed in name parts with the passed in separator.
15
28
  #
16
- # @attr names [Array<#to_s>]
17
- class Scope
18
- attr_reader :names
29
+ # @param parts [Array<#to_s>]
30
+ # @param separator [#to_s] (ObjectInspector.configuration.flags_separator)
31
+ def join_name(parts,
32
+ separator: ObjectInspector.configuration.name_separator)
33
+ _join(parts, separator)
34
+ end
19
35
 
20
- def initialize(names = %w[self])
21
- @names = Array(names).map { |name| String(name) }
22
- end
36
+ # Join the passed in flags with the passed in separator.
37
+ #
38
+ # @param flags [Array<#to_s>]
39
+ # @param separator [#to_s] (ObjectInspector.configuration.flags_separator)
40
+ def join_flags(flags,
41
+ separator: ObjectInspector.configuration.flags_separator)
42
+ _join(flags, separator)
43
+ end
23
44
 
24
- # Join the passed-in name parts with the passed in separator.
25
- #
26
- # @param parts [Array<#to_s>]
27
- # @param separator [#to_s] (ObjectInspector.configuration.flags_separator)
28
- def join_name(parts,
29
- separator: ObjectInspector.configuration.name_separator)
30
- _join(parts, separator)
31
- end
45
+ # Join the passed in issues with the passed in separator.
46
+ #
47
+ # @param issues [Array<#to_s>]
48
+ # @param separator [#to_s] (ObjectInspector.configuration.issues_separator)
49
+ def join_issues(issues,
50
+ separator: ObjectInspector.configuration.issues_separator)
51
+ _join(issues, separator)
52
+ end
32
53
 
33
- # Join the passed-in flags with the passed in separator.
34
- #
35
- # @param flags [Array<#to_s>]
36
- # @param separator [#to_s] (ObjectInspector.configuration.flags_separator)
37
- def join_flags(flags,
38
- separator: ObjectInspector.configuration.flags_separator)
39
- _join(flags, separator)
40
- end
54
+ # Join the passed in items with the passed in separator.
55
+ #
56
+ # @param items [Array<#to_s>]
57
+ # @param separator [#to_s] (ObjectInspector.configuration.info_separator)
58
+ def join_info(items,
59
+ separator: ObjectInspector.configuration.info_separator)
60
+ _join(items, separator)
61
+ end
41
62
 
42
- # Join the passed-in issues with the passed in separator.
43
- #
44
- # @param issues [Array<#to_s>]
45
- # @param separator [#to_s] (ObjectInspector.configuration.issues_separator)
46
- def join_issues(issues,
47
- separator: ObjectInspector.configuration.issues_separator)
48
- _join(issues, separator)
49
- end
63
+ # Compare self with the passed in object.
64
+ #
65
+ # @return [TrueClass] if self and `other` resolve to the same set of objects
66
+ # @return [FalseClass] if self and `other` resolve to a different set of
67
+ # objects
68
+ def ==(other)
69
+ @names.sort == Array(other).map(&:to_s).sort
70
+ end
71
+ alias_method :eql?, :==
50
72
 
51
- # Join the passed-in items with the passed in separator.
52
- #
53
- # @param items [Array<#to_s>]
54
- # @param separator [#to_s] (ObjectInspector.configuration.info_separator)
55
- def join_info(items,
56
- separator: ObjectInspector.configuration.info_separator)
57
- _join(items, separator)
58
- end
73
+ # @return [String] the contents of {#names}, joined by `, `.
74
+ def to_s(separator: ", ")
75
+ to_a.join(separator)
76
+ end
59
77
 
60
- # Compare self with the passed in object.
61
- #
62
- # @return [TrueClass] if self and `other` resolve to the same set of objects
63
- # @return [FalseClass] if self and `other` resolve to a different set of
64
- # objects
65
- def ==(other)
66
- @names.sort == Array(other).map(&:to_s).sort
67
- end
68
- alias_method :eql?, :==
78
+ # @return (see #names)
79
+ def to_a
80
+ names
81
+ end
69
82
 
70
- def to_s(separator: ", ")
71
- to_a.join(separator)
72
- end
83
+ private
73
84
 
74
- def to_a
75
- @names
85
+ def method_missing(method_name, *args, &block)
86
+ if method_name[-1] == "?"
87
+ scope_name = method_name[0..-2]
88
+ evaluate_match(scope_name, &block)
89
+ else
90
+ super
76
91
  end
92
+ end
77
93
 
78
- private
94
+ def evaluate_match(scope_name, &block)
95
+ is_a_match = match?(scope_name)
79
96
 
80
- def method_missing(method_name, *args, &block)
81
- if method_name[-1] == "?"
82
- scope_name = method_name[0..-2]
83
- evaluate_match(scope_name, &block)
84
- else
85
- super
86
- end
97
+ if block
98
+ evaluate_block_if(is_a_match, &block)
99
+ else
100
+ is_a_match
87
101
  end
102
+ end
88
103
 
89
- def evaluate_match(scope_name, &block)
90
- is_a_match = match?(scope_name)
104
+ # :reek:ControlParameter (`condition`)
91
105
 
92
- if block
93
- evaluate_block_if(is_a_match, &block)
94
- else
95
- is_a_match
96
- end
106
+ def evaluate_block_if(condition)
107
+ if condition
108
+ yield(self)
109
+ else
110
+ ObjectInspector.configuration.out_of_scope_placeholder
97
111
  end
112
+ end
98
113
 
99
- def evaluate_block_if(condition)
100
- if condition
101
- yield(self)
102
- else
103
- ObjectInspector.configuration.out_of_scope_placeholder
104
- end
105
- end
114
+ # :reek:FeatureEnvy (`items.`)
106
115
 
107
- def _join(items, separator)
108
- items = Array(items)
109
- items.flatten!
110
- items.compact!
111
- items.join(separator) unless items.empty?
112
- end
116
+ def _join(items, separator)
117
+ items = Array(items)
118
+ items.flatten!
119
+ items.compact!
120
+ items.join(separator) unless items.empty?
121
+ end
113
122
 
114
- def match?(scope_name)
115
- any_names_match?(scope_name) ||
116
- wild_card_scope?
117
- end
123
+ def match?(scope_name)
124
+ any_names_match?(scope_name) ||
125
+ wild_card_scope?
126
+ end
118
127
 
119
- def wild_card_scope?
120
- @wild_card_scope ||=
121
- any_names_match?(ObjectInspector.configuration.wild_card_scope)
122
- end
128
+ def wild_card_scope?
129
+ @wild_card_scope ||=
130
+ any_names_match?(ObjectInspector.configuration.wild_card_scope)
131
+ end
123
132
 
124
- def any_names_match?(other_name)
125
- @names.any? { |name| name == other_name }
126
- end
133
+ def any_names_match?(other_name)
134
+ @names.any?(other_name)
135
+ end
127
136
 
128
- def respond_to_missing?(method_name, include_private = false)
129
- method_name[-1] == "?" || super
130
- end
137
+ # :reek:BooleanParameter
138
+ def respond_to_missing?(method_name, include_private = false)
139
+ method_name[-1] == "?" || super
131
140
  end
132
141
  end
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ObjectInspector
4
- VERSION = "0.6.2"
4
+ # The current ObjectInspector gem version.
5
+ VERSION = "0.6.3"
5
6
  end
@@ -3,14 +3,18 @@
3
3
  # ObjectInspector is the base namespace for all modules/classes related to the
4
4
  # object_inspector gem.
5
5
  module ObjectInspector
6
+ # Accessor for the {ObjectInspector::Configuration} object.
6
7
  def self.configuration
7
8
  @configuration ||= Configuration.new
8
9
  end
9
10
 
11
+ # @yieldparam configuration [ObjectInspector::Configuration]
10
12
  def self.configure
11
13
  yield(configuration)
12
14
  end
13
15
 
16
+ # Reset the current configuration settings memoized by
17
+ # {ObjectInspector.configuration}.
14
18
  def self.reset_configuration
15
19
  @configuration = Configuration.new
16
20
  end
@@ -18,6 +22,8 @@ module ObjectInspector
18
22
  # ObjectInspector::Configuration stores the default configuration options for
19
23
  # the ObjectInspector gem. Modification of attributes is possible at any time,
20
24
  # and values will persist for the duration of the running process.
25
+ #
26
+ # :reek:TooManyInstanceVariables
21
27
  class Configuration
22
28
  attr_reader :formatter_class,
23
29
  :inspect_method_prefix,
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: object_inspector
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.2
4
+ version: 0.6.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul DobbinSchmaltz
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-12-31 00:00:00.000000000 Z
11
+ date: 2023-11-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: benchmark-ips
@@ -94,6 +94,20 @@ dependencies:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: pdobb-style
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: pry
99
113
  requirement: !ruby/object:Gem::Requirement
@@ -151,7 +165,7 @@ dependencies:
151
165
  - !ruby/object:Gem::Version
152
166
  version: '0'
153
167
  - !ruby/object:Gem::Dependency
154
- name: rubocop
168
+ name: simplecov
155
169
  requirement: !ruby/object:Gem::Requirement
156
170
  requirements:
157
171
  - - ">="
@@ -165,7 +179,7 @@ dependencies:
165
179
  - !ruby/object:Gem::Version
166
180
  version: '0'
167
181
  - !ruby/object:Gem::Dependency
168
- name: simplecov
182
+ name: yard
169
183
  requirement: !ruby/object:Gem::Requirement
170
184
  requirements:
171
185
  - - ">="
@@ -178,27 +192,18 @@ dependencies:
178
192
  - - ">="
179
193
  - !ruby/object:Gem::Version
180
194
  version: '0'
181
- description: ObjectInspector takes Object#inspect to the next level. Specify any combination
182
- of identification attributes, flags, issues, info, and/or a name along with an optional,
183
- self-definable scope option to represents objects. Great for the console, logging,
184
- etc.
195
+ description: Object Inspector takes Object#inspect to the next level. Specify any
196
+ combination of identification attributes, flags, issues, info, and/or a name along
197
+ with an optional, self-definable scope option to represents objects. Great for the
198
+ console, logging, etc.
185
199
  email:
186
200
  - p.dobbinschmaltz@icloud.com
187
201
  executables: []
188
202
  extensions: []
189
203
  extra_rdoc_files: []
190
204
  files:
191
- - ".gitignore"
192
- - ".rubocop"
193
- - ".rubocop.yml"
194
- - CHANGELOG.md
195
- - Gemfile
196
- - Gemfile.lock
197
205
  - LICENSE.txt
198
206
  - README.md
199
- - Rakefile
200
- - bin/console
201
- - bin/setup
202
207
  - lib/object_inspector.rb
203
208
  - lib/object_inspector/conversions.rb
204
209
  - lib/object_inspector/formatters/base_formatter.rb
@@ -209,13 +214,15 @@ files:
209
214
  - lib/object_inspector/object_interrogator.rb
210
215
  - lib/object_inspector/scope.rb
211
216
  - lib/object_inspector/version.rb
212
- - object_inspector.gemspec
213
- - scripts/benchmarking/formatters.rb
214
- - scripts/benchmarking/object_inspector.rb
215
217
  homepage: https://github.com/pdobb/object_inspector
216
218
  licenses:
217
219
  - MIT
218
- metadata: {}
220
+ metadata:
221
+ bug_tracker_uri: https://github.com/pdobb/object_inspector/issues
222
+ changelog_uri: https://github.com/pdobb/object_inspector/releases
223
+ source_code_uri: https://github.com/pdobb/object_inspector
224
+ homepage_uri: https://github.com/pdobb/object_inspector
225
+ rubygems_mfa_required: 'true'
219
226
  post_install_message:
220
227
  rdoc_options: []
221
228
  require_paths:
@@ -224,16 +231,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
224
231
  requirements:
225
232
  - - ">="
226
233
  - !ruby/object:Gem::Version
227
- version: '0'
234
+ version: '2.7'
228
235
  required_rubygems_version: !ruby/object:Gem::Requirement
229
236
  requirements:
230
237
  - - ">="
231
238
  - !ruby/object:Gem::Version
232
239
  version: '0'
233
240
  requirements: []
234
- rubygems_version: 3.3.3
241
+ rubygems_version: 3.4.10
235
242
  signing_key:
236
243
  specification_version: 4
237
- summary: ObjectInspector builds uniformly formatted inspect output with customizable
244
+ summary: Object Inspector builds uniformly formatted inspect output with customizable
238
245
  amounts of detail.
239
246
  test_files: []
data/.gitignore DELETED
@@ -1,11 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /_yardoc/
4
- /coverage/
5
- /doc/
6
- /pkg/
7
- /spec/reports/
8
- /tmp/
9
- .byebug_history
10
- *.gem
11
- .DS_Store
data/.rubocop DELETED
@@ -1,4 +0,0 @@
1
- --display-cop-names
2
- --display-style-guide
3
- --extra-details
4
- --format=fuubar
data/.rubocop.yml DELETED
@@ -1,158 +0,0 @@
1
- AllCops:
2
- UseCache: true
3
- DisplayCopNames: true
4
- DisplayStyleGuide: true
5
- ExtraDetails: false
6
- TargetRubyVersion: 2.5.3
7
-
8
- Layout/ClassStructure:
9
- Enabled: true
10
- Categories:
11
- module_inclusion:
12
- - extend
13
- - include
14
- - prepend
15
- attributes:
16
- - attr_accessor
17
- - attr_reader
18
- - attr_writer
19
- ExpectedOrder:
20
- - constants
21
- - module_inclusion
22
- - attributes
23
- - public_class_methods
24
- - initializer
25
- - public_methods
26
- - predicates
27
- - protected_methods
28
- - private_methods
29
-
30
- Layout/DotPosition:
31
- EnforcedStyle: trailing
32
-
33
- Layout/EmptyLineAfterGuardClause:
34
- Enabled: true
35
-
36
- Layout/EndOfLine:
37
- EnforcedStyle: lf
38
-
39
- Layout/IndentFirstArgument:
40
- EnforcedStyle: consistent_relative_to_receiver
41
-
42
- Layout/IndentFirstArrayElement:
43
- EnforcedStyle: consistent
44
-
45
- Layout/IndentFirstHashElement:
46
- EnforcedStyle: consistent
47
-
48
- Layout/IndentFirstParameter:
49
- Enabled: false # Revisit if more settings become available.
50
-
51
- Layout/MultilineAssignmentLayout:
52
- Enabled: true
53
-
54
- Layout/MultilineMethodCallBraceLayout:
55
- EnforcedStyle: same_line
56
-
57
- Layout/MultilineMethodCallIndentation:
58
- EnforcedStyle: indented_relative_to_receiver
59
-
60
- Layout/MultilineMethodDefinitionBraceLayout:
61
- EnforcedStyle: same_line
62
-
63
- Layout/MultilineOperationIndentation:
64
- Enabled: false # Waiting for e.g. `indented_relative_to_receiver`.
65
-
66
- Lint/AmbiguousOperator:
67
- Enabled: false # Conflicts with other rules.
68
-
69
- Lint/AmbiguousRegexpLiteral:
70
- Enabled: false # Conflicts with other rules.
71
-
72
- Lint/Void:
73
- CheckForMethodsWithNoSideEffects: true
74
-
75
- Metrics/BlockLength:
76
- ExcludedMethods:
77
- - new
78
- - describe # Tests
79
- - context # Tests
80
- - ips # Benchmarking
81
-
82
- Metrics/ClassLength:
83
- Exclude:
84
- - "test/**/*"
85
- - "lib/object_inspector/formatters/templating_formatter.rb"
86
-
87
- Metrics/LineLength:
88
- Max: 80
89
- Exclude:
90
- - "test/**/*"
91
- - "object_inspector.gemspec"
92
-
93
- Naming/UncommunicativeMethodParamName:
94
- AllowedNames:
95
- - a
96
- - b
97
-
98
- Style/Alias:
99
- EnforcedStyle: prefer_alias_method
100
-
101
- Style/BlockDelimiters:
102
- Enabled: false # Reconsider later.
103
-
104
- Style/ClassAndModuleChildren:
105
- AutoCorrect: true
106
- Exclude:
107
- - "test/**/*"
108
-
109
- Style/CollectionMethods:
110
- Enabled: true
111
- PreferredMethods:
112
- collect: map
113
- collect!: map!
114
- find_all: select
115
- detect: detect
116
- inject: inject
117
-
118
- Style/EmptyElse:
119
- # It"s helpful to show intent by including a comment in an else block.
120
- Enabled: false
121
-
122
- Style/EmptyMethod:
123
- EnforcedStyle: expanded
124
-
125
- Style/ExpandPathArguments:
126
- Exclude:
127
- - "object_inspector.gemspec"
128
-
129
- Style/FormatString:
130
- Enabled: false # % notation with an Array just reads better sometimes.
131
-
132
- Style/Lambda:
133
- EnforcedStyle: literal
134
-
135
- Style/NumericPredicate:
136
- AutoCorrect: true
137
-
138
- Style/RegexpLiteral:
139
- EnforcedStyle: mixed
140
-
141
- Style/RescueStandardError:
142
- EnforcedStyle: implicit
143
-
144
- Style/ReturnNil:
145
- Enabled: true
146
-
147
- Style/StringMethods:
148
- Enabled: true
149
-
150
- Style/SingleLineMethods:
151
- Exclude:
152
- - "test/**/*_test.rb"
153
-
154
- Style/StringLiterals:
155
- EnforcedStyle: double_quotes
156
-
157
- Style/StringLiteralsInInterpolation:
158
- EnforcedStyle: double_quotes
data/CHANGELOG.md DELETED
@@ -1,49 +0,0 @@
1
- ### 0.6.2 - 2022-12-30
2
- - Internal spruce-up for Ruby 3.2. No outward-facing changes.
3
- - Remove travis-ci config since travis-ci is no longer in use.
4
-
5
- ### 0.6.1 - 2019-06-27
6
- - Flatten and compact arrays of `nil`s as well as nested arrays of `nil`s in join_* methods.
7
-
8
- ### 0.6.0 - 2019-03-13
9
- - Fix inspection of delegating wrapper objects.
10
- - Allow clearing output of inspect methods.
11
-
12
- ### 0.5.2 - 2019-02-24
13
- - Automatically compact nils in join_* methods.
14
-
15
- ### 0.5.1 - 2018-06-12
16
- - Don't include empty strings from Scope#join_* methods when applicable.
17
-
18
- ### 0.5.0 - 2018-06-11
19
- - Add `inspect_issues` to ObjectInspector::TemplatingFormatter.
20
- - Add ObjectInspector::Scope#join_name.
21
- - Add configurable ObjectInspector.configuration.presented_object_separator.
22
-
23
- ### 0.4.0 - 2018-05-25
24
- - Feature: Add ObjectInspector::Configuration#default_scope setting -- can be used to override the default Scope for object inspection.
25
- - Implement ObjectInspector::Scope#== for comparing scopes with scopes and/or scopes with (Arrays of) Strings, Symbols, etc.
26
-
27
- ### 0.3.1 - 2018-04-15
28
- - Add ObjectInspector::Configuration#formatter_class setting for overriding the default Formatter.
29
-
30
- ### 0.3.0 - 2018-04-14
31
- - Remove optional dependency on ActiveSupport::StringInquirer. [Scopes are now objects](https://github.com/pdobb/object_inspector/blob/master/lib/object_inspector/scope.rb) that act like ActiveSupport::StringInquirer objects.
32
- - Add ObjectInspector::Scope.join_flags helper method.
33
- - Add ObjectInspector::Scope.join_info helper method.
34
- - Scope: Show an out-of-scope-placeholder symbol (*) when predicate is not matched and a block is given.
35
- - Scope: Add wild-card "all" scope that is always evaluated as true / a match.
36
- - Add ability to specify multiple scopes. e.g. my_object.inspect(scope: %i[verbose complex]).
37
- - Add gem defaults configuration.
38
-
39
- ### 0.2.0 - 2018-04-12
40
- - Automatically inspect wrapped Objects, if applicable.
41
- - Use `display_name` if defined on object, in place of `inspect_name`.
42
- - Add on-the-fly inspect methods when Symbols are passed in to #inspect.
43
- - Update the `flags` and `info` demarcation symbols.
44
- - Add ObjectInspector::TemplatingFormatter, and use it as the new default since it's faster.
45
- - Rename ObjectInspector::DefaultFormatter to ObjectInspector::CombiningFormatter.
46
-
47
-
48
- ### 0.1.0 - 2018-04-09
49
- - Initial release!
data/Gemfile DELETED
@@ -1,8 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source "https://rubygems.org"
4
-
5
- git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
6
-
7
- # Specify your gem's dependencies in object_inspector.gemspec
8
- gemspec