archiveable 0.0.5 → 0.0.6
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 +4 -4
- data/lib/archiveable.rb +8 -2
- data/lib/archiveable/version.rb +1 -1
- data/test/lib/archiveable_test.rb +6 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 52166347bb6fe0010aea22de41ac4008081b02cc
|
4
|
+
data.tar.gz: 75afbce382e8bc1246538d4667c89920e41f6a8b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7929258b7904456ddb720aafdfa7fbf8f11f28584220757f8c3656458a4efb4dc5b7f3fa91fbf5d0384a87cf9a4e1f46ea00f9cc693ff3b21ab15043c0d02261
|
7
|
+
data.tar.gz: 88d044bcadaa22acb25ef5773ca8ab8ecaf086cae586eac03703d5d3a4284120ead4f59a6e53c073086ef2f7bdddd28d9575a559252cb5c972072c95c147aad6
|
data/lib/archiveable.rb
CHANGED
@@ -15,7 +15,7 @@ module Archiveable
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def published=(value)
|
18
|
-
self.archived = !value
|
18
|
+
self.archived = !bool(value)
|
19
19
|
end
|
20
20
|
|
21
21
|
def archived
|
@@ -23,7 +23,7 @@ module Archiveable
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def archived=(value)
|
26
|
-
self.archived_at = value ? Time.now : nil
|
26
|
+
self.archived_at = bool(value) ? Time.now : nil
|
27
27
|
end
|
28
28
|
|
29
29
|
def archive
|
@@ -41,4 +41,10 @@ module Archiveable
|
|
41
41
|
def publish!
|
42
42
|
update! archived: false
|
43
43
|
end
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
def bool(value)
|
48
|
+
not ["false", "0", ""].include? value.to_s.downcase
|
49
|
+
end
|
44
50
|
end
|
data/lib/archiveable/version.rb
CHANGED
@@ -46,6 +46,12 @@ describe Archiveable do
|
|
46
46
|
subject.archived = false
|
47
47
|
subject.archived_at.must_equal nil
|
48
48
|
end
|
49
|
+
|
50
|
+
it "unsets the archived_at when archived is set to 0" do
|
51
|
+
subject.archived_at = Time.now
|
52
|
+
subject.archived = 0
|
53
|
+
subject.archived_at.must_equal nil
|
54
|
+
end
|
49
55
|
end
|
50
56
|
|
51
57
|
describe ".published" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: archiveable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- JBailes
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-03-
|
12
|
+
date: 2014-03-31 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|