object_inspector 0.6.1 → 0.6.3

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.
@@ -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.1"
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.1
4
+ version: 0.6.3
5
5
  platform: ruby
6
6
  authors:
7
- - Paul Dobbins
8
- autorequire:
7
+ - Paul DobbinSchmaltz
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-06-27 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,28 +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
- - paul.dobbins@icloud.com
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
- - ".travis.yml"
195
- - CHANGELOG.md
196
- - Gemfile
197
- - Gemfile.lock
198
205
  - LICENSE.txt
199
206
  - README.md
200
- - Rakefile
201
- - bin/console
202
- - bin/setup
203
207
  - lib/object_inspector.rb
204
208
  - lib/object_inspector/conversions.rb
205
209
  - lib/object_inspector/formatters/base_formatter.rb
@@ -210,14 +214,16 @@ files:
210
214
  - lib/object_inspector/object_interrogator.rb
211
215
  - lib/object_inspector/scope.rb
212
216
  - lib/object_inspector/version.rb
213
- - object_inspector.gemspec
214
- - scripts/benchmarking/formatters.rb
215
- - scripts/benchmarking/object_inspector.rb
216
217
  homepage: https://github.com/pdobb/object_inspector
217
218
  licenses:
218
219
  - MIT
219
- metadata: {}
220
- post_install_message:
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'
226
+ post_install_message:
221
227
  rdoc_options: []
222
228
  require_paths:
223
229
  - lib
@@ -225,16 +231,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
225
231
  requirements:
226
232
  - - ">="
227
233
  - !ruby/object:Gem::Version
228
- version: '0'
234
+ version: '2.7'
229
235
  required_rubygems_version: !ruby/object:Gem::Requirement
230
236
  requirements:
231
237
  - - ">="
232
238
  - !ruby/object:Gem::Version
233
239
  version: '0'
234
240
  requirements: []
235
- rubygems_version: 3.0.4
236
- signing_key:
241
+ rubygems_version: 3.4.10
242
+ signing_key:
237
243
  specification_version: 4
238
- summary: ObjectInspector builds uniformly formatted inspect output with customizable
244
+ summary: Object Inspector builds uniformly formatted inspect output with customizable
239
245
  amounts of detail.
240
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/.travis.yml DELETED
@@ -1,21 +0,0 @@
1
- env:
2
- global:
3
- - CC_TEST_REPORTER_ID=7711465d4611bd7f1211f3262ac4ba750ffcda0574c3c6e4a6ba55446871dd17
4
- sudo: false
5
- language: ruby
6
- rvm:
7
- - 2.3
8
- - 2.4
9
- - 2.5
10
- - 2.6
11
- - ruby-head
12
- notifications:
13
- email: false
14
- before_install: gem install bundler -v 1.16.1
15
- cache: bundler
16
- before_script:
17
- - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
18
- - chmod +x ./cc-test-reporter
19
- - ./cc-test-reporter before-build
20
- after_script:
21
- - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
data/CHANGELOG.md DELETED
@@ -1,45 +0,0 @@
1
- ### 0.6.1 - 2019-06-27
2
- - Flatten and compact arrays of `nil`s as well as nested arrays of `nil`s in join_* methods.
3
-
4
- ### 0.6.0 - 2019-03-13
5
- - Fix inspection of delegating wrapper objects.
6
- - Allow clearing output of inspect methods.
7
-
8
- ### 0.5.2 - 2019-02-24
9
- - Automatically compact nils in join_* methods.
10
-
11
- ### 0.5.1 - 2018-06-12
12
- - Don't include empty strings from Scope#join_* methods when applicable.
13
-
14
- ### 0.5.0 - 2018-06-11
15
- - Add `inspect_issues` to ObjectInspector::TemplatingFormatter.
16
- - Add ObjectInspector::Scope#join_name.
17
- - Add configurable ObjectInspector.configuration.presented_object_separator.
18
-
19
- ### 0.4.0 - 2018-05-25
20
- - Feature: Add ObjectInspector::Configuration#default_scope setting -- can be used to override the default Scope for object inspection.
21
- - Implement ObjectInspector::Scope#== for comparing scopes with scopes and/or scopes with (Arrays of) Strings, Symbols, etc.
22
-
23
- ### 0.3.1 - 2018-04-15
24
- - Add ObjectInspector::Configuration#formatter_class setting for overriding the default Formatter.
25
-
26
- ### 0.3.0 - 2018-04-14
27
- - 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.
28
- - Add ObjectInspector::Scope.join_flags helper method.
29
- - Add ObjectInspector::Scope.join_info helper method.
30
- - Scope: Show an out-of-scope-placeholder symbol (*) when predicate is not matched and a block is given.
31
- - Scope: Add wild-card "all" scope that is always evaluated as true / a match.
32
- - Add ability to specify multiple scopes. e.g. my_object.inspect(scope: %i[verbose complex]).
33
- - Add gem defaults configuration.
34
-
35
- ### 0.2.0 - 2018-04-12
36
- - Automatically inspect wrapped Objects, if applicable.
37
- - Use `display_name` if defined on object, in place of `inspect_name`.
38
- - Add on-the-fly inspect methods when Symbols are passed in to #inspect.
39
- - Update the `flags` and `info` demarcation symbols.
40
- - Add ObjectInspector::TemplatingFormatter, and use it as the new default since it's faster.
41
- - Rename ObjectInspector::DefaultFormatter to ObjectInspector::CombiningFormatter.
42
-
43
-
44
- ### 0.1.0 - 2018-04-09
45
- - 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