object_identifier 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -0
- data/lib/object_identifier.rb +1 -0
- data/lib/object_identifier/core_ext/big_decimal.rb +9 -0
- data/lib/object_identifier/version.rb +1 -1
- data/test/core_ext/big_decimal_test.rb +12 -0
- data/test/core_ext/object_test.rb +2 -2
- data/test/core_ext/string_test.rb +1 -1
- data/test/core_ext/symbol_test.rb +1 -1
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/object_identifier_test.rb +15 -15
- data/test/test_helper.rb +0 -5
- metadata +19 -41
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 145c33d70d8d3e4122c427a6c2a5ae956cfe7ed0
|
4
|
+
data.tar.gz: c550160bd82b0417256face662342f33c567a1a6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 28deb5124d478be4452168bc59cb371704d60481a8adae647e6edf9672c52272058a5c48bf63e9b2ba3a28e710cdbf75bf92f4c2400104478277ea13b0e4e8d3
|
7
|
+
data.tar.gz: 5772ec327a63e2f0a528398c73c7738a66af8d436b1a48b5189d0bfd85c7d3d53e841d69bcd75a76efac04f70933a92bda312e835a79b2393e6e2d8421c12357
|
data/README.md
CHANGED
data/lib/object_identifier.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require "object_identifier/core_ext/object"
|
2
2
|
require "object_identifier/core_ext/string"
|
3
3
|
require "object_identifier/core_ext/symbol"
|
4
|
+
require "object_identifier/core_ext/big_decimal"
|
4
5
|
|
5
6
|
module ObjectIdentifier
|
6
7
|
autoload :Identifier, "object_identifier/identifier"
|
@@ -0,0 +1,9 @@
|
|
1
|
+
class BigDecimal
|
2
|
+
# Formats this BigDecimal to look like a float, which is at least readable.
|
3
|
+
# @return [String] a String representation of this BigDecimal object (via float)
|
4
|
+
# @example
|
5
|
+
# BigDecimal.new(1).inspect_lit # => "1.0"
|
6
|
+
def inspect_lit
|
7
|
+
to_s
|
8
|
+
end
|
9
|
+
end
|
@@ -2,10 +2,10 @@ require "test_helper"
|
|
2
2
|
|
3
3
|
describe Object do
|
4
4
|
it "responds to #inspect_lit" do
|
5
|
-
assert
|
5
|
+
assert Object.new.respond_to?(:inspect_lit)
|
6
6
|
end
|
7
7
|
|
8
8
|
it "responds to #identify" do
|
9
|
-
assert
|
9
|
+
assert Object.new.respond_to?(:identify)
|
10
10
|
end
|
11
11
|
end
|
File without changes
|
@@ -3,67 +3,67 @@ require "test_helper"
|
|
3
3
|
describe ObjectIdentifier::Identifier do
|
4
4
|
describe "#identify" do
|
5
5
|
it "yields 'Class[id:1]' when id and no attributes" do
|
6
|
-
assert
|
6
|
+
assert OpenStruct.new(id: 1).identify == "OpenStruct[id:1]"
|
7
7
|
end
|
8
8
|
|
9
9
|
it "lists each entry in collection" do
|
10
10
|
collection = [OpenStruct.new(id: 1), OpenStruct.new(id: 2)]
|
11
|
-
assert
|
11
|
+
assert collection.identify == "OpenStruct[id:1], OpenStruct[id:2]"
|
12
12
|
end
|
13
13
|
|
14
14
|
describe "no attributes, no id, empty array, nil" do
|
15
15
|
it "yields 'Class[]' when no id or attributes" do
|
16
|
-
assert
|
16
|
+
assert Object.new.identify == "Object[]"
|
17
17
|
end
|
18
18
|
|
19
19
|
it "yields '[no objects]' when an empty array" do
|
20
|
-
assert
|
20
|
+
assert [].identify == "[no objects]"
|
21
21
|
end
|
22
22
|
|
23
23
|
it "yields '[no objects]' when nil" do
|
24
|
-
assert
|
24
|
+
assert nil.identify == "[no objects]"
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
28
|
describe "with attributes" do
|
29
29
|
it "yields attribute values" do
|
30
30
|
obj = OpenStruct.new(name: "Pepper", beak_size: 4)
|
31
|
-
assert
|
31
|
+
assert obj.identify(:beak_size) == "OpenStruct[beak_size:4]"
|
32
32
|
end
|
33
33
|
|
34
34
|
it "quotes strings" do
|
35
35
|
obj = OpenStruct.new(name: "Pepper")
|
36
|
-
assert
|
36
|
+
assert obj.identify(:name) == %(OpenStruct[name:"Pepper"])
|
37
37
|
end
|
38
38
|
|
39
39
|
it "quotes symbols" do
|
40
40
|
obj = OpenStruct.new(name: "Pepper", color: :grey)
|
41
|
-
assert
|
41
|
+
assert obj.identify(:color) == %(OpenStruct[color::"grey"])
|
42
42
|
end
|
43
43
|
|
44
44
|
it "ignores attributes that don't exist" do
|
45
45
|
obj = OpenStruct.new(name: "Pepper", color: :grey, beak_size: 4)
|
46
|
-
assert
|
46
|
+
assert obj.identify(:volume, :beak_size) == "OpenStruct[beak_size:4]"
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
50
|
describe "options" do
|
51
51
|
it "overrides object class name with :klass" do
|
52
|
-
assert
|
52
|
+
assert OpenStruct.new(id: 1).identify(klass: "Monkey") == "Monkey[id:1]"
|
53
53
|
end
|
54
54
|
|
55
55
|
it "yields no class if given class is empty string" do
|
56
|
-
assert
|
57
|
-
assert
|
56
|
+
assert OpenStruct.new(id: 1).identify(klass: "") == "[id:1]"
|
57
|
+
assert OpenStruct.new(id: 1).identify(klass: nil) == "[id:1]"
|
58
58
|
end
|
59
59
|
|
60
60
|
it "overrides object class name with :klass with no attributes" do
|
61
|
-
assert
|
61
|
+
assert [].identify(klass: "Monkey") == "Monkey[]"
|
62
62
|
end
|
63
63
|
|
64
64
|
it "yields first n (:limit) objects in collection" do
|
65
|
-
assert
|
66
|
-
"Fixnum[to_i:1], Fixnum[to_i:2], Fixnum[to_i:3], ... (4 more)"
|
65
|
+
assert [1,2,3,4,5,6,7].identify(:to_i, limit: 3) ==
|
66
|
+
"Fixnum[to_i:1], Fixnum[to_i:2], Fixnum[to_i:3], ... (4 more)"
|
67
67
|
end
|
68
68
|
end
|
69
69
|
end
|
data/test/test_helper.rb
CHANGED
@@ -4,11 +4,6 @@ ENV["RAILS_ENV"] = "test"
|
|
4
4
|
require File.expand_path("../dummy/config/environment.rb", __FILE__)
|
5
5
|
require "rails/test_help"
|
6
6
|
require "minitest/rails"
|
7
|
-
require "minitest/ansi"
|
8
|
-
require "wrong/adapters/minitest"
|
9
|
-
|
10
|
-
MiniTest::ANSI.use!
|
11
|
-
Wrong.config.color
|
12
7
|
|
13
8
|
Rails.backtrace_cleaner.remove_silencers!
|
14
9
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: object_identifier
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paul Dobbins
|
@@ -9,90 +9,62 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-08-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- -
|
18
|
+
- - ">="
|
19
19
|
- !ruby/object:Gem::Version
|
20
20
|
version: 3.0.0
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
|
-
- -
|
25
|
+
- - ">="
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: 3.0.0
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: naught
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
|
-
- -
|
32
|
+
- - ">="
|
33
33
|
- !ruby/object:Gem::Version
|
34
34
|
version: '0'
|
35
35
|
type: :runtime
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
|
-
- -
|
39
|
+
- - ">="
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: '0'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: sqlite3
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
|
-
- -
|
46
|
+
- - ">="
|
47
47
|
- !ruby/object:Gem::Version
|
48
48
|
version: '0'
|
49
49
|
type: :development
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
|
-
- -
|
53
|
+
- - ">="
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
version: '0'
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
57
|
name: minitest-rails
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
59
59
|
requirements:
|
60
|
-
- -
|
60
|
+
- - ">="
|
61
61
|
- !ruby/object:Gem::Version
|
62
62
|
version: '0'
|
63
63
|
type: :development
|
64
64
|
prerelease: false
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
66
66
|
requirements:
|
67
|
-
- -
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
version: '0'
|
70
|
-
- !ruby/object:Gem::Dependency
|
71
|
-
name: minitest-ansi
|
72
|
-
requirement: !ruby/object:Gem::Requirement
|
73
|
-
requirements:
|
74
|
-
- - '>='
|
75
|
-
- !ruby/object:Gem::Version
|
76
|
-
version: '0'
|
77
|
-
type: :development
|
78
|
-
prerelease: false
|
79
|
-
version_requirements: !ruby/object:Gem::Requirement
|
80
|
-
requirements:
|
81
|
-
- - '>='
|
82
|
-
- !ruby/object:Gem::Version
|
83
|
-
version: '0'
|
84
|
-
- !ruby/object:Gem::Dependency
|
85
|
-
name: wrong
|
86
|
-
requirement: !ruby/object:Gem::Requirement
|
87
|
-
requirements:
|
88
|
-
- - '>='
|
89
|
-
- !ruby/object:Gem::Version
|
90
|
-
version: '0'
|
91
|
-
type: :development
|
92
|
-
prerelease: false
|
93
|
-
version_requirements: !ruby/object:Gem::Requirement
|
94
|
-
requirements:
|
95
|
-
- - '>='
|
67
|
+
- - ">="
|
96
68
|
- !ruby/object:Gem::Version
|
97
69
|
version: '0'
|
98
70
|
description:
|
@@ -106,11 +78,13 @@ files:
|
|
106
78
|
- README.md
|
107
79
|
- Rakefile
|
108
80
|
- lib/object_identifier.rb
|
81
|
+
- lib/object_identifier/core_ext/big_decimal.rb
|
109
82
|
- lib/object_identifier/core_ext/object.rb
|
110
83
|
- lib/object_identifier/core_ext/string.rb
|
111
84
|
- lib/object_identifier/core_ext/symbol.rb
|
112
85
|
- lib/object_identifier/identifier.rb
|
113
86
|
- lib/object_identifier/version.rb
|
87
|
+
- test/core_ext/big_decimal_test.rb
|
114
88
|
- test/core_ext/object_test.rb
|
115
89
|
- test/core_ext/string_test.rb
|
116
90
|
- test/core_ext/symbol_test.rb
|
@@ -141,6 +115,7 @@ files:
|
|
141
115
|
- test/dummy/config/initializers/wrap_parameters.rb
|
142
116
|
- test/dummy/config/locales/en.yml
|
143
117
|
- test/dummy/config/routes.rb
|
118
|
+
- test/dummy/db/test.sqlite3
|
144
119
|
- test/dummy/log/development.log
|
145
120
|
- test/dummy/log/test.log
|
146
121
|
- test/dummy/public/404.html
|
@@ -159,21 +134,22 @@ require_paths:
|
|
159
134
|
- lib
|
160
135
|
required_ruby_version: !ruby/object:Gem::Requirement
|
161
136
|
requirements:
|
162
|
-
- -
|
137
|
+
- - ">="
|
163
138
|
- !ruby/object:Gem::Version
|
164
139
|
version: '0'
|
165
140
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
166
141
|
requirements:
|
167
|
-
- -
|
142
|
+
- - ">="
|
168
143
|
- !ruby/object:Gem::Version
|
169
144
|
version: '0'
|
170
145
|
requirements: []
|
171
146
|
rubyforge_project:
|
172
|
-
rubygems_version: 2.
|
147
|
+
rubygems_version: 2.3.0
|
173
148
|
signing_key:
|
174
149
|
specification_version: 4
|
175
150
|
summary: Identify an object by inspecting its class name and attributes.
|
176
151
|
test_files:
|
152
|
+
- test/core_ext/big_decimal_test.rb
|
177
153
|
- test/core_ext/object_test.rb
|
178
154
|
- test/core_ext/string_test.rb
|
179
155
|
- test/core_ext/symbol_test.rb
|
@@ -202,6 +178,7 @@ test_files:
|
|
202
178
|
- test/dummy/config/locales/en.yml
|
203
179
|
- test/dummy/config/routes.rb
|
204
180
|
- test/dummy/config.ru
|
181
|
+
- test/dummy/db/test.sqlite3
|
205
182
|
- test/dummy/log/development.log
|
206
183
|
- test/dummy/log/test.log
|
207
184
|
- test/dummy/public/404.html
|
@@ -212,3 +189,4 @@ test_files:
|
|
212
189
|
- test/dummy/README.rdoc
|
213
190
|
- test/object_identifier_test.rb
|
214
191
|
- test/test_helper.rb
|
192
|
+
has_rdoc:
|