couchpillow 0.4.10 → 0.4.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/couchpillow/directives/attribute.rb +2 -2
- data/lib/couchpillow/document.rb +6 -6
- data/lib/couchpillow/iso8601.rb +11 -0
- data/lib/couchpillow/version.rb +1 -1
- data/lib/couchpillow.rb +1 -0
- data/test/test_document.rb +8 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 696cfe25404a7a89de88ae8863e6388f3e20d48c
|
4
|
+
data.tar.gz: c0954f6feeb54438dc14ec6992aede890f83a54a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9e977460fa8a14e8af98bea41502312c3b9630780f796747bb105c4cc08e80ce4fd5fedd73c2380b35661af4e6daefaea3bebf2bdb680184ddbadf8d097987c8
|
7
|
+
data.tar.gz: 18ed07990ae09053e7930c47d754fc7cea8adb44fcacb657a1f11c7d24b434beccb475aeef64bb9873edd90a53e27ffcafac104afbc6ad8dfa61c763ca75bc44
|
@@ -162,8 +162,8 @@ module CouchPillow
|
|
162
162
|
value = String(value)
|
163
163
|
elsif @type == Array
|
164
164
|
value = Array(value)
|
165
|
-
elsif @type == Time && !value.is_a?(Time)
|
166
|
-
value =
|
165
|
+
elsif (@type == Time || @type == Iso8601Time) && !value.is_a?(Time)
|
166
|
+
value = @type.parse(value)
|
167
167
|
elsif @type == CouchPillow::Boolean
|
168
168
|
value = value == 0 || value.to_s.downcase == "false" || !value ? false : true
|
169
169
|
end
|
data/lib/couchpillow/document.rb
CHANGED
@@ -23,16 +23,16 @@ module CouchPillow
|
|
23
23
|
|
24
24
|
attribute :_created_at do
|
25
25
|
required
|
26
|
-
type
|
26
|
+
type CouchPillow::Iso8601Time
|
27
27
|
auto_convert
|
28
|
-
default {
|
28
|
+
default { CouchPillow::Iso8601Time.now.utc }
|
29
29
|
end
|
30
30
|
|
31
31
|
attribute :_updated_at do
|
32
32
|
required
|
33
|
-
type
|
33
|
+
type CouchPillow::Iso8601Time
|
34
34
|
auto_convert
|
35
|
-
default {
|
35
|
+
default { CouchPillow::Iso8601Time.now.utc }
|
36
36
|
end
|
37
37
|
|
38
38
|
|
@@ -50,7 +50,7 @@ module CouchPillow
|
|
50
50
|
|
51
51
|
@id = self.class._is_type_prefixed? ? self.class._sanitize_id(id) : id
|
52
52
|
|
53
|
-
time =
|
53
|
+
time = CouchPillow::Iso8601Time.now.utc
|
54
54
|
@data[:_created_at] ||= time
|
55
55
|
@data[:_updated_at] ||= time
|
56
56
|
|
@@ -311,7 +311,7 @@ module CouchPillow
|
|
311
311
|
# Timestamp this document
|
312
312
|
#
|
313
313
|
def _timestamp!
|
314
|
-
@data[:_updated_at] =
|
314
|
+
@data[:_updated_at] = CouchPillow::Iso8601Time.now.utc
|
315
315
|
end
|
316
316
|
|
317
317
|
|
data/lib/couchpillow/version.rb
CHANGED
data/lib/couchpillow.rb
CHANGED
data/test/test_document.rb
CHANGED
@@ -38,6 +38,14 @@ class TestDocument < Minitest::Test
|
|
38
38
|
end
|
39
39
|
|
40
40
|
|
41
|
+
def test_iso8601
|
42
|
+
d = Document.new({"_created_at" => "2008-06-21 13:30:00 UTC"}, "1")
|
43
|
+
d.save!
|
44
|
+
json = JSON.parse(d.to_json)
|
45
|
+
assert_equal "2008-06-21T13:30:00Z", json['_created_at']
|
46
|
+
end
|
47
|
+
|
48
|
+
|
41
49
|
def test_default_type
|
42
50
|
d = Document.new({}, "1")
|
43
51
|
assert_equal "couchpillow", d.doc_type
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: couchpillow
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Albert Tedja
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-11-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: couchbase
|
@@ -89,6 +89,7 @@ files:
|
|
89
89
|
- lib/couchpillow/document.rb
|
90
90
|
- lib/couchpillow/errors.rb
|
91
91
|
- lib/couchpillow/helper.rb
|
92
|
+
- lib/couchpillow/iso8601.rb
|
92
93
|
- lib/couchpillow/version.rb
|
93
94
|
- test/helper.rb
|
94
95
|
- test/test_attribute.rb
|