acts_as_publishable 0.2.3 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock
CHANGED
@@ -1,41 +1,84 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
acts_as_publishable (0.
|
5
|
-
rails (~>
|
4
|
+
acts_as_publishable (0.3.0)
|
5
|
+
rails (~> 3.0)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: http://rubygems.org/
|
9
9
|
specs:
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
activesupport (=
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
10
|
+
abstract (1.0.0)
|
11
|
+
actionmailer (3.0.3)
|
12
|
+
actionpack (= 3.0.3)
|
13
|
+
mail (~> 2.2.9)
|
14
|
+
actionpack (3.0.3)
|
15
|
+
activemodel (= 3.0.3)
|
16
|
+
activesupport (= 3.0.3)
|
17
|
+
builder (~> 2.1.2)
|
18
|
+
erubis (~> 2.6.6)
|
19
|
+
i18n (~> 0.4)
|
20
|
+
rack (~> 1.2.1)
|
21
|
+
rack-mount (~> 0.6.13)
|
22
|
+
rack-test (~> 0.5.6)
|
23
|
+
tzinfo (~> 0.3.23)
|
24
|
+
activemodel (3.0.3)
|
25
|
+
activesupport (= 3.0.3)
|
26
|
+
builder (~> 2.1.2)
|
27
|
+
i18n (~> 0.4)
|
28
|
+
activerecord (3.0.3)
|
29
|
+
activemodel (= 3.0.3)
|
30
|
+
activesupport (= 3.0.3)
|
31
|
+
arel (~> 2.0.2)
|
32
|
+
tzinfo (~> 0.3.23)
|
33
|
+
activeresource (3.0.3)
|
34
|
+
activemodel (= 3.0.3)
|
35
|
+
activesupport (= 3.0.3)
|
36
|
+
activesupport (3.0.3)
|
37
|
+
arel (2.0.7)
|
38
|
+
builder (2.1.2)
|
39
|
+
erubis (2.6.6)
|
40
|
+
abstract (>= 1.0.0)
|
41
|
+
i18n (0.5.0)
|
42
|
+
mail (2.2.14)
|
43
|
+
activesupport (>= 2.3.6)
|
44
|
+
i18n (>= 0.4.0)
|
45
|
+
mime-types (~> 1.16)
|
46
|
+
treetop (~> 1.4.8)
|
47
|
+
mime-types (1.16)
|
48
|
+
polyglot (0.3.1)
|
49
|
+
rack (1.2.1)
|
50
|
+
rack-mount (0.6.13)
|
51
|
+
rack (>= 1.0.0)
|
52
|
+
rack-test (0.5.7)
|
53
|
+
rack (>= 1.0)
|
54
|
+
rails (3.0.3)
|
55
|
+
actionmailer (= 3.0.3)
|
56
|
+
actionpack (= 3.0.3)
|
57
|
+
activerecord (= 3.0.3)
|
58
|
+
activeresource (= 3.0.3)
|
59
|
+
activesupport (= 3.0.3)
|
60
|
+
bundler (~> 1.0)
|
61
|
+
railties (= 3.0.3)
|
62
|
+
railties (3.0.3)
|
63
|
+
actionpack (= 3.0.3)
|
64
|
+
activesupport (= 3.0.3)
|
65
|
+
rake (>= 0.8.7)
|
66
|
+
thor (~> 0.14.4)
|
28
67
|
rake (0.8.7)
|
29
68
|
rspec (1.3.1)
|
30
69
|
sqlite3 (1.3.3)
|
31
70
|
sqlite3-ruby (1.3.3)
|
32
71
|
sqlite3 (>= 1.3.3)
|
72
|
+
thor (0.14.6)
|
73
|
+
treetop (1.4.9)
|
74
|
+
polyglot (>= 0.3.1)
|
75
|
+
tzinfo (0.3.24)
|
33
76
|
|
34
77
|
PLATFORMS
|
35
78
|
ruby
|
36
79
|
|
37
80
|
DEPENDENCIES
|
38
81
|
acts_as_publishable!
|
39
|
-
rails (~>
|
82
|
+
rails (~> 3.0)
|
40
83
|
rspec (= 1.3.1)
|
41
84
|
sqlite3-ruby
|
data/acts_as_publishable.gemspec
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
module ActsAsPublishable
|
2
|
-
|
3
|
-
|
4
|
-
end
|
5
|
-
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
|
6
4
|
module ClassMethods
|
7
5
|
def acts_as_publishable(options = {})
|
8
6
|
metaclass = (class << self; self; end)
|
@@ -16,7 +14,7 @@ module ActsAsPublishable
|
|
16
14
|
self.published_to_column = options[:published_to_column] || 'published_to'
|
17
15
|
self.default_published_now = (options[:default_published_now] == true)
|
18
16
|
|
19
|
-
|
17
|
+
scope :published, where(["#{publish_now_column} = :published OR (#{published_from_column} <= :published_from AND #{published_to_column} >= :published_to)", {:published => true, :published_from => Time.now, :published_to => Time.now}])
|
20
18
|
|
21
19
|
before_save { |publishable| publishable[publish_now_column.to_sym] = default_published_now if publishable[publish_now_column.to_sym].nil?; true }
|
22
20
|
|
@@ -28,7 +26,7 @@ module ActsAsPublishable
|
|
28
26
|
def validate_chronology
|
29
27
|
validates_each published_to_column do |publishable, attribute, value|
|
30
28
|
unless value.blank? || publishable[published_from_column.to_sym].blank?
|
31
|
-
publishable.errors.add(attribute, :earlier_than_published_from, :
|
29
|
+
publishable.errors.add(attribute, :earlier_than_published_from, :message => "cannot be set earlier than #{published_from_column.to_s.humanize}") unless publishable[published_from_column.to_sym] < value
|
32
30
|
end
|
33
31
|
end
|
34
32
|
end
|
@@ -36,7 +34,7 @@ module ActsAsPublishable
|
|
36
34
|
|
37
35
|
module InstanceMethods
|
38
36
|
def published?
|
39
|
-
now = Time.now
|
37
|
+
now = Time.now
|
40
38
|
@from ||= self[self.class.published_from_column.to_sym]
|
41
39
|
@to ||= self[self.class.published_to_column.to_sym]
|
42
40
|
is_published_now = self[self.class.publish_now_column.to_sym]
|
@@ -75,7 +75,7 @@ describe "Publishable with default columns" do
|
|
75
75
|
a_day_ago = Time.parse 'Fri Jun 18 17:03:03 +0200 2010'
|
76
76
|
@post.published_from = a_day_ago
|
77
77
|
@post.published_to = tomorrow
|
78
|
-
@post.
|
78
|
+
@post.save(:validate => false)
|
79
79
|
Post.find(@post.id).published_from.should eql(a_day_ago)
|
80
80
|
Post.find(@post.id).published_to.should eql(tomorrow)
|
81
81
|
end
|
metadata
CHANGED
@@ -1,8 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acts_as_publishable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
4
|
+
hash: 19
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 3
|
9
|
+
- 0
|
10
|
+
version: 0.3.0
|
6
11
|
platform: ruby
|
7
12
|
authors:
|
8
13
|
- Rasmus Bang Grouleff
|
@@ -10,7 +15,7 @@ autorequire:
|
|
10
15
|
bindir: bin
|
11
16
|
cert_chain: []
|
12
17
|
|
13
|
-
date: 2011-
|
18
|
+
date: 2011-01-21 00:00:00 +01:00
|
14
19
|
default_executable:
|
15
20
|
dependencies:
|
16
21
|
- !ruby/object:Gem::Dependency
|
@@ -21,6 +26,11 @@ dependencies:
|
|
21
26
|
requirements:
|
22
27
|
- - "="
|
23
28
|
- !ruby/object:Gem::Version
|
29
|
+
hash: 25
|
30
|
+
segments:
|
31
|
+
- 1
|
32
|
+
- 3
|
33
|
+
- 1
|
24
34
|
version: 1.3.1
|
25
35
|
type: :development
|
26
36
|
version_requirements: *id001
|
@@ -32,6 +42,9 @@ dependencies:
|
|
32
42
|
requirements:
|
33
43
|
- - ">="
|
34
44
|
- !ruby/object:Gem::Version
|
45
|
+
hash: 3
|
46
|
+
segments:
|
47
|
+
- 0
|
35
48
|
version: "0"
|
36
49
|
type: :development
|
37
50
|
version_requirements: *id002
|
@@ -43,7 +56,11 @@ dependencies:
|
|
43
56
|
requirements:
|
44
57
|
- - ~>
|
45
58
|
- !ruby/object:Gem::Version
|
46
|
-
|
59
|
+
hash: 7
|
60
|
+
segments:
|
61
|
+
- 3
|
62
|
+
- 0
|
63
|
+
version: "3.0"
|
47
64
|
type: :runtime
|
48
65
|
version_requirements: *id003
|
49
66
|
description: Rails gem that adds functionality to make Active Record models publishable
|
@@ -83,17 +100,23 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
83
100
|
requirements:
|
84
101
|
- - ">="
|
85
102
|
- !ruby/object:Gem::Version
|
103
|
+
hash: 3
|
104
|
+
segments:
|
105
|
+
- 0
|
86
106
|
version: "0"
|
87
107
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
108
|
none: false
|
89
109
|
requirements:
|
90
110
|
- - ">="
|
91
111
|
- !ruby/object:Gem::Version
|
112
|
+
hash: 3
|
113
|
+
segments:
|
114
|
+
- 0
|
92
115
|
version: "0"
|
93
116
|
requirements: []
|
94
117
|
|
95
118
|
rubyforge_project: acts_as_publishable
|
96
|
-
rubygems_version: 1.
|
119
|
+
rubygems_version: 1.3.7
|
97
120
|
signing_key:
|
98
121
|
specification_version: 3
|
99
122
|
summary: Rails gem that adds functionality to make Active Record models publishable
|