object_identifier 0.8.0 → 0.10.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5b85174f7e95e1acad9f62da0d27dd867435668009aaf20d37a77de955835837
4
- data.tar.gz: bbf1820134da13adc7bf0cc1ed41653afa63a0b0023b205d5b5179156227f202
3
+ metadata.gz: 38798b7f089d030451f58184525dead78487ef58d077950f5431902f6fa81ba9
4
+ data.tar.gz: 6fd7204e666fc5340dfeb303c86829b8595c5c7fc9fd4047c1abf9635444f8ae
5
5
  SHA512:
6
- metadata.gz: 0beefb1a00fe450580879bcd8b1095f30a412eaa2b6a32033c614753b828eb6a4bb96e5d891935666d82cde9233bf73c010162d9bccb345a4946ab4f4e7f2833
7
- data.tar.gz: 48b59efffdb83a460f471d6ba957b6ba3166b3aaf6cc1b19d7d17afd4a274b607de02a4f853f51806489f56de77bfaa4c2cc2461665f8dd5bee61f8dd4b27145
6
+ metadata.gz: 33eefb5c23a4f22cb0aaa9a05506068b4d6940e2f04054868dc5e7971f045893828c6372f2cd5b4dd4ff4d1fcc73200cc6cf9129d9adf9f3482ec9605a30e58a
7
+ data.tar.gz: 571cfbcef11143e7b052a2aa4a2e0497f3526481a068715cc3a427875751b1e9b90a0bde5cf989ca9ab2e2df026805d21a1237fbf893db63e86cae975d4ebf96
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2024 Paul DobbinSchmaltz
3
+ Copyright (c) 2025 Paul DobbinSchmaltz
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -2,7 +2,6 @@
2
2
 
3
3
  [![Gem Version](https://img.shields.io/github/v/release/pdobb/object_identifier)](https://img.shields.io/github/v/release/pdobb/object_identifier)
4
4
  [![CI Actions](https://github.com/pdobb/object_identifier/actions/workflows/ci.yml/badge.svg)](https://github.com/pdobb/object_identifier/actions)
5
- [![Maintainability](https://api.codeclimate.com/v1/badges/0b737a72d16ec755c1ff/maintainability)](https://codeclimate.com/github/pdobb/object_identifier/maintainability)
6
5
 
7
6
  Object Identifier allows quick, easy, and uniform identification of an object by inspecting its class name and outputting any desirable attributes/methods. It is great for logging, sending descriptive notification messages, etc.
8
7
 
@@ -38,11 +37,17 @@ Or install it yourself as:
38
37
 
39
38
  Tested MRI Ruby Versions:
40
39
 
41
- - 3.1
42
40
  - 3.2
43
41
  - 3.3
42
+ - 3.4
44
43
 
45
- Note: For Ruby 2.7 or 3.1 support, install object_identifier gem version 0.7.0.
44
+ For Ruby 2.7 support, install object_identifier gem version 0.7.0.
45
+
46
+ ```ruby
47
+ gem "object_identifier", "0.7.0"
48
+ ```
49
+
50
+ For Ruby 3.1 support, install object_identifier gem version 0.9.0.
46
51
 
47
52
  ```ruby
48
53
  gem "object_identifier", "0.7.0"
@@ -133,36 +138,6 @@ The number of results that will be identified from a collection can be truncated
133
138
  {}.identify # => [no objects]
134
139
  ```
135
140
 
136
- ## Custom Object Identifiers
137
-
138
- Internally, Object Identifier calls `inspect_lit` to return a "literally-inspected" string representation of an object. This works because Object, itself, is monkey-patched to define `inspect_lit` which just returns `inspect`. This is sufficient for most objects, but some objects will benefit from defining special output from `inspect_lit`.
139
-
140
- Object Identifier defines `inspect_lit` on three other core objects: String, Symbol, and BigDecimal.
141
-
142
- ```ruby
143
- "a_string".inspect_lit # => "\"a_string\""
144
- :a_symbol.inspect_lit # => ":\"a_symbol\""
145
- BigDecimal(1.99, 3).inspect_lit # => "<BD:1.99>"
146
- ```
147
-
148
- To identify an object in a special way, just define `inspect_lit` to return a custom String.
149
-
150
- ```ruby
151
- class MyValueObject
152
- def initialize(val)
153
- @val = val
154
- end
155
-
156
- def inspect_lit
157
- "#{@val} Meters"
158
- end
159
- end
160
-
161
- my_value_object = MyValueObject.new(42)
162
- OpenStruct.new(my_value: my_value_object).identify(:my_value)
163
- # => "OpenStruct[my_value:42 Meters]"
164
- ```
165
-
166
141
  ## Supporting Gems
167
142
 
168
143
  Object Identifier works great with the [Object Inspector](https://github.com/pdobb/object_inspector) gem.
@@ -191,7 +166,7 @@ To install this gem onto your local machine, run `bundle exec rake install`.
191
166
 
192
167
  ### Testing
193
168
 
194
- To test this gem (gemwork):
169
+ To test this gem:
195
170
 
196
171
  ```bash
197
172
  rake
@@ -210,7 +185,7 @@ npx prettier . --write
210
185
 
211
186
  ### Releases
212
187
 
213
- To release a new version of Gemwork to RubyGems:
188
+ To release a new version of this gem to RubyGems:
214
189
 
215
190
  1. Update the version number in `version.rb`
216
191
  2. Update `CHANGELOG.md`
@@ -2,14 +2,6 @@
2
2
 
3
3
  # Reopen the core Object class to add {#identify} to all objects.
4
4
  class Object
5
- # Standard #inspect for any object that doesn't override this method. This
6
- # method is meant to make an object's type inherently obvious inspected.
7
- #
8
- # @return [String] a String-literal representation of this object
9
- def inspect_lit
10
- inspect
11
- end
12
-
13
5
  # Instance method for constructing a self-identifying string for any given
14
6
  # object or list of objects.
15
7
  #
@@ -39,7 +31,7 @@ class Object
39
31
  #
40
32
  # (1..10).to_a.identify(:to_f, limit: 2)
41
33
  # # => "Integer[to_f:1.0], Integer[to_f:2.0], ... (8 more)"
42
- def identify(*args, **kwargs)
43
- ObjectIdentifier.(self, *args, **kwargs)
34
+ def identify(...)
35
+ ObjectIdentifier.(self, ...)
44
36
  end
45
37
  end
@@ -23,14 +23,14 @@ class ObjectIdentifier::StringFormatter < ObjectIdentifier::BaseFormatter
23
23
 
24
24
  private
25
25
 
26
- def format_collection
27
- Collection.new(objects, parameters).call
28
- end
29
-
30
26
  def format_item(object = objects.first)
31
27
  Item.new(object, parameters).call
32
28
  end
33
29
 
30
+ def format_collection
31
+ Collection.new(objects, parameters).call
32
+ end
33
+
34
34
  # ObjectIdentifier::StringFormatter::Collection formats a collection-specific
35
35
  # identification String, which will also necessarily be composed of
36
36
  # {ObjectIdentifier::StringFormatter::Item} identification Strings.
@@ -122,9 +122,9 @@ class ObjectIdentifier::StringFormatter < ObjectIdentifier::BaseFormatter
122
122
  def attributes_formatter
123
123
  @attributes_formatter ||=
124
124
  if attributes_hash.one?
125
- ->(_key, value) { value.inspect_lit }
125
+ ->(_key, value) { value.inspect }
126
126
  else # attributes_hash.size > 1
127
- ->(key, value) { "#{key}:#{value.inspect_lit}" }
127
+ ->(key, value) { "#{key}:#{value.inspect}" }
128
128
  end
129
129
  end
130
130
 
@@ -12,7 +12,6 @@ module ObjectIdentifier
12
12
  *attributes,
13
13
  formatter_class: default_formatter_class,
14
14
  **formatter_options)
15
-
16
15
  parameters =
17
16
  ObjectIdentifier::Parameters.build(
18
17
  attributes: attributes,
@@ -2,5 +2,5 @@
2
2
 
3
3
  module ObjectIdentifier
4
4
  # The current ObjectIdentifier gem version.
5
- VERSION = "0.8.0"
5
+ VERSION = "0.10.0"
6
6
  end
@@ -18,6 +18,3 @@ require "object_identifier/formatters/string_formatter"
18
18
  # CORE EXTENSIONS
19
19
 
20
20
  require "core_ext/object"
21
- require "core_ext/string"
22
- require "core_ext/symbol"
23
- require "core_ext/big_decimal"
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: object_identifier
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul DobbinSchmaltz
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2024-11-21 00:00:00.000000000 Z
10
+ date: 2025-01-04 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: benchmark-ips
@@ -63,10 +62,7 @@ extra_rdoc_files: []
63
62
  files:
64
63
  - LICENSE.txt
65
64
  - README.md
66
- - lib/core_ext/big_decimal.rb
67
65
  - lib/core_ext/object.rb
68
- - lib/core_ext/string.rb
69
- - lib/core_ext/symbol.rb
70
66
  - lib/object_identifier.rb
71
67
  - lib/object_identifier/array_wrap.rb
72
68
  - lib/object_identifier/configuration.rb
@@ -84,7 +80,6 @@ metadata:
84
80
  source_code_uri: https://github.com/pdobb/object_identifier
85
81
  homepage_uri: https://github.com/pdobb/object_identifier
86
82
  rubygems_mfa_required: 'true'
87
- post_install_message:
88
83
  rdoc_options: []
89
84
  require_paths:
90
85
  - lib
@@ -92,15 +87,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
92
87
  requirements:
93
88
  - - ">="
94
89
  - !ruby/object:Gem::Version
95
- version: '3.1'
90
+ version: '3.2'
96
91
  required_rubygems_version: !ruby/object:Gem::Requirement
97
92
  requirements:
98
93
  - - ">="
99
94
  - !ruby/object:Gem::Version
100
95
  version: '0'
101
96
  requirements: []
102
- rubygems_version: 3.3.27
103
- signing_key:
97
+ rubygems_version: 3.6.2
104
98
  specification_version: 4
105
99
  summary: Object Identifier identifies an object by its class name and attributes.
106
100
  test_files: []
@@ -1,17 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "bigdecimal"
4
-
5
- # Reopen the core BigDecimal class to represent {#inspect_lit}.
6
- class BigDecimal
7
- # Formats this BigDecimal as an object-type-revealing String.
8
- #
9
- # @return [String] a String representation of this BigDecimal object
10
- #
11
- # @example
12
- # BigDecimal.new(1).inspect_lit # => "<BD:1.0>"
13
- # BigDecimal.new(99.999, 5).inspect_lit # => "<BD:99.999>"
14
- def inspect_lit
15
- "<BD:#{self}>"
16
- end
17
- end
@@ -1,17 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Reopen the core String class to represent {#inspect_lit}.
4
- class String
5
- # Formats self to look like a String literal so that object type will be
6
- # inherently obvious when inspected.
7
- #
8
- # @return [String] a String-literal representation of this object
9
- #
10
- # @example
11
- # "test".inspect_lit # => "\"test\"" (i.e. '"test"')
12
- # "1".inspect_lit # => "\"1\"" (i.e. '"1"')
13
- # "12.3".inspect_lit # => "\"12.3\"" (i.e. '"12.3"')
14
- def inspect_lit
15
- %("#{self}")
16
- end
17
- end
@@ -1,16 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Reopen the core Symbol class to represent {#inspect_lit}.
4
- class Symbol
5
- # Formats this symbol to look like a symbol literal so that object type will
6
- # be inherently obvious when used in logging methods, etc.
7
- #
8
- # @return [String] a symbol literal representation of this object
9
- #
10
- # @example
11
- # :test.inspect_lit # => ":\"test\"" (or ':"test"')
12
- # :"ta-da!".inspect_lit # => ":\"ta-da!\"" (or ':"ta-da!"')
13
- def inspect_lit
14
- %(:"#{self}")
15
- end
16
- end