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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 594dc64f6fbb19ee55894da1b9c1e122d23cea3eec1caf78e13671e8e0472e61
4
- data.tar.gz: 3842e0eba2e37555e020c44e679383422ad29f12f2945e3918cdd0e76c5998ff
3
+ metadata.gz: bbab525606ca826781627ff66be0e57229d14be19e2d19d562f5f73d7b2b7a5d
4
+ data.tar.gz: b266c154b7c283721b335d752b40705b3ba9000ad46d0ad8689a1f7654249c54
5
5
  SHA512:
6
- metadata.gz: 195fbb54d47c00305d2b46d640db4629dc75deac68ec70c70679b90ec07cbf482dfe747dc1e6d2ae262bf3c85eb46d03aea312e377b528815635ba86db4ada2c
7
- data.tar.gz: bd36eac52299c54da4d2a99ad02d9c8e0a04ba82260b59255183ba734b93460cbb49b3105d6863729be96035e79486e75c5763e3ba661e2d696cbd84d606d9e6
6
+ metadata.gz: b83e5d96392c489dd19a32d265602161069db563c7bda67a4aa88eb28eca6ea26ffdf3641b52a060482493717c1f652b190b6545547b6ae4cadfa1cee3360451
7
+ data.tar.gz: 26f3c65910cd39d01e51af199b57f5a8fee3d1ddbe79f67b69552b0abf9c5f9da9752e8947afa0f663aa53e84f0968940cae59d9735a9f5c3745329ad778839d
@@ -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
@@ -4,14 +4,12 @@ env:
4
4
  sudo: false
5
5
  language: ruby
6
6
  rvm:
7
- - 2.3.7
8
- - 2.4.4
9
- - 2.5.3
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.0.1
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
@@ -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.
@@ -1,77 +1,61 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- object_identifier (0.3.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.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)
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.9.2)
31
- minitest (5.11.3)
32
- minitest-reporters (1.3.6)
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.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)
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.10)
31
+ pry (~> 0.13.0)
46
32
  psych (3.1.0)
47
33
  rainbow (3.0.0)
48
- rake (12.3.2)
49
- reek (5.4.0)
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.7, != 2.5.1.1)
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
- rubocop (0.72.0)
56
- jaro_winkler (~> 1.5.1)
40
+ regexp_parser (1.7.1)
41
+ rexml (3.2.4)
42
+ rubocop (0.90.0)
57
43
  parallel (~> 1.10)
58
- parser (>= 2.6)
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, < 1.7)
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.16.1)
54
+ simplecov (0.19.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-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.0.1
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.2.10
44
- * 2.3.7
45
- * 2.4.4
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 # => 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
 
@@ -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.0"
5
5
  end
@@ -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.3.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: 2019-06-27 00:00:00.000000000 Z
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: '0'
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.0.4
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: []