acts_as_publishable 0.2.3 → 0.3.0

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.
data/Gemfile.lock CHANGED
@@ -1,41 +1,84 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- acts_as_publishable (0.2.1)
5
- rails (~> 2.3)
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
- actionmailer (2.3.10)
11
- actionpack (= 2.3.10)
12
- actionpack (2.3.10)
13
- activesupport (= 2.3.10)
14
- rack (~> 1.1.0)
15
- activerecord (2.3.10)
16
- activesupport (= 2.3.10)
17
- activeresource (2.3.10)
18
- activesupport (= 2.3.10)
19
- activesupport (2.3.10)
20
- rack (1.1.0)
21
- rails (2.3.10)
22
- actionmailer (= 2.3.10)
23
- actionpack (= 2.3.10)
24
- activerecord (= 2.3.10)
25
- activeresource (= 2.3.10)
26
- activesupport (= 2.3.10)
27
- rake (>= 0.8.3)
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 (~> 2.3)
82
+ rails (~> 3.0)
40
83
  rspec (= 1.3.1)
41
84
  sqlite3-ruby
@@ -21,5 +21,5 @@ Gem::Specification.new do |s|
21
21
 
22
22
  s.add_development_dependency 'rspec', '= 1.3.1'
23
23
  s.add_development_dependency 'sqlite3-ruby'
24
- s.add_dependency 'rails', '~> 2.3'
24
+ s.add_dependency 'rails', '~> 3.0'
25
25
  end
@@ -1,8 +1,6 @@
1
1
  module ActsAsPublishable
2
- def self.included(base)
3
- base.extend ActsAsPublishable::ClassMethods
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
- named_scope :published, :conditions => ["#{publish_now_column} = :published OR (#{published_from_column} <= :published_from AND #{published_to_column} >= :published_to)", {:published => true, :published_from => Time.now.utc, :published_to => Time.now.utc}]
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, :default => "cannot be set earlier than #{published_from_column.to_s.humanize}") unless publishable[published_from_column.to_sym] < value
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.utc
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]
@@ -1,4 +1,4 @@
1
1
  module ActsAsPublishable
2
- VERSION = "0.2.3"
2
+ VERSION = "0.3.0"
3
3
  end
4
4
 
@@ -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.save_without_validation
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
- prerelease:
5
- version: 0.2.3
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-03-28 00:00:00 +02:00
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
- version: "2.3"
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.5.0
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