unread 0.3.0 → 0.3.1
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/.travis.yml +4 -9
- data/README.md +1 -1
- data/changelog.md +29 -12
- data/ci/{Gemfile.rails-3.0.x → Gemfile-rails-3-0} +0 -0
- data/ci/{Gemfile.rails-3.1.x → Gemfile-rails-3-1} +0 -0
- data/ci/{Gemfile.rails-3.2.x → Gemfile-rails-3-2} +0 -0
- data/ci/{Gemfile.rails-4.0.x → Gemfile-rails-4-0} +1 -1
- data/lib/unread/read_mark.rb +1 -1
- data/lib/unread/readable.rb +2 -2
- data/lib/unread/reader.rb +3 -1
- data/lib/unread/scopes.rb +2 -2
- data/lib/unread/version.rb +1 -1
- data/test/schema.rb +2 -2
- data/test/test_helper.rb +3 -0
- data/test/unread_test.rb +1 -1
- metadata +19 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 22da2f765c42c94461c4bf67560a057ed1f76d8f
|
4
|
+
data.tar.gz: 3d45b07e1d0fc2a3af20b81a8a8fa0b1ff2bf9de
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c51a5ad38b6a49467f3f3d542e06177c9ea3226cadd1001b66f407bea2f1edf65d7f45bad871184697b526938e62a08905e1e44cb154288eb37a886396d5f53a
|
7
|
+
data.tar.gz: 53b3e25c4723f78121aa3a1f066a68c91b462cbc3a56f5489ac416ba58cb7bb4ea917bc3c174c4b25a852dee4228c10e90c7c054da2f16ceb73b1e5044e79b1b
|
data/.travis.yml
CHANGED
@@ -1,14 +1,9 @@
|
|
1
1
|
language: ruby
|
2
2
|
rvm:
|
3
|
-
- 1.8.7
|
4
3
|
- 1.9.3
|
5
4
|
- 2.0.0
|
6
5
|
gemfile:
|
7
|
-
- ci/Gemfile
|
8
|
-
- ci/Gemfile
|
9
|
-
- ci/Gemfile
|
10
|
-
- ci/Gemfile
|
11
|
-
matrix:
|
12
|
-
exclude:
|
13
|
-
- rvm: 1.8.7
|
14
|
-
gemfile: ci/Gemfile.rails-4.0.x
|
6
|
+
- ci/Gemfile-rails-3-0
|
7
|
+
- ci/Gemfile-rails-3-1
|
8
|
+
- ci/Gemfile-rails-3-2
|
9
|
+
- ci/Gemfile-rails-4-0
|
data/README.md
CHANGED
@@ -18,7 +18,7 @@ Ruby gem to manage read/unread status of ActiveRecord objects - and it's fast.
|
|
18
18
|
|
19
19
|
## Requirements
|
20
20
|
|
21
|
-
* Ruby 1.
|
21
|
+
* Ruby 1.9.3 or 2.0.0
|
22
22
|
* Rails 3 (including 3.0, 3.1, 3.2) and Rails 4. For use with Rails 2.3 there is a branch named "rails2"
|
23
23
|
* Needs a timestamp field in your models (like created_at or updated_at) with a database index on it
|
24
24
|
|
data/changelog.md
CHANGED
@@ -1,58 +1,75 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
-
## 0.3.
|
3
|
+
## 0.3.1 - 2013-12-04
|
4
|
+
|
5
|
+
* Use Time.current instead of Time.now to avoid time zone trouble. Issue #18 (thanks to @henrythe9th)
|
6
|
+
* Handle primary keys other than "id". Issue #29 (thanks to @bcavileer)
|
7
|
+
|
8
|
+
|
9
|
+
## 0.3.0 - 2013-03-17
|
4
10
|
|
5
11
|
* Support for Rails 4 (beta1)
|
6
12
|
|
7
|
-
|
13
|
+
|
14
|
+
## 0.2.0 - 2013-02-18
|
8
15
|
|
9
16
|
* Support for Rails 2 dropped
|
10
17
|
* Refactoring
|
11
18
|
* Added migration generator
|
12
19
|
|
13
|
-
|
20
|
+
|
21
|
+
## 0.1.2 - 2013-01-27
|
14
22
|
|
15
23
|
* Scopes: Improved parameter check
|
16
24
|
|
17
|
-
|
25
|
+
|
26
|
+
## 0.1.1 - 2012-05-01
|
18
27
|
|
19
28
|
* Fixed handling namespaced classes. Closes #10 (thanks to @stanislaw)
|
20
29
|
|
21
|
-
|
30
|
+
|
31
|
+
## 0.1.0 - 2012-04-21
|
22
32
|
|
23
33
|
* Added scope "with_read_marks_for"
|
24
34
|
* Fixed #7: Added attr_accessible to all ReadMark attributes (thanks to @negative)
|
25
35
|
|
26
|
-
|
36
|
+
|
37
|
+
## 0.0.7 - 2012-02-29
|
27
38
|
|
28
39
|
* Cleanup files
|
29
40
|
* acts_as_reader: Using inverse_of (available since Rails 2.3.6)
|
30
41
|
|
31
|
-
|
42
|
+
|
43
|
+
## 0.0.6 - 2011-11-11
|
32
44
|
|
33
45
|
* Fixed #5: Gemspec dependency fix (thanks to @bricker88)
|
34
46
|
* Fixed #6: Removed hard coded dependency on a class named "User" (thanks to @mixandgo)
|
35
47
|
* Some cleanup
|
36
48
|
|
37
|
-
|
49
|
+
|
50
|
+
## 0.0.5 - 2011-09-09
|
38
51
|
|
39
52
|
* Fixed class loading issue in development environment
|
40
53
|
|
41
|
-
|
54
|
+
|
55
|
+
## 0.0.4 - 2011-08-31
|
42
56
|
|
43
57
|
* Ignore multiple calls of acts_as_*
|
44
58
|
* Improved error messages
|
45
59
|
* Tested with Rails 3.1
|
46
60
|
|
47
|
-
|
61
|
+
|
62
|
+
## 0.0.3 - 2011-08-01
|
48
63
|
|
49
64
|
* Fixed gemspec by adding development dependencies
|
50
65
|
* Testing with Travis CI
|
51
66
|
|
52
|
-
|
67
|
+
|
68
|
+
## 0.0.2 - 2011-06-23
|
53
69
|
|
54
70
|
* Fixed scoping for ActiveRecord 2.x
|
55
71
|
|
56
|
-
|
72
|
+
|
73
|
+
## 0.0.1 - 2011-06-23
|
57
74
|
|
58
75
|
* Released as Gem
|
File without changes
|
File without changes
|
File without changes
|
data/lib/unread/read_mark.rb
CHANGED
@@ -8,7 +8,7 @@ class ReadMark < ActiveRecord::Base
|
|
8
8
|
|
9
9
|
scope :global, lambda { where(:readable_id => nil) }
|
10
10
|
scope :single, lambda { where('readable_id IS NOT NULL') }
|
11
|
-
scope :older_than, lambda { |timestamp| where([ 'timestamp < ?', timestamp]) }
|
11
|
+
scope :older_than, lambda { |timestamp| where([ 'timestamp < ?', timestamp ]) }
|
12
12
|
|
13
13
|
# Returns the class defined by acts_as_reader
|
14
14
|
def self.reader_class
|
data/lib/unread/readable.rb
CHANGED
@@ -71,7 +71,7 @@ module Unread
|
|
71
71
|
ReadMark.delete_all :readable_type => self.base_class.name
|
72
72
|
ReadMark.connection.execute <<-EOT
|
73
73
|
INSERT INTO read_marks (user_id, readable_type, timestamp)
|
74
|
-
SELECT
|
74
|
+
SELECT #{ReadMark.reader_class.primary_key}, '#{self.base_class.name}', '#{Time.current.to_s(:db)}'
|
75
75
|
FROM #{ReadMark.reader_class.table_name}
|
76
76
|
EOT
|
77
77
|
end
|
@@ -82,7 +82,7 @@ module Unread
|
|
82
82
|
|
83
83
|
ReadMark.transaction do
|
84
84
|
ReadMark.delete_all :readable_type => self.base_class.name, :user_id => user.id
|
85
|
-
ReadMark.create! :readable_type => self.base_class.name, :user_id => user.id, :timestamp => Time.
|
85
|
+
ReadMark.create! :readable_type => self.base_class.name, :user_id => user.id, :timestamp => Time.current
|
86
86
|
end
|
87
87
|
end
|
88
88
|
|
data/lib/unread/reader.rb
CHANGED
@@ -3,7 +3,9 @@ module Unread
|
|
3
3
|
module InstanceMethods
|
4
4
|
def read_mark_global(klass)
|
5
5
|
instance_var_name = "@read_mark_global_#{klass.name.gsub('::','_')}"
|
6
|
-
|
6
|
+
if instance_variables.include?(instance_var_name.to_sym)
|
7
|
+
instance_variable_get(instance_var_name)
|
8
|
+
else # memoize
|
7
9
|
obj = self.read_marks.where(:readable_type => klass.base_class.name).global.first
|
8
10
|
instance_variable_set(instance_var_name, obj)
|
9
11
|
end
|
data/lib/unread/scopes.rb
CHANGED
@@ -5,7 +5,7 @@ module Unread
|
|
5
5
|
assert_reader(user)
|
6
6
|
|
7
7
|
joins "LEFT JOIN read_marks ON read_marks.readable_type = '#{base_class.name}'
|
8
|
-
AND read_marks.readable_id = #{table_name}
|
8
|
+
AND read_marks.readable_id = #{table_name}.#{primary_key}
|
9
9
|
AND read_marks.user_id = #{user.id}
|
10
10
|
AND read_marks.timestamp >= #{table_name}.#{readable_options[:on]}"
|
11
11
|
end
|
@@ -26,4 +26,4 @@ module Unread
|
|
26
26
|
end
|
27
27
|
end
|
28
28
|
end
|
29
|
-
end
|
29
|
+
end
|
data/lib/unread/version.rb
CHANGED
data/test/schema.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
ActiveRecord::Schema.define(:version => 0) do
|
2
|
-
create_table :readers, :force => true do |t|
|
2
|
+
create_table :readers, :primary_key => 'number', :force => true do |t|
|
3
3
|
t.string :name
|
4
4
|
end
|
5
5
|
|
6
|
-
create_table :emails, :force => true do |t|
|
6
|
+
create_table :emails, :primary_key => 'messageid', :force => true do |t|
|
7
7
|
t.string :subject
|
8
8
|
t.text :content
|
9
9
|
t.datetime :created_at
|
data/test/test_helper.rb
CHANGED
@@ -14,10 +14,13 @@ load(File.dirname(__FILE__) + "/schema.rb")
|
|
14
14
|
require 'unread'
|
15
15
|
|
16
16
|
class Reader < ActiveRecord::Base
|
17
|
+
self.primary_key = 'number'
|
17
18
|
acts_as_reader
|
18
19
|
end
|
19
20
|
|
20
21
|
class Email < ActiveRecord::Base
|
22
|
+
self.primary_key = 'messageid'
|
23
|
+
|
21
24
|
acts_as_readable :on => :updated_at
|
22
25
|
end
|
23
26
|
|
data/test/unread_test.rb
CHANGED
@@ -126,7 +126,7 @@ class UnreadTest < ActiveSupport::TestCase
|
|
126
126
|
def test_mark_all_as_read
|
127
127
|
Email.mark_as_read! :all, :for => @reader
|
128
128
|
|
129
|
-
assert_equal Time.
|
129
|
+
assert_equal Time.current, @reader.read_mark_global(Email).timestamp
|
130
130
|
assert_equal [], @reader.read_marks.single
|
131
131
|
assert_equal 0, ReadMark.single.count
|
132
132
|
assert_equal 2, ReadMark.global.count
|
metadata
CHANGED
@@ -1,69 +1,69 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unread
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Georg Ledermann
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-12-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '3'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '3'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: timecop
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: sqlite3
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
description: 'This gem creates a scope for unread objects and adds methods to mark
|
@@ -74,17 +74,17 @@ executables: []
|
|
74
74
|
extensions: []
|
75
75
|
extra_rdoc_files: []
|
76
76
|
files:
|
77
|
-
- .gitignore
|
78
|
-
- .travis.yml
|
77
|
+
- ".gitignore"
|
78
|
+
- ".travis.yml"
|
79
79
|
- Gemfile
|
80
80
|
- MIT-LICENSE
|
81
81
|
- README.md
|
82
82
|
- Rakefile
|
83
83
|
- changelog.md
|
84
|
-
- ci/Gemfile
|
85
|
-
- ci/Gemfile
|
86
|
-
- ci/Gemfile
|
87
|
-
- ci/Gemfile
|
84
|
+
- ci/Gemfile-rails-3-0
|
85
|
+
- ci/Gemfile-rails-3-1
|
86
|
+
- ci/Gemfile-rails-3-2
|
87
|
+
- ci/Gemfile-rails-4-0
|
88
88
|
- lib/generators/unread/migration/migration_generator.rb
|
89
89
|
- lib/generators/unread/migration/templates/migration.rb
|
90
90
|
- lib/unread.rb
|
@@ -108,17 +108,17 @@ require_paths:
|
|
108
108
|
- lib
|
109
109
|
required_ruby_version: !ruby/object:Gem::Requirement
|
110
110
|
requirements:
|
111
|
-
- -
|
111
|
+
- - ">="
|
112
112
|
- !ruby/object:Gem::Version
|
113
113
|
version: '0'
|
114
114
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
115
115
|
requirements:
|
116
|
-
- -
|
116
|
+
- - ">="
|
117
117
|
- !ruby/object:Gem::Version
|
118
118
|
version: '0'
|
119
119
|
requirements: []
|
120
120
|
rubyforge_project: unread
|
121
|
-
rubygems_version: 2.0.
|
121
|
+
rubygems_version: 2.0.14
|
122
122
|
signing_key:
|
123
123
|
specification_version: 4
|
124
124
|
summary: Manages read/unread status of ActiveRecord objects
|