object_identifier 0.3.0 → 0.4.1

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: 594dc64f6fbb19ee55894da1b9c1e122d23cea3eec1caf78e13671e8e0472e61
4
- data.tar.gz: 3842e0eba2e37555e020c44e679383422ad29f12f2945e3918cdd0e76c5998ff
3
+ metadata.gz: c0a0e09332282b492a3c9e83f9ab59a319a421c9ed3e83c2bfa87f6bfe20e6bd
4
+ data.tar.gz: 7b27cf091a8ecfd1c747fb75918f4b88aabd725dba3221489021aa2f5d24138a
5
5
  SHA512:
6
- metadata.gz: 195fbb54d47c00305d2b46d640db4629dc75deac68ec70c70679b90ec07cbf482dfe747dc1e6d2ae262bf3c85eb46d03aea312e377b528815635ba86db4ada2c
7
- data.tar.gz: bd36eac52299c54da4d2a99ad02d9c8e0a04ba82260b59255183ba734b93460cbb49b3105d6863729be96035e79486e75c5763e3ba661e2d696cbd84d606d9e6
6
+ metadata.gz: 6b1150c07800795094a4f15e475ba180187c51e248f0a5cfb385030b9720c4b2e3000692974f89eecc211b223778159b3041b358957265ae7e2e55b2835f8e47
7
+ data.tar.gz: 75b8bc577271cfe6b8a58ec5ec8a7d65c1e308aee3dfef8481e65869ac4e749ff9725f7f0d4fa752b391638c0e4b0003cafd2cd91ff352514fa03301df7931e8
data/.rubocop.yml CHANGED
@@ -3,7 +3,8 @@ AllCops:
3
3
  DisplayCopNames: true
4
4
  DisplayStyleGuide: true
5
5
  ExtraDetails: false
6
- TargetRubyVersion: 2.5.3
6
+ TargetRubyVersion: 2.4.0
7
+ NewCops: enable
7
8
 
8
9
  Layout/DotPosition:
9
10
  EnforcedStyle: trailing
@@ -11,16 +12,16 @@ Layout/DotPosition:
11
12
  Layout/EndOfLine:
12
13
  EnforcedStyle: lf
13
14
 
14
- Layout/IndentFirstArgument:
15
+ Layout/FirstArgumentIndentation:
15
16
  EnforcedStyle: consistent_relative_to_receiver
16
17
 
17
- Layout/IndentFirstArrayElement:
18
+ Layout/FirstArrayElementIndentation:
18
19
  EnforcedStyle: consistent
19
20
 
20
- Layout/IndentFirstHashElement:
21
+ Layout/FirstHashElementIndentation:
21
22
  EnforcedStyle: consistent
22
23
 
23
- Layout/IndentFirstParameter:
24
+ Layout/FirstParameterIndentation:
24
25
  Enabled: false # Revisit if more settings become available.
25
26
 
26
27
  Layout/MultilineMethodCallBraceLayout:
@@ -59,7 +60,7 @@ Metrics/LineLength:
59
60
  Exclude:
60
61
  - "object_identifier.gemspec"
61
62
 
62
- Naming/UncommunicativeMethodParamName:
63
+ Naming/MethodParameterName:
63
64
  AllowedNames:
64
65
  - a
65
66
  - b
data/CHANGELOG.md CHANGED
@@ -1,8 +1,19 @@
1
+ ### 0.4.1 - 2022-12-?
2
+ - Make compatible with Ruby 3.2 (and likely Ruby 3.0 and 3.1 as well).
3
+ - Update development dependencies.
4
+
5
+ ### 0.4.0 - 2020-09-01
6
+ - [#4](https://github.com/pdobb/object_identifier/pull/4) Only show attribute names if identifying more than one attribute.
7
+ - Update development dependencies.
8
+
9
+ #### BREAKING
10
+ - Drop support for Ruby 2.3.
11
+
1
12
  ### 0.3.0 - 2019-06-27
2
13
  - Fix identification of objects that implement `to_a`, such as Struct.
3
14
 
4
15
  ### 0.2.1 - 2019-02-24
5
- - Add ability to identify instance vars
16
+ - Add ability to identify instance vars.
6
17
 
7
18
  ### 0.1.0 - 2018-04-14
8
19
  - Revamp gem.
data/Gemfile.lock CHANGED
@@ -1,77 +1,63 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- object_identifier (0.3.0)
4
+ object_identifier (0.4.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
9
  ansi (1.5.0)
10
- ast (2.4.0)
11
- axiom-types (0.1.1)
12
- descendants_tracker (~> 0.0.4)
13
- ice_nine (~> 0.11.0)
14
- thread_safe (~> 0.3, >= 0.3.1)
15
- builder (3.2.3)
16
- byebug (11.0.1)
17
- codeclimate-engine-rb (0.4.1)
18
- virtus (~> 1.0)
19
- coderay (1.1.2)
20
- coercible (1.0.0)
21
- descendants_tracker (~> 0.0.1)
22
- descendants_tracker (0.0.4)
23
- thread_safe (~> 0.3, >= 0.3.1)
24
- docile (1.3.2)
25
- equalizer (0.0.11)
26
- ice_nine (0.11.2)
27
- jaro_winkler (1.5.3)
28
- json (2.2.0)
10
+ ast (2.4.2)
11
+ builder (3.2.4)
12
+ byebug (11.1.3)
13
+ coderay (1.1.3)
14
+ docile (1.4.0)
15
+ json (2.6.3)
29
16
  kwalify (0.7.2)
30
- method_source (0.9.2)
31
- minitest (5.11.3)
32
- minitest-reporters (1.3.6)
17
+ method_source (1.0.0)
18
+ minitest (5.16.3)
19
+ minitest-reporters (1.5.0)
33
20
  ansi
34
21
  builder
35
22
  minitest (>= 5.0)
36
23
  ruby-progressbar
37
- parallel (1.17.0)
38
- parser (2.6.3.0)
39
- ast (~> 2.4.0)
40
- pry (0.12.2)
41
- coderay (~> 1.1.0)
42
- method_source (~> 0.9.0)
43
- pry-byebug (3.7.0)
24
+ parallel (1.22.1)
25
+ parser (3.1.3.0)
26
+ ast (~> 2.4.1)
27
+ pry (0.14.1)
28
+ coderay (~> 1.1)
29
+ method_source (~> 1.0)
30
+ pry-byebug (3.10.1)
44
31
  byebug (~> 11.0)
45
- pry (~> 0.10)
46
- psych (3.1.0)
47
- rainbow (3.0.0)
48
- rake (12.3.2)
49
- reek (5.4.0)
50
- codeclimate-engine-rb (~> 0.4.0)
32
+ pry (>= 0.13, < 0.15)
33
+ rainbow (3.1.1)
34
+ rake (13.0.6)
35
+ reek (6.1.3)
51
36
  kwalify (~> 0.7.0)
52
- parser (>= 2.5.0.0, < 2.7, != 2.5.1.1)
53
- psych (~> 3.1.0)
37
+ parser (~> 3.1.0)
54
38
  rainbow (>= 2.0, < 4.0)
55
- rubocop (0.72.0)
56
- jaro_winkler (~> 1.5.1)
39
+ regexp_parser (2.6.1)
40
+ rexml (3.2.5)
41
+ rubocop (1.41.1)
42
+ json (~> 2.3)
57
43
  parallel (~> 1.10)
58
- parser (>= 2.6)
44
+ parser (>= 3.1.2.1)
59
45
  rainbow (>= 2.2.2, < 4.0)
46
+ regexp_parser (>= 1.8, < 3.0)
47
+ rexml (>= 3.2.5, < 4.0)
48
+ rubocop-ast (>= 1.23.0, < 2.0)
60
49
  ruby-progressbar (~> 1.7)
61
- unicode-display_width (>= 1.4.0, < 1.7)
62
- ruby-progressbar (1.10.1)
63
- simplecov (0.16.1)
50
+ unicode-display_width (>= 1.4.0, < 3.0)
51
+ rubocop-ast (1.24.1)
52
+ parser (>= 3.1.1.0)
53
+ ruby-progressbar (1.11.0)
54
+ simplecov (0.22.0)
64
55
  docile (~> 1.1)
65
- json (>= 1.8, < 3)
66
- simplecov-html (~> 0.10.0)
67
- simplecov-html (0.10.2)
68
- thread_safe (0.3.6)
69
- unicode-display_width (1.6.0)
70
- virtus (1.0.5)
71
- axiom-types (~> 0.1)
72
- coercible (~> 1.0)
73
- descendants_tracker (~> 0.0, >= 0.0.3)
74
- equalizer (~> 0.0, >= 0.0.9)
56
+ simplecov-html (~> 0.11)
57
+ simplecov_json_formatter (~> 0.1)
58
+ simplecov-html (0.12.3)
59
+ simplecov_json_formatter (0.1.4)
60
+ unicode-display_width (2.3.0)
75
61
 
76
62
  PLATFORMS
77
63
  ruby
@@ -90,4 +76,4 @@ DEPENDENCIES
90
76
  simplecov
91
77
 
92
78
  BUNDLED WITH
93
- 2.0.1
79
+ 2.4.1
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2018 Paul Dobbins
3
+ Copyright (c) 2022 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
@@ -1,7 +1,6 @@
1
1
  # Object Identifier
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/object_identifier.svg)](https://badge.fury.io/rb/object_identifier)
4
- [![Build Status](https://travis-ci.org/pdobb/object_identifier.svg?branch=master)](https://travis-ci.org/pdobb/object_identifier)
5
4
  [![Test Coverage](https://api.codeclimate.com/v1/badges/0b737a72d16ec755c1ff/test_coverage)](https://codeclimate.com/github/pdobb/object_identifier/test_coverage)
6
5
  [![Maintainability](https://api.codeclimate.com/v1/badges/0b737a72d16ec755c1ff/maintainability)](https://codeclimate.com/github/pdobb/object_identifier/maintainability)
7
6
 
@@ -40,11 +39,10 @@ Or install it yourself as:
40
39
  ## Compatibility
41
40
 
42
41
  Tested MRI Ruby Versions:
43
- * 2.2.10
44
- * 2.3.7
45
- * 2.4.4
46
- * 2.5.1
47
- * edge
42
+ * 3.2.0
43
+ * 2.4.9
44
+ * 2.5.8
45
+ * 2.6.6
48
46
 
49
47
 
50
48
  ## Usage
@@ -54,33 +52,38 @@ Tested MRI Ruby Versions:
54
52
  `identify` outputs the `id` of the receiving object by default, if it exists and no other attributes/methods are specified.
55
53
 
56
54
  ```ruby
57
- my_movie.identify # => Movie[id:1]
58
- my_movie.identify(:rating) # => Movie[rating:"7/10"]
55
+ my_movie.identify # => Movie[1]
59
56
  ```
60
57
 
61
- Private methods can be identified just the same as public methods.
58
+ `identify` doesn't output labels if only identifying a single attribute/method. It includes labels when two or more attributes/methods are being identified.
62
59
 
63
60
  ```ruby
64
- my_movie.identify(:my_private_method) # => Movie[my_private_method:"Shh"]
61
+ my_movie.identify(:id) # => Movie[1]
62
+ my_movie.identify(:rating) # => Movie["7/10"]
63
+ my_movie.identify(:id, :rating) # => Movie[id:1, rating:"7/10"]
65
64
  ```
66
65
 
66
+ Private methods can be identified just the same as public methods.
67
+
68
+ ```ruby
69
+ my_movie.identify(:my_private_method) # => Movie["Shh"]
70
+ ```
67
71
 
68
72
  ### Unknown Attributes/Methods
69
73
 
70
74
  If the object doesn't respond to a specified attribute/method it is simply ignored:
71
75
 
72
76
  ```ruby
73
- my_movie.identify(:gobble_gobble, :rating) # => Movie[rating:"7/10"]
77
+ my_movie.identify(:id, :rating, :other) # => Movie[id:1, rating:"7/10"]
74
78
  ```
75
79
 
76
80
  ### Overriding Class Names
77
81
 
78
82
  ```ruby
79
- my_delayed_job.identify(klass: "Delayed::Job") # => Delayed::Job[id:1]
80
- my_movie.identify(klass: nil) # => [id:1]
83
+ my_delayed_job.identify(klass: "Delayed::Job") # => Delayed::Job[1]
84
+ my_movie.identify(klass: nil) # => [1]
81
85
  ```
82
86
 
83
-
84
87
  ### Identifying Nil
85
88
 
86
89
  ```ruby
@@ -88,7 +91,6 @@ nil.identify(:id, :name) # => [no objects]
88
91
  nil.identify(:id, :name, klass: "Nope") # => [no objects]
89
92
  ```
90
93
 
91
-
92
94
  ### Collections
93
95
 
94
96
  Collections of objects are each identified in turn.
@@ -101,7 +103,7 @@ Collections of objects are each identified in turn.
101
103
  The number of results that will be identified from a collection can be truncated by specifying the `limit` option.
102
104
 
103
105
  ```ruby
104
- [my_movie, my_contact].identify(:id, :name, limit: 1)
106
+ [my_movie, my_user].identify(:id, :name, limit: 1)
105
107
  # => Movie[id:1, name:"Pi"], ... (1 more)
106
108
  ```
107
109
 
@@ -154,7 +156,9 @@ ObjectIdentifier works great with the [ObjectInspector](https://github.com/pdobb
154
156
 
155
157
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
156
158
 
157
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
159
+ To install this gem onto your local machine, run `bundle exec rake install`.
160
+
161
+ To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
158
162
 
159
163
 
160
164
  ## Contributing
@@ -39,7 +39,7 @@ class Object
39
39
  #
40
40
  # (1..10).to_a.identify(:to_f, limit: 2)
41
41
  # # => "Integer[to_f:1.0], Integer[to_f:2.0], ... (8 more)"
42
- def identify(*args)
43
- ObjectIdentifier::Identifier.identify(self, *args)
42
+ def identify(*args, **kargs)
43
+ ObjectIdentifier::Identifier.identify(self, *args, **kargs)
44
44
  end
45
45
  end
@@ -39,8 +39,8 @@ module ObjectIdentifier
39
39
  #
40
40
  # ObjectIdentifier::Identifier.identify((1..10).to_a, :to_f, limit: 2)
41
41
  # # => "Integer[to_f:1.0], Integer[to_f:2.0], ... (8 more)"
42
- def self.identify(object, *args)
43
- new(object, *args).to_s
42
+ def self.identify(*args, **kargs)
43
+ new(*args, **kargs).to_s
44
44
  end
45
45
 
46
46
  def initialize(objects, *args, limit: nil, klass: :not_given)
@@ -90,9 +90,17 @@ module ObjectIdentifier
90
90
  def format_attributes(attributes_hash)
91
91
  return if attributes_hash.empty?
92
92
 
93
- attributes_hash.map { |(key, value)|
94
- "#{key}:#{value.inspect_lit}"
95
- }.join(", ")
93
+ attributes_hash.
94
+ map(&format_attributes_map_block(attributes_hash)).
95
+ join(", ")
96
+ end
97
+
98
+ def format_attributes_map_block(attributes_hash)
99
+ if attributes_hash.one?
100
+ ->(_key, value) { value.inspect_lit }
101
+ else
102
+ ->(key, value) { "#{key}:#{value.inspect_lit}" }
103
+ end
96
104
  end
97
105
 
98
106
  # @return [Hash]
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ObjectIdentifier
4
- VERSION = "0.3.0"
4
+ VERSION = "0.4.1"
5
5
  end
@@ -7,8 +7,9 @@ require "object_identifier/version"
7
7
  Gem::Specification.new do |spec|
8
8
  spec.name = "object_identifier"
9
9
  spec.version = ObjectIdentifier::VERSION
10
- spec.authors = ["Paul Dobbins", "Evan Sherwood"]
11
- spec.email = ["paul.dobbins@icloud.com"]
10
+ spec.authors = ["Paul DobbinSchmaltz", "Evan Sherwood"]
11
+ spec.email = ["p.dobbinschmaltz@icloud.com"]
12
+ spec.required_ruby_version = ">= 2.4.0"
12
13
 
13
14
  spec.summary = "ObjectIdentifier identifies an object by its class name and attributes."
14
15
  spec.description = "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."
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: object_identifier
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
- - Paul Dobbins
7
+ - Paul DobbinSchmaltz
8
8
  - Evan Sherwood
9
- autorequire:
9
+ autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2019-06-27 00:00:00.000000000 Z
12
+ date: 2022-12-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -155,7 +155,7 @@ description: Object Identifier allows quick, easy, and uniform identification of
155
155
  object by inspecting its class name and outputting any desirable attributes/methods.
156
156
  It is great for logging, sending descriptive notification messages, etc.
157
157
  email:
158
- - paul.dobbins@icloud.com
158
+ - p.dobbinschmaltz@icloud.com
159
159
  executables: []
160
160
  extensions: []
161
161
  extra_rdoc_files: []
@@ -163,7 +163,6 @@ files:
163
163
  - ".gitignore"
164
164
  - ".rubocop"
165
165
  - ".rubocop.yml"
166
- - ".travis.yml"
167
166
  - CHANGELOG.md
168
167
  - Gemfile
169
168
  - Gemfile.lock
@@ -184,7 +183,7 @@ homepage: https://github.com/pdobb/object_identifier
184
183
  licenses:
185
184
  - MIT
186
185
  metadata: {}
187
- post_install_message:
186
+ post_install_message:
188
187
  rdoc_options: []
189
188
  require_paths:
190
189
  - lib
@@ -192,15 +191,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
192
191
  requirements:
193
192
  - - ">="
194
193
  - !ruby/object:Gem::Version
195
- version: '0'
194
+ version: 2.4.0
196
195
  required_rubygems_version: !ruby/object:Gem::Requirement
197
196
  requirements:
198
197
  - - ">="
199
198
  - !ruby/object:Gem::Version
200
199
  version: '0'
201
200
  requirements: []
202
- rubygems_version: 3.0.4
203
- signing_key:
201
+ rubygems_version: 3.4.1
202
+ signing_key:
204
203
  specification_version: 4
205
204
  summary: ObjectIdentifier identifies an object by its class name and attributes.
206
205
  test_files: []
data/.travis.yml DELETED
@@ -1,21 +0,0 @@
1
- env:
2
- global:
3
- - CC_TEST_REPORTER_ID=3b57e55dcd3cc40ee073715e7d75fa80ab7b7687cb8a420eac500d27b5cb28db
4
- sudo: false
5
- language: ruby
6
- rvm:
7
- - 2.3.7
8
- - 2.4.4
9
- - 2.5.3
10
- - 2.6.2
11
- - ruby-head
12
- notifications:
13
- email: false
14
- before_install: gem install bundler -v 2.0.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