object_identifier 0.0.3 → 0.0.4

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
  SHA1:
3
- metadata.gz: 97409c6d7248a1cdd659e5c051c1d08220afd511
4
- data.tar.gz: 78be1a73639f24bba4058b5cc0bb7f0c42ba9c6e
3
+ metadata.gz: 145c33d70d8d3e4122c427a6c2a5ae956cfe7ed0
4
+ data.tar.gz: c550160bd82b0417256face662342f33c567a1a6
5
5
  SHA512:
6
- metadata.gz: 4d2d47ac701ca0caad18b11dc7b9ce00751aaf9f7caa48cbd569c0b6d75e4b80a60f22194da66609c22ec0118a0b3563089b057877fb8f1a5141a0f9bb696861
7
- data.tar.gz: 9c66bbf4112053b1994692e4b10fa4a6549ea4917008443aafc0b04cd585dee2532660fc30d0c646051b9711ee89a7ebde136e451700a42fb978c73c8f3bf93f
6
+ metadata.gz: 28deb5124d478be4452168bc59cb371704d60481a8adae647e6edf9672c52272058a5c48bf63e9b2ba3a28e710cdbf75bf92f4c2400104478277ea13b0e4e8d3
7
+ data.tar.gz: 5772ec327a63e2f0a528398c73c7738a66af8d436b1a48b5189d0bfd85c7d3d53e841d69bcd75a76efac04f70933a92bda312e835a79b2393e6e2d8421c12357
data/README.md CHANGED
@@ -16,7 +16,10 @@ now just use `"#{some_object.identify(:id, :name)}"`.
16
16
 
17
17
  Tested with:
18
18
 
19
+ * Ruby: MRI 1.9.3
19
20
  * Ruby: MRI 2.0.0
21
+ * Ruby: MRI 2.1.0
22
+ * Rails: 3.2
20
23
  * Rails: 4.0.1
21
24
 
22
25
  ## Installation
@@ -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
@@ -1,3 +1,3 @@
1
1
  module ObjectIdentifier
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -0,0 +1,12 @@
1
+ require "test_helper"
2
+
3
+ describe BigDecimal do
4
+ describe "#inspect_lit" do
5
+ it "returns the same as #to_s" do
6
+ [1, 1.0, 0, 99.9999].each do |val|
7
+ bd_val = BigDecimal.new(val, 10)
8
+ assert bd_val.inspect_lit == bd_val.to_s
9
+ end
10
+ end
11
+ end
12
+ 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 { Object.new.respond_to?(:inspect_lit) }
5
+ assert Object.new.respond_to?(:inspect_lit)
6
6
  end
7
7
 
8
8
  it "responds to #identify" do
9
- assert { Object.new.respond_to?(:identify) }
9
+ assert Object.new.respond_to?(:identify)
10
10
  end
11
11
  end
@@ -3,7 +3,7 @@ require "test_helper"
3
3
  describe String do
4
4
  describe "#inspect_lit" do
5
5
  it "quotes string values" do
6
- assert { "string".inspect_lit == %("string") }
6
+ assert "string".inspect_lit == %("string")
7
7
  end
8
8
  end
9
9
  end
@@ -3,7 +3,7 @@ require "test_helper"
3
3
  describe Symbol do
4
4
  describe "#inspect_lit" do
5
5
  it "quotes symbol values after colon" do
6
- assert { :symbol.inspect_lit == %(:"symbol") }
6
+ assert :symbol.inspect_lit == %(:"symbol")
7
7
  end
8
8
  end
9
9
  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 { OpenStruct.new(id: 1).identify == "OpenStruct[id:1]" }
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 { collection.identify == "OpenStruct[id:1], OpenStruct[id:2]" }
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 { Object.new.identify == "Object[]" }
16
+ assert Object.new.identify == "Object[]"
17
17
  end
18
18
 
19
19
  it "yields '[no objects]' when an empty array" do
20
- assert { [].identify == "[no objects]" }
20
+ assert [].identify == "[no objects]"
21
21
  end
22
22
 
23
23
  it "yields '[no objects]' when nil" do
24
- assert { nil.identify == "[no objects]" }
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 { obj.identify(:beak_size) == "OpenStruct[beak_size:4]" }
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 { obj.identify(:name) == %(OpenStruct[name:"Pepper"]) }
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 { obj.identify(:color) == %(OpenStruct[color::"grey"]) }
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 { obj.identify(:volume, :beak_size) == "OpenStruct[beak_size:4]" }
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 { OpenStruct.new(id: 1).identify(klass: "Monkey") == "Monkey[id:1]" }
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 { OpenStruct.new(id: 1).identify(klass: "") == "[id:1]" }
57
- assert { OpenStruct.new(id: 1).identify(klass: nil) == "[id:1]" }
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 { [].identify(klass: "Monkey") == "Monkey[]" }
61
+ assert [].identify(klass: "Monkey") == "Monkey[]"
62
62
  end
63
63
 
64
64
  it "yields first n (:limit) objects in collection" do
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)" }
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.3
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-01-28 00:00:00.000000000 Z
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.2.0
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: