unread 0.13.0 → 0.14.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.
- checksums.yaml +4 -4
- data/.github/workflows/main.yml +6 -6
- data/Appraisals +7 -1
- data/README.md +2 -2
- data/gemfiles/rails_7.2.gemfile +10 -0
- data/lib/generators/unread/migration/migration_generator.rb +12 -1
- data/lib/unread/readable_scopes.rb +12 -4
- data/lib/unread/reader_scopes.rb +11 -3
- data/lib/unread/version.rb +1 -1
- data/unread.gemspec +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 67315a612c07e3b1b75c27ab34d2d29b9d7c6ae49c43b7f8fa9109ea9bf1360a
|
4
|
+
data.tar.gz: 2e744db1b74319ead0e3166a127b7bb21791fb41e0ffeed0211b8a0427778fed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f1c031e9c0dbfab4fc028e4ad57c27aebf51f637338cd4df97b190527f98108af91bbe3fd1a525112f1c5c384da127ae197f7ddd30470933329a20bd8656135e
|
7
|
+
data.tar.gz: b277d655b81d67083832e011b90301effed633ac93559cc87c589f7e44ce719414db7fb1d72d16426fe71e27ba13ab22bff0395fb83a6268c10ec280bbf57ee5
|
data/.github/workflows/main.yml
CHANGED
@@ -13,8 +13,8 @@ jobs:
|
|
13
13
|
strategy:
|
14
14
|
fail-fast: false
|
15
15
|
matrix:
|
16
|
-
ruby: [
|
17
|
-
rails: [
|
16
|
+
ruby: ['3.1', '3.2', '3.3']
|
17
|
+
rails: ['6.1', '7.0', '7.1', '7.2']
|
18
18
|
|
19
19
|
name: SQLite / Ruby ${{ matrix.ruby }} / Rails ${{ matrix.rails }}
|
20
20
|
|
@@ -58,8 +58,8 @@ jobs:
|
|
58
58
|
strategy:
|
59
59
|
fail-fast: false
|
60
60
|
matrix:
|
61
|
-
ruby: [
|
62
|
-
rails: [
|
61
|
+
ruby: ['3.1', '3.2', '3.3']
|
62
|
+
rails: ['6.1', '7.0', '7.1', '7.2']
|
63
63
|
|
64
64
|
name: MySQL / Ruby ${{ matrix.ruby }} / Rails ${{ matrix.rails }}
|
65
65
|
|
@@ -107,8 +107,8 @@ jobs:
|
|
107
107
|
strategy:
|
108
108
|
fail-fast: false
|
109
109
|
matrix:
|
110
|
-
ruby: [
|
111
|
-
rails: [
|
110
|
+
ruby: ['3.1', '3.2', '3.3']
|
111
|
+
rails: ['6.1', '7.0', '7.1', '7.2']
|
112
112
|
|
113
113
|
name: PostgreSQL / Ruby ${{ matrix.ruby }} / Rails ${{ matrix.rails }}
|
114
114
|
|
data/Appraisals
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
appraise "rails-7.2" do
|
2
|
+
gem "activerecord", "~> 7.2.0"
|
3
|
+
gem "mysql2", "~> 0.5"
|
4
|
+
gem "pg", "~> 1.3"
|
5
|
+
gem "sqlite3", ">= 2.0"
|
6
|
+
end
|
7
|
+
|
1
8
|
appraise "rails-7.1" do
|
2
9
|
gem "activerecord", "~> 7.1.0"
|
3
10
|
gem "mysql2", "~> 0.5"
|
@@ -18,4 +25,3 @@ appraise "rails-6.1" do
|
|
18
25
|
gem "pg", "~> 1.1"
|
19
26
|
gem "sqlite3", "~> 1.4"
|
20
27
|
end
|
21
|
-
|
data/README.md
CHANGED
@@ -19,8 +19,8 @@ Ruby gem to manage read/unread status of ActiveRecord objects - and it's fast.
|
|
19
19
|
|
20
20
|
## Requirements
|
21
21
|
|
22
|
-
* Ruby 3.
|
23
|
-
* Rails 6.1 or newer (including Rails 7.
|
22
|
+
* Ruby 3.1 or newer
|
23
|
+
* Rails 6.1 or newer (including Rails 7.2)
|
24
24
|
* MySQL, PostgreSQL or SQLite
|
25
25
|
* Needs a timestamp field in your models (like created_at or updated_at) with a database index on it
|
26
26
|
|
@@ -13,11 +13,22 @@ module Unread
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def self.next_migration_number(dirname)
|
16
|
-
if
|
16
|
+
if self.timestamped_migrations?
|
17
17
|
Time.now.utc.strftime("%Y%m%d%H%M%S")
|
18
18
|
else
|
19
19
|
"%.3d" % (current_migration_number(dirname) + 1)
|
20
20
|
end
|
21
21
|
end
|
22
|
+
|
23
|
+
def self.timestamped_migrations?
|
24
|
+
(
|
25
|
+
ActiveRecord::Base.respond_to?(:timestamped_migrations) &&
|
26
|
+
ActiveRecord::Base.timestamped_migrations
|
27
|
+
) ||
|
28
|
+
(
|
29
|
+
ActiveRecord.respond_to?(:timestamped_migrations) &&
|
30
|
+
ActiveRecord.timestamped_migrations
|
31
|
+
)
|
32
|
+
end
|
22
33
|
end
|
23
34
|
end
|
@@ -7,8 +7,8 @@ module Unread
|
|
7
7
|
joins "LEFT JOIN #{ReadMark.quoted_table_name}
|
8
8
|
ON #{ReadMark.quoted_table_name}.readable_type = '#{readable_parent.name}'
|
9
9
|
AND #{ReadMark.quoted_table_name}.readable_id = #{quoted_table_name}.#{quoted_primary_key}
|
10
|
-
AND #{ReadMark.quoted_table_name}.reader_id = #{
|
11
|
-
AND #{ReadMark.quoted_table_name}.reader_type = #{
|
10
|
+
AND #{ReadMark.quoted_table_name}.reader_id = #{quoted(reader.id)}
|
11
|
+
AND #{ReadMark.quoted_table_name}.reader_type = #{quoted(reader.class.base_class.name)}
|
12
12
|
AND #{ReadMark.quoted_table_name}.timestamp >= #{quoted_table_name}.#{connection.quote_column_name(readable_options[:on])}"
|
13
13
|
end
|
14
14
|
|
@@ -39,8 +39,16 @@ module Unread
|
|
39
39
|
|
40
40
|
join_read_marks(reader).select("#{quoted_table_name}.*,
|
41
41
|
#{ReadMark.quoted_table_name}.id AS read_mark_id,
|
42
|
-
#{
|
43
|
-
#{
|
42
|
+
#{quoted(reader.class.base_class.name)}#{postgresql_string_cast} AS read_mark_reader_type,
|
43
|
+
#{quoted(reader.id)} AS read_mark_reader_id")
|
44
|
+
end
|
45
|
+
|
46
|
+
def quoted(value)
|
47
|
+
if Gem::Version.new(ActiveRecord::VERSION::STRING) >= Gem::Version.new('7.2')
|
48
|
+
quote_bound_value(connection, value)
|
49
|
+
else
|
50
|
+
quote_bound_value(value)
|
51
|
+
end
|
44
52
|
end
|
45
53
|
end
|
46
54
|
end
|
data/lib/unread/reader_scopes.rb
CHANGED
@@ -12,7 +12,7 @@ module Unread
|
|
12
12
|
|
13
13
|
joins "LEFT JOIN #{ReadMark.quoted_table_name}
|
14
14
|
ON #{ReadMark.quoted_table_name}.readable_type = '#{readable.class.readable_parent.name}'
|
15
|
-
AND (#{ReadMark.quoted_table_name}.readable_id = #{
|
15
|
+
AND (#{ReadMark.quoted_table_name}.readable_id = #{quoted(readable.id)} OR #{ReadMark.quoted_table_name}.readable_id IS NULL)
|
16
16
|
AND #{ReadMark.quoted_table_name}.reader_id = #{quoted_table_name}.#{quoted_primary_key}
|
17
17
|
AND #{ReadMark.quoted_table_name}.reader_type = '#{connection.quote_string base_class.name}'
|
18
18
|
AND #{ReadMark.quoted_table_name}.timestamp >= '#{connection.quoted_date readable.send(readable.class.readable_options[:on])}'"
|
@@ -31,8 +31,16 @@ module Unread
|
|
31
31
|
|
32
32
|
join_read_marks(readable).select("#{quoted_table_name}.*,
|
33
33
|
#{ReadMark.quoted_table_name}.id AS read_mark_id,
|
34
|
-
#{
|
35
|
-
#{
|
34
|
+
#{quoted(readable.class.name)}#{postgresql_string_cast} AS read_mark_readable_type,
|
35
|
+
#{quoted(readable.id)} AS read_mark_readable_id")
|
36
|
+
end
|
37
|
+
|
38
|
+
def quoted(value)
|
39
|
+
if Gem::Version.new(ActiveRecord::VERSION::STRING) >= Gem::Version.new('7.2')
|
40
|
+
quote_bound_value(connection, value)
|
41
|
+
else
|
42
|
+
quote_bound_value(value)
|
43
|
+
end
|
36
44
|
end
|
37
45
|
end
|
38
46
|
end
|
data/lib/unread/version.rb
CHANGED
data/unread.gemspec
CHANGED
@@ -12,7 +12,7 @@ Gem::Specification.new do |s|
|
|
12
12
|
s.homepage = "https://github.com/ledermann/unread"
|
13
13
|
s.summary = %q{Manages read/unread status of ActiveRecord objects}
|
14
14
|
s.description = %q{This gem creates a scope for unread objects and adds methods to mark objects as read }
|
15
|
-
s.required_ruby_version = '>= 3.
|
15
|
+
s.required_ruby_version = '>= 3.1'
|
16
16
|
|
17
17
|
s.files = `git ls-files -z`.split("\x0").reject do |f|
|
18
18
|
f.match(%r{^(test|spec|features)/})
|
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.
|
4
|
+
version: 0.14.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Georg Ledermann
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-10-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -198,6 +198,7 @@ files:
|
|
198
198
|
- gemfiles/rails_6.1.gemfile
|
199
199
|
- gemfiles/rails_7.0.gemfile
|
200
200
|
- gemfiles/rails_7.1.gemfile
|
201
|
+
- gemfiles/rails_7.2.gemfile
|
201
202
|
- lib/generators/unread/migration/migration_generator.rb
|
202
203
|
- lib/generators/unread/migration/templates/migration.rb
|
203
204
|
- lib/generators/unread/polymorphic_reader_migration/polymorphic_reader_migration_generator.rb
|
@@ -224,14 +225,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
224
225
|
requirements:
|
225
226
|
- - ">="
|
226
227
|
- !ruby/object:Gem::Version
|
227
|
-
version: '3.
|
228
|
+
version: '3.1'
|
228
229
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
229
230
|
requirements:
|
230
231
|
- - ">="
|
231
232
|
- !ruby/object:Gem::Version
|
232
233
|
version: '0'
|
233
234
|
requirements: []
|
234
|
-
rubygems_version: 3.5.
|
235
|
+
rubygems_version: 3.5.21
|
235
236
|
signing_key:
|
236
237
|
specification_version: 4
|
237
238
|
summary: Manages read/unread status of ActiveRecord objects
|