object_identifier 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +7 -6
- data/.travis.yml +4 -6
- data/CHANGELOG.md +8 -1
- data/Gemfile.lock +34 -50
- data/README.md +17 -15
- data/lib/object_identifier/identifier.rb +11 -3
- data/lib/object_identifier/version.rb +1 -1
- data/object_identifier.gemspec +1 -0
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bbab525606ca826781627ff66be0e57229d14be19e2d19d562f5f73d7b2b7a5d
|
4
|
+
data.tar.gz: b266c154b7c283721b335d752b40705b3ba9000ad46d0ad8689a1f7654249c54
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b83e5d96392c489dd19a32d265602161069db563c7bda67a4aa88eb28eca6ea26ffdf3641b52a060482493717c1f652b190b6545547b6ae4cadfa1cee3360451
|
7
|
+
data.tar.gz: 26f3c65910cd39d01e51af199b57f5a8fee3d1ddbe79f67b69552b0abf9c5f9da9752e8947afa0f663aa53e84f0968940cae59d9735a9f5c3745329ad778839d
|
data/.rubocop.yml
CHANGED
@@ -3,7 +3,8 @@ AllCops:
|
|
3
3
|
DisplayCopNames: true
|
4
4
|
DisplayStyleGuide: true
|
5
5
|
ExtraDetails: false
|
6
|
-
TargetRubyVersion: 2.
|
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/
|
15
|
+
Layout/FirstArgumentIndentation:
|
15
16
|
EnforcedStyle: consistent_relative_to_receiver
|
16
17
|
|
17
|
-
Layout/
|
18
|
+
Layout/FirstArrayElementIndentation:
|
18
19
|
EnforcedStyle: consistent
|
19
20
|
|
20
|
-
Layout/
|
21
|
+
Layout/FirstHashElementIndentation:
|
21
22
|
EnforcedStyle: consistent
|
22
23
|
|
23
|
-
Layout/
|
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/
|
63
|
+
Naming/MethodParameterName:
|
63
64
|
AllowedNames:
|
64
65
|
- a
|
65
66
|
- b
|
data/.travis.yml
CHANGED
@@ -4,14 +4,12 @@ env:
|
|
4
4
|
sudo: false
|
5
5
|
language: ruby
|
6
6
|
rvm:
|
7
|
-
- 2.
|
8
|
-
- 2.
|
9
|
-
- 2.
|
10
|
-
- 2.6.2
|
11
|
-
- ruby-head
|
7
|
+
- 2.4.9
|
8
|
+
- 2.5.8
|
9
|
+
- 2.6.6
|
12
10
|
notifications:
|
13
11
|
email: false
|
14
|
-
before_install: gem install bundler -v 2.
|
12
|
+
before_install: gem install bundler -v 2.1.4
|
15
13
|
cache: bundler
|
16
14
|
before_script:
|
17
15
|
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
data/CHANGELOG.md
CHANGED
@@ -1,8 +1,15 @@
|
|
1
|
+
### 0.4.0 - 2020-09-01
|
2
|
+
- [#4](https://github.com/pdobb/object_identifier/pull/4) Only show attribute names if identifying more than one attribute.
|
3
|
+
- Update development dependencies.
|
4
|
+
|
5
|
+
#### BREAKING
|
6
|
+
- Drop support for Ruby 2.3.
|
7
|
+
|
1
8
|
### 0.3.0 - 2019-06-27
|
2
9
|
- Fix identification of objects that implement `to_a`, such as Struct.
|
3
10
|
|
4
11
|
### 0.2.1 - 2019-02-24
|
5
|
-
- Add ability to identify instance vars
|
12
|
+
- Add ability to identify instance vars.
|
6
13
|
|
7
14
|
### 0.1.0 - 2018-04-14
|
8
15
|
- Revamp gem.
|
data/Gemfile.lock
CHANGED
@@ -1,77 +1,61 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
object_identifier (0.
|
4
|
+
object_identifier (0.4.0)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
9
|
ansi (1.5.0)
|
10
|
-
ast (2.4.
|
11
|
-
|
12
|
-
|
13
|
-
|
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)
|
10
|
+
ast (2.4.1)
|
11
|
+
builder (3.2.4)
|
12
|
+
byebug (11.1.3)
|
13
|
+
coderay (1.1.3)
|
24
14
|
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)
|
29
15
|
kwalify (0.7.2)
|
30
|
-
method_source (0.
|
31
|
-
minitest (5.
|
32
|
-
minitest-reporters (1.
|
16
|
+
method_source (1.0.0)
|
17
|
+
minitest (5.14.2)
|
18
|
+
minitest-reporters (1.4.2)
|
33
19
|
ansi
|
34
20
|
builder
|
35
21
|
minitest (>= 5.0)
|
36
22
|
ruby-progressbar
|
37
|
-
parallel (1.
|
38
|
-
parser (2.
|
39
|
-
ast (~> 2.4.
|
40
|
-
pry (0.
|
41
|
-
coderay (~> 1.1
|
42
|
-
method_source (~>
|
43
|
-
pry-byebug (3.
|
23
|
+
parallel (1.19.2)
|
24
|
+
parser (2.7.1.4)
|
25
|
+
ast (~> 2.4.1)
|
26
|
+
pry (0.13.1)
|
27
|
+
coderay (~> 1.1)
|
28
|
+
method_source (~> 1.0)
|
29
|
+
pry-byebug (3.9.0)
|
44
30
|
byebug (~> 11.0)
|
45
|
-
pry (~> 0.
|
31
|
+
pry (~> 0.13.0)
|
46
32
|
psych (3.1.0)
|
47
33
|
rainbow (3.0.0)
|
48
|
-
rake (
|
49
|
-
reek (
|
50
|
-
codeclimate-engine-rb (~> 0.4.0)
|
34
|
+
rake (13.0.1)
|
35
|
+
reek (6.0.1)
|
51
36
|
kwalify (~> 0.7.0)
|
52
|
-
parser (>= 2.5.0.0, < 2.
|
37
|
+
parser (>= 2.5.0.0, < 2.8, != 2.5.1.1)
|
53
38
|
psych (~> 3.1.0)
|
54
39
|
rainbow (>= 2.0, < 4.0)
|
55
|
-
|
56
|
-
|
40
|
+
regexp_parser (1.7.1)
|
41
|
+
rexml (3.2.4)
|
42
|
+
rubocop (0.90.0)
|
57
43
|
parallel (~> 1.10)
|
58
|
-
parser (>= 2.
|
44
|
+
parser (>= 2.7.1.1)
|
59
45
|
rainbow (>= 2.2.2, < 4.0)
|
46
|
+
regexp_parser (>= 1.7)
|
47
|
+
rexml
|
48
|
+
rubocop-ast (>= 0.3.0, < 1.0)
|
60
49
|
ruby-progressbar (~> 1.7)
|
61
|
-
unicode-display_width (>= 1.4.0, <
|
50
|
+
unicode-display_width (>= 1.4.0, < 2.0)
|
51
|
+
rubocop-ast (0.3.0)
|
52
|
+
parser (>= 2.7.1.4)
|
62
53
|
ruby-progressbar (1.10.1)
|
63
|
-
simplecov (0.
|
54
|
+
simplecov (0.19.0)
|
64
55
|
docile (~> 1.1)
|
65
|
-
|
66
|
-
|
67
|
-
|
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-html (0.12.2)
|
58
|
+
unicode-display_width (1.7.0)
|
75
59
|
|
76
60
|
PLATFORMS
|
77
61
|
ruby
|
@@ -90,4 +74,4 @@ DEPENDENCIES
|
|
90
74
|
simplecov
|
91
75
|
|
92
76
|
BUNDLED WITH
|
93
|
-
2.
|
77
|
+
2.1.4
|
data/README.md
CHANGED
@@ -40,11 +40,9 @@ Or install it yourself as:
|
|
40
40
|
## Compatibility
|
41
41
|
|
42
42
|
Tested MRI Ruby Versions:
|
43
|
-
* 2.
|
44
|
-
* 2.
|
45
|
-
* 2.
|
46
|
-
* 2.5.1
|
47
|
-
* edge
|
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
|
58
|
-
my_movie.identify(:rating) # => Movie[rating:"7/10"]
|
55
|
+
my_movie.identify # => Movie[1]
|
59
56
|
```
|
60
57
|
|
61
|
-
|
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(:
|
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(:
|
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[
|
80
|
-
my_movie.identify(klass: nil) # => [
|
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,
|
106
|
+
[my_movie, my_user].identify(:id, :name, limit: 1)
|
105
107
|
# => Movie[id:1, name:"Pi"], ... (1 more)
|
106
108
|
```
|
107
109
|
|
@@ -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.
|
94
|
-
|
95
|
-
|
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]
|
data/object_identifier.gemspec
CHANGED
@@ -9,6 +9,7 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.version = ObjectIdentifier::VERSION
|
10
10
|
spec.authors = ["Paul Dobbins", "Evan Sherwood"]
|
11
11
|
spec.email = ["paul.dobbins@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.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paul Dobbins
|
8
8
|
- Evan Sherwood
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2020-09-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -184,7 +184,7 @@ homepage: https://github.com/pdobb/object_identifier
|
|
184
184
|
licenses:
|
185
185
|
- MIT
|
186
186
|
metadata: {}
|
187
|
-
post_install_message:
|
187
|
+
post_install_message:
|
188
188
|
rdoc_options: []
|
189
189
|
require_paths:
|
190
190
|
- lib
|
@@ -192,15 +192,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
192
192
|
requirements:
|
193
193
|
- - ">="
|
194
194
|
- !ruby/object:Gem::Version
|
195
|
-
version:
|
195
|
+
version: 2.4.0
|
196
196
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
197
197
|
requirements:
|
198
198
|
- - ">="
|
199
199
|
- !ruby/object:Gem::Version
|
200
200
|
version: '0'
|
201
201
|
requirements: []
|
202
|
-
rubygems_version: 3.
|
203
|
-
signing_key:
|
202
|
+
rubygems_version: 3.1.4
|
203
|
+
signing_key:
|
204
204
|
specification_version: 4
|
205
205
|
summary: ObjectIdentifier identifies an object by its class name and attributes.
|
206
206
|
test_files: []
|