gotime-cassandra_object 2.10.10 → 2.10.11
Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,25 @@
|
|
1
|
+
module CassandraObject
|
2
|
+
module Inspect
|
3
|
+
def inspect
|
4
|
+
inspection = ["#{self.class.primary_key}: #{id.inspect}"]
|
5
|
+
|
6
|
+
@attributes.keys.each do |attribute|
|
7
|
+
inspection << "#{attribute}: #{attribute_for_inspect(attribute)}"
|
8
|
+
end
|
9
|
+
|
10
|
+
"#<#{self.class} #{inspection * ', '}>"
|
11
|
+
end
|
12
|
+
|
13
|
+
def attribute_for_inspect(attr_name)
|
14
|
+
value = read_attribute(attr_name)
|
15
|
+
|
16
|
+
if value.is_a?(String) && value.length > 50
|
17
|
+
"#{value[0..50]}...".inspect
|
18
|
+
elsif value.is_a?(Date) || value.is_a?(Time)
|
19
|
+
%("#{value.to_s(:db)}")
|
20
|
+
else
|
21
|
+
value.inspect
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class CassandraObject::InspectTest < CassandraObject::TestCase
|
4
|
+
test 'attribute_for_inspect' do
|
5
|
+
object = temp_object do
|
6
|
+
string :long_string
|
7
|
+
time :the_time
|
8
|
+
integer :other
|
9
|
+
end
|
10
|
+
|
11
|
+
assert_equal "#{'x' * 51}...".inspect, object.new(long_string: 'x' * 100).attribute_for_inspect(:long_string)
|
12
|
+
assert_equal "2012-02-14 12:01:02".inspect, object.new(the_time: Time.new(2012, 02, 14, 12, 01, 02)).attribute_for_inspect(:the_time)
|
13
|
+
assert_equal "5", object.new(other: 5).attribute_for_inspect(:other)
|
14
|
+
end
|
15
|
+
|
16
|
+
test 'inspect' do
|
17
|
+
object = temp_object do
|
18
|
+
string :description
|
19
|
+
integer :price
|
20
|
+
end.new(description: "yeah buddy", price: 42)
|
21
|
+
|
22
|
+
assert_match /id/, object.inspect
|
23
|
+
assert_match /description/, object.inspect
|
24
|
+
end
|
25
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gotime-cassandra_object
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.10.
|
4
|
+
version: 2.10.11
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,11 +10,11 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-02-
|
13
|
+
date: 2012-02-16 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activemodel
|
17
|
-
requirement: &
|
17
|
+
requirement: &70104281371060 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
@@ -22,10 +22,10 @@ dependencies:
|
|
22
22
|
version: '3.0'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *70104281371060
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: cassandra
|
28
|
-
requirement: &
|
28
|
+
requirement: &70104281368940 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
31
|
- - ! '>='
|
@@ -33,10 +33,10 @@ dependencies:
|
|
33
33
|
version: 0.12.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
|
-
version_requirements: *
|
36
|
+
version_requirements: *70104281368940
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
name: bundler
|
39
|
-
requirement: &
|
39
|
+
requirement: &70104281386900 !ruby/object:Gem::Requirement
|
40
40
|
none: false
|
41
41
|
requirements:
|
42
42
|
- - ! '>='
|
@@ -44,7 +44,7 @@ dependencies:
|
|
44
44
|
version: '0'
|
45
45
|
type: :development
|
46
46
|
prerelease: false
|
47
|
-
version_requirements: *
|
47
|
+
version_requirements: *70104281386900
|
48
48
|
description: Cassandra ActiveModel
|
49
49
|
email: gems@gotime.com
|
50
50
|
executables: []
|
@@ -81,6 +81,7 @@ files:
|
|
81
81
|
- lib/cassandra_object/identity/hashed_natural_key_factory.rb
|
82
82
|
- lib/cassandra_object/identity/natural_key_factory.rb
|
83
83
|
- lib/cassandra_object/identity/uuid_key_factory.rb
|
84
|
+
- lib/cassandra_object/inspect.rb
|
84
85
|
- lib/cassandra_object/log_subscriber.rb
|
85
86
|
- lib/cassandra_object/migrations.rb
|
86
87
|
- lib/cassandra_object/migrations/migration.rb
|
@@ -128,6 +129,7 @@ files:
|
|
128
129
|
- test/unit/finder_methods_test.rb
|
129
130
|
- test/unit/identity/uuid_key_factory_test.rb
|
130
131
|
- test/unit/identity_test.rb
|
132
|
+
- test/unit/inspect_test.rb
|
131
133
|
- test/unit/persistence_test.rb
|
132
134
|
- test/unit/timestamps_test.rb
|
133
135
|
- test/unit/types/array_type_test.rb
|