object_inspector 0.10.0 → 1.1.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,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # ObjectInspector is the base namespace for all modules/classes related to the
3
+ # Defines the base namespace for all modules/classes used by the
4
4
  # object_inspector gem.
5
5
  module ObjectInspector
6
6
  # Accessor for the {ObjectInspector::Configuration} object.
@@ -11,6 +11,8 @@ module ObjectInspector
11
11
  # @yieldparam configuration [ObjectInspector::Configuration]
12
12
  def self.configure
13
13
  yield(configuration)
14
+
15
+ configuration
14
16
  end
15
17
 
16
18
  # Reset the current configuration settings memoized by
@@ -19,11 +21,11 @@ module ObjectInspector
19
21
  @configuration = Configuration.new
20
22
  end
21
23
 
24
+ # :reek:TooManyInstanceVariables, :reek:TooManyMethods
25
+
22
26
  # ObjectInspector::Configuration stores the default configuration options for
23
27
  # the ObjectInspector gem. Modification of attributes is possible at any time,
24
28
  # and values will persist for the duration of the running process.
25
- #
26
- # :reek:TooManyInstanceVariables
27
29
  class Configuration
28
30
  attr_reader :formatter_class,
29
31
  :inspect_method_prefix,
@@ -36,17 +38,59 @@ module ObjectInspector
36
38
  :issues_separator,
37
39
  :info_separator
38
40
 
39
- def initialize
40
- @formatter_class = TemplatingFormatter
41
- @inspect_method_prefix = "inspect"
42
- @default_scope = Scope.new(:self)
43
- @wild_card_scope = "all"
44
- @out_of_scope_placeholder = "*"
45
- @presented_object_separator = " #{[0x21E8].pack("U")} "
46
- @name_separator = " - "
47
- @flags_separator = " / "
48
- @issues_separator = " | "
49
- @info_separator = " | "
41
+ # :reek:LongParameterList, :reek:BooleanParameter
42
+ def initialize( # rubocop:disable Metrics/MethodLength, Metrics/ParameterLists
43
+ enabled: true,
44
+ formatter_class: TemplatingFormatter,
45
+ inspect_method_prefix: "inspect",
46
+ default_scope: Scope.new(:self),
47
+ wild_card_scope: "all",
48
+ out_of_scope_placeholder: "*",
49
+ presented_object_separator: " #{[0x21E8].pack("U")} ", # This is: " ⇨ "
50
+ name_separator: " - ",
51
+ flags_separator: " / ",
52
+ issues_separator: " | ",
53
+ info_separator: " | "
54
+ )
55
+ @enabled = enabled
56
+ @formatter_class = formatter_class
57
+ @inspect_method_prefix = inspect_method_prefix
58
+ @default_scope = default_scope
59
+ @wild_card_scope = wild_card_scope
60
+ @out_of_scope_placeholder = out_of_scope_placeholder
61
+ @presented_object_separator = presented_object_separator
62
+ @name_separator = name_separator
63
+ @flags_separator = flags_separator
64
+ @issues_separator = issues_separator
65
+ @info_separator = info_separator
66
+ end
67
+
68
+ # @param value [Object] Coerced to a Boolean with `!!value`.
69
+ def enabled=(value)
70
+ @enabled = !!value
71
+ end
72
+
73
+ # Toggles between {#enable} and {#disable} based on {#enabled?}.
74
+ def toggle = enabled? ? disable : enable
75
+
76
+ # @return [Boolean]
77
+ def enabled? = @enabled
78
+
79
+ # Enable Object Inspector for the current process and print a status
80
+ # message to `$stdout`.
81
+ def enable
82
+ self.enabled = true
83
+ puts(" -> ObjectInspector enabled")
84
+ end
85
+
86
+ # @return [Boolean]
87
+ def disabled? = !enabled?
88
+
89
+ # Disable Object Inspector for the current process and print a status
90
+ # message to `$stdout`.
91
+ def disable
92
+ self.enabled = false
93
+ puts(" -> ObjectInspector disabled")
50
94
  end
51
95
 
52
96
  def formatter_class=(value)
@@ -99,8 +143,8 @@ require "object_inspector/version"
99
143
  require "object_inspector/conversions"
100
144
  require "object_inspector/inspector"
101
145
  require "object_inspector/scope"
102
- require "object_inspector/inspectors_helper"
103
- require "object_inspector/object_interrogator"
146
+ require "object_inspector/inspect_behaviors"
147
+ require "object_inspector/interrogate_object"
104
148
  require "object_inspector/formatters/base_formatter"
105
149
  require "object_inspector/formatters/combining_formatter"
106
150
  require "object_inspector/formatters/templating_formatter"
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: object_inspector
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul DobbinSchmaltz
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-04-02 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: benchmark-ips
@@ -67,7 +67,7 @@ dependencies:
67
67
  version: '0'
68
68
  description: Object Inspector takes Object#inspect to the next level. Specify any
69
69
  combination of identification attributes, flags, issues, info, and/or a name along
70
- with an optional, self-definable scope option to represents objects. Great for the
70
+ with an optional, self-definable scope option to represent objects. Great for the
71
71
  console, logging, etc.
72
72
  email:
73
73
  - p.dobbinschmaltz@icloud.com
@@ -82,9 +82,9 @@ files:
82
82
  - lib/object_inspector/formatters/base_formatter.rb
83
83
  - lib/object_inspector/formatters/combining_formatter.rb
84
84
  - lib/object_inspector/formatters/templating_formatter.rb
85
+ - lib/object_inspector/inspect_behaviors.rb
85
86
  - lib/object_inspector/inspector.rb
86
- - lib/object_inspector/inspectors_helper.rb
87
- - lib/object_inspector/object_interrogator.rb
87
+ - lib/object_inspector/interrogate_object.rb
88
88
  - lib/object_inspector/scope.rb
89
89
  - lib/object_inspector/version.rb
90
90
  homepage: https://github.com/pdobb/object_inspector
@@ -110,7 +110,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
110
110
  - !ruby/object:Gem::Version
111
111
  version: '0'
112
112
  requirements: []
113
- rubygems_version: 3.6.6
113
+ rubygems_version: 3.7.2
114
114
  specification_version: 4
115
115
  summary: Object Inspector builds uniformly formatted inspect output with customizable
116
116
  amounts of detail.
@@ -1,24 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # ObjectInspector::InspectorsHelper can be included into any object to
4
- # simplify the process of instantiating an ObjectInspector::Inspector and
5
- # generating the inspection output.
6
- module ObjectInspector::InspectorsHelper
7
- # Calls {ObjectInspector::Inspector.inspect} on the passed in `object`,
8
- # passing through any keyword arguments.
9
- #
10
- # @return [String]
11
- def inspect(object = self, **)
12
- ObjectInspector::Inspector.inspect(object, **)
13
- end
14
-
15
- # Like {#inspect} but forces scope to `:all`. This (the bang (!) version) is
16
- # considered the "more dangerous" version of {#inspect} in the sense that the
17
- # `:all` scope may result in additional queries or extra processing--depending
18
- # on how the inspect hooks are setup.
19
- #
20
- # @return [String]
21
- def inspect!(object = self, **)
22
- ObjectInspector::Inspector.inspect(object, **, scope: :all)
23
- end
24
- end