unread 0.7.0 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -0
- data/README.md +1 -0
- data/bin/console +1 -1
- data/ci/Gemfile-rails-3-0 +1 -0
- data/ci/Gemfile-rails-3-1 +1 -0
- data/ci/Gemfile-rails-3-2 +1 -0
- data/ci/Gemfile-rails-4-0 +1 -0
- data/ci/Gemfile-rails-4-1 +1 -0
- data/ci/Gemfile-rails-4-2 +1 -0
- data/lib/unread/garbage_collector.rb +1 -1
- data/lib/unread/readable.rb +1 -1
- data/lib/unread/reader.rb +1 -1
- data/lib/unread/version.rb +1 -1
- data/spec/app/models/reader.rb +2 -2
- data/spec/database.yml +4 -0
- data/spec/support/matchers/perform_queries.rb +2 -5
- data/unread.gemspec +2 -1
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b42af3056d22efa6bd8f01efb9015ce13f4e2655
|
4
|
+
data.tar.gz: 99e1e8ba04db00f7d29e40dfb5ac4370511d3fe5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d4cd7ed7703aa74f878b8c3a93b2c5b083775b04735590db2431d745e2f68e271c7f3546cb8494de38c1969ad552894cc5a0e776a9303a63d6ed0d1bb1b796de
|
7
|
+
data.tar.gz: 98263bf4a54954ce81777b2c6aefde0baee14938da8ecea81462bfa693c263a7862bc2ff5fbb9c14bb948916ff5febee9f303df1b3fa24c5cb660111c6b2e486
|
data/.travis.yml
CHANGED
@@ -16,5 +16,7 @@ sudo: false
|
|
16
16
|
env:
|
17
17
|
- DB=sqlite
|
18
18
|
- DB=mysql
|
19
|
+
- DB=postgres
|
19
20
|
before_script:
|
20
21
|
- sh -c "if [ '$DB' = 'mysql' ]; then mysql -e 'create database IF NOT EXISTS unread_test;'; fi"
|
22
|
+
- sh -c "if [ '$DB' = 'postgres' ]; then psql -c 'create database unread_test;' -U postgres; fi"
|
data/README.md
CHANGED
@@ -21,6 +21,7 @@ Ruby gem to manage read/unread status of ActiveRecord objects - and it's fast.
|
|
21
21
|
|
22
22
|
* Ruby 1.9.3 or newer
|
23
23
|
* Rails 3 (including 3.0, 3.1, 3.2) and Rails 4. For use with Rails 2.3 there is a branch named "rails2"
|
24
|
+
* MySQL, PostgreSQL or SQLite
|
24
25
|
* Needs a timestamp field in your models (like created_at or updated_at) with a database index on it
|
25
26
|
|
26
27
|
|
data/bin/console
CHANGED
@@ -20,7 +20,7 @@ require 'spec/app/models/email'
|
|
20
20
|
# Pry.start
|
21
21
|
|
22
22
|
ActiveRecord::Base.configurations = YAML.load_file('spec/database.yml')
|
23
|
-
ActiveRecord::Base.establish_connection(
|
23
|
+
ActiveRecord::Base.establish_connection((ENV['DB'] || 'sqlite').to_sym)
|
24
24
|
ActiveRecord::Migration.verbose = false
|
25
25
|
|
26
26
|
UnreadMigration.up
|
data/ci/Gemfile-rails-3-0
CHANGED
data/ci/Gemfile-rails-3-1
CHANGED
data/ci/Gemfile-rails-3-2
CHANGED
data/ci/Gemfile-rails-4-0
CHANGED
data/ci/Gemfile-rails-4-1
CHANGED
data/ci/Gemfile-rails-4-2
CHANGED
@@ -30,7 +30,7 @@ module Unread
|
|
30
30
|
reader_scope.
|
31
31
|
joins(:read_marks).
|
32
32
|
where(:read_marks => { :readable_type => readable_class.base_class.name }).
|
33
|
-
group(
|
33
|
+
group("read_marks.reader_type, read_marks.reader_id, #{reader_class.quoted_table_name}.#{reader_class.quoted_primary_key}").
|
34
34
|
having('COUNT(read_marks.id) > 1')
|
35
35
|
end
|
36
36
|
|
data/lib/unread/readable.rb
CHANGED
data/lib/unread/reader.rb
CHANGED
@@ -35,7 +35,7 @@ module Unread
|
|
35
35
|
|
36
36
|
def read_mark_id_belongs_to?(readable)
|
37
37
|
self.read_mark_readable_type == readable.class.base_class.name &&
|
38
|
-
(self.read_mark_readable_id.nil? || self.read_mark_readable_id == readable.id)
|
38
|
+
(self.read_mark_readable_id.nil? || self.read_mark_readable_id.to_i == readable.id)
|
39
39
|
end
|
40
40
|
|
41
41
|
# We assume that a new reader should not be tackled by tons of old messages created BEFORE he signed up.
|
data/lib/unread/version.rb
CHANGED
data/spec/app/models/reader.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
class Reader < ActiveRecord::Base
|
2
2
|
self.primary_key = 'number'
|
3
3
|
|
4
|
-
scope :not_foo, -> { where(
|
5
|
-
scope :not_bar, -> { where(
|
4
|
+
scope :not_foo, -> { where("name <> 'foo'") }
|
5
|
+
scope :not_bar, -> { where("name <> 'bar'") }
|
6
6
|
|
7
7
|
acts_as_reader
|
8
8
|
|
data/spec/database.yml
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
RSpec::Matchers.define :perform_queries do |expected|
|
2
|
+
supports_block_expectations
|
3
|
+
|
2
4
|
match do |block|
|
3
5
|
query_count(&block) == expected
|
4
6
|
end
|
@@ -12,11 +14,6 @@ RSpec::Matchers.define :perform_queries do |expected|
|
|
12
14
|
ActiveSupport::Notifications.subscribe('sql.active_record', @counter.to_proc)
|
13
15
|
yield
|
14
16
|
ActiveSupport::Notifications.unsubscribe(@counter.to_proc)
|
15
|
-
|
16
17
|
@counter.query_count
|
17
18
|
end
|
18
|
-
|
19
|
-
def supports_block_expectations?
|
20
|
-
true
|
21
|
-
end
|
22
19
|
end
|
data/unread.gemspec
CHANGED
@@ -25,7 +25,8 @@ Gem::Specification.new do |s|
|
|
25
25
|
s.add_development_dependency 'rake'
|
26
26
|
s.add_development_dependency 'timecop'
|
27
27
|
s.add_development_dependency 'sqlite3'
|
28
|
-
s.add_development_dependency 'mysql2'
|
28
|
+
s.add_development_dependency 'mysql2', '~> 0.3.13'
|
29
|
+
s.add_development_dependency 'pg'
|
29
30
|
s.add_development_dependency 'rspec'
|
30
31
|
s.add_development_dependency 'simplecov'
|
31
32
|
s.add_development_dependency 'coveralls', '>= 0.8.0'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unread
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.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: 2015-11-
|
11
|
+
date: 2015-11-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -68,6 +68,20 @@ dependencies:
|
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: mysql2
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.3.13
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.3.13
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: pg
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
72
86
|
requirements:
|
73
87
|
- - ">="
|