object_inspector 0.6.2 → 0.7.0

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(
32
+ parts, 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(
41
+ flags, 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(
50
+ issues, 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(
59
+ items, 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, &)
86
+ if method_name[-1] == "?"
87
+ scope_name = method_name[0..-2]
88
+ evaluate_match(scope_name, &)
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.7.0"
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.7.0
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: 2024-11-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: benchmark-ips
@@ -25,49 +25,7 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: bundler
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
- - !ruby/object:Gem::Dependency
42
- name: byebug
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
- - !ruby/object:Gem::Dependency
56
- name: minitest
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- version: '0'
69
- - !ruby/object:Gem::Dependency
70
- name: minitest-reporters
28
+ name: gemwork
71
29
  requirement: !ruby/object:Gem::Requirement
72
30
  requirements:
73
31
  - - ">="
@@ -94,34 +52,6 @@ dependencies:
94
52
  - - ">="
95
53
  - !ruby/object:Gem::Version
96
54
  version: '0'
97
- - !ruby/object:Gem::Dependency
98
- name: pry
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'
111
- - !ruby/object:Gem::Dependency
112
- name: pry-byebug
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - ">="
116
- - !ruby/object:Gem::Version
117
- version: '0'
118
- type: :development
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - ">="
123
- - !ruby/object:Gem::Version
124
- version: '0'
125
55
  - !ruby/object:Gem::Dependency
126
56
  name: rake
127
57
  requirement: !ruby/object:Gem::Requirement
@@ -136,69 +66,18 @@ dependencies:
136
66
  - - ">="
137
67
  - !ruby/object:Gem::Version
138
68
  version: '0'
139
- - !ruby/object:Gem::Dependency
140
- name: reek
141
- requirement: !ruby/object:Gem::Requirement
142
- requirements:
143
- - - ">="
144
- - !ruby/object:Gem::Version
145
- version: '0'
146
- type: :development
147
- prerelease: false
148
- version_requirements: !ruby/object:Gem::Requirement
149
- requirements:
150
- - - ">="
151
- - !ruby/object:Gem::Version
152
- version: '0'
153
- - !ruby/object:Gem::Dependency
154
- name: rubocop
155
- requirement: !ruby/object:Gem::Requirement
156
- requirements:
157
- - - ">="
158
- - !ruby/object:Gem::Version
159
- version: '0'
160
- type: :development
161
- prerelease: false
162
- version_requirements: !ruby/object:Gem::Requirement
163
- requirements:
164
- - - ">="
165
- - !ruby/object:Gem::Version
166
- version: '0'
167
- - !ruby/object:Gem::Dependency
168
- name: simplecov
169
- requirement: !ruby/object:Gem::Requirement
170
- requirements:
171
- - - ">="
172
- - !ruby/object:Gem::Version
173
- version: '0'
174
- type: :development
175
- prerelease: false
176
- version_requirements: !ruby/object:Gem::Requirement
177
- requirements:
178
- - - ">="
179
- - !ruby/object:Gem::Version
180
- 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.
69
+ description: Object Inspector takes Object#inspect to the next level. Specify any
70
+ combination of identification attributes, flags, issues, info, and/or a name along
71
+ with an optional, self-definable scope option to represents objects. Great for the
72
+ console, logging, etc.
185
73
  email:
186
74
  - p.dobbinschmaltz@icloud.com
187
75
  executables: []
188
76
  extensions: []
189
77
  extra_rdoc_files: []
190
78
  files:
191
- - ".gitignore"
192
- - ".rubocop"
193
- - ".rubocop.yml"
194
- - CHANGELOG.md
195
- - Gemfile
196
- - Gemfile.lock
197
79
  - LICENSE.txt
198
80
  - README.md
199
- - Rakefile
200
- - bin/console
201
- - bin/setup
202
81
  - lib/object_inspector.rb
203
82
  - lib/object_inspector/conversions.rb
204
83
  - lib/object_inspector/formatters/base_formatter.rb
@@ -209,13 +88,15 @@ files:
209
88
  - lib/object_inspector/object_interrogator.rb
210
89
  - lib/object_inspector/scope.rb
211
90
  - lib/object_inspector/version.rb
212
- - object_inspector.gemspec
213
- - scripts/benchmarking/formatters.rb
214
- - scripts/benchmarking/object_inspector.rb
215
91
  homepage: https://github.com/pdobb/object_inspector
216
92
  licenses:
217
93
  - MIT
218
- metadata: {}
94
+ metadata:
95
+ bug_tracker_uri: https://github.com/pdobb/object_inspector/issues
96
+ changelog_uri: https://github.com/pdobb/object_inspector/releases
97
+ source_code_uri: https://github.com/pdobb/object_inspector
98
+ homepage_uri: https://github.com/pdobb/object_inspector
99
+ rubygems_mfa_required: 'true'
219
100
  post_install_message:
220
101
  rdoc_options: []
221
102
  require_paths:
@@ -224,16 +105,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
224
105
  requirements:
225
106
  - - ">="
226
107
  - !ruby/object:Gem::Version
227
- version: '0'
108
+ version: '3.1'
228
109
  required_rubygems_version: !ruby/object:Gem::Requirement
229
110
  requirements:
230
111
  - - ">="
231
112
  - !ruby/object:Gem::Version
232
113
  version: '0'
233
114
  requirements: []
234
- rubygems_version: 3.3.3
115
+ rubygems_version: 3.3.27
235
116
  signing_key:
236
117
  specification_version: 4
237
- summary: ObjectInspector builds uniformly formatted inspect output with customizable
118
+ summary: Object Inspector builds uniformly formatted inspect output with customizable
238
119
  amounts of detail.
239
120
  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