unread 0.11.0 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: da2c0da709d4464ceda393f45c8fa5aa6858c3bf458cbd75351491145a9b4905
4
- data.tar.gz: b6a4938837521be8b1a86e38aa2b181572cf4ec2731b765389e71538a3822a0a
3
+ metadata.gz: '0849de50af252049e5309e1ca544df5053ba3c6351d67e391866682b33fa8163'
4
+ data.tar.gz: 1f64b206feac17afb3870ecb2bc218388a908fab0087132cc6ebad180e888ae5
5
5
  SHA512:
6
- metadata.gz: 9b3980715732e4f3dc0fbf2e63b3367322b6f3c03ced30516b6cba94e31e4b54e6a707ae192e4aa5a00fd2ad83b3501c93ba7f89c3d9081903fc36966a183765
7
- data.tar.gz: '0228314b73218e74d9583860892b77d9fd1f9ed3f41ff9c07b6985095e895be1b609fb4ac9befa34b64c3352b45ffb0c229295e74c1d16e7fdfaf7c7b6e34ee4'
6
+ metadata.gz: aa99055d954ba4f8b26a2e4d57891631865f1a424926c537aad9c270fe07447c7648813ecd4fb3d4ef41e7d90dfca2e5efc20a3c9bdaea6cd9819babc7239a3c
7
+ data.tar.gz: 19c235ff12ad3ce70d5b7f360dfb162eef10fa4190e6eb6c2a2cebae58eb7d3fb63d5e4e0dd87a2596d730e2ebf13d30b8032ad8a3bdc748256519f518d2db78
@@ -0,0 +1,129 @@
1
+ name: Test
2
+
3
+ on:
4
+ push:
5
+ branches: [ master ]
6
+ pull_request:
7
+ branches: [ master ]
8
+
9
+ jobs:
10
+ test_sqlite:
11
+ runs-on: ubuntu-latest
12
+
13
+ strategy:
14
+ fail-fast: false
15
+ matrix:
16
+ ruby: [ '2.7', '3.0', '3.1' ]
17
+ rails: [ '6.0', '6.1', '7.0' ]
18
+
19
+ name: SQLite / Ruby ${{ matrix.ruby }} / Rails ${{ matrix.rails }}
20
+
21
+ steps:
22
+ - uses: actions/checkout@v2
23
+
24
+ - name: Setup Ruby
25
+ uses: ruby/setup-ruby@v1
26
+ with:
27
+ ruby-version: ${{ matrix.ruby }}
28
+
29
+ - name: Install gems
30
+ env:
31
+ MATRIX_RAILS_VERSION: ${{ matrix.rails }}
32
+ run: |
33
+ export BUNDLE_GEMFILE="${GITHUB_WORKSPACE}/gemfiles/rails_${MATRIX_RAILS_VERSION}.gemfile"
34
+ bundle install --jobs 4 --retry 3
35
+
36
+ - name: RSpec
37
+ run: bundle exec rake
38
+
39
+ test_mysql:
40
+ runs-on: ubuntu-latest
41
+
42
+ services:
43
+ mysql:
44
+ image: mysql:5.7
45
+ env:
46
+ MYSQL_ROOT_PASSWORD: password
47
+ ports:
48
+ - 3306:3306
49
+ options: >-
50
+ --health-cmd="mysqladmin ping"
51
+ --health-interval=10s
52
+ --health-timeout=5s
53
+ --health-retries=3
54
+
55
+ strategy:
56
+ fail-fast: false
57
+ matrix:
58
+ ruby: [ '2.7', '3.0', '3.1' ]
59
+ rails: [ '6.0', '6.1', '7.0' ]
60
+
61
+ name: MySQL / Ruby ${{ matrix.ruby }} / Rails ${{ matrix.rails }}
62
+
63
+ steps:
64
+ - uses: actions/checkout@v2
65
+
66
+ - name: Setup Ruby
67
+ uses: ruby/setup-ruby@v1
68
+ with:
69
+ ruby-version: ${{ matrix.ruby }}
70
+
71
+ - name: Install gems
72
+ env:
73
+ MATRIX_RAILS_VERSION: ${{ matrix.rails }}
74
+ run: |
75
+ export BUNDLE_GEMFILE="${GITHUB_WORKSPACE}/gemfiles/rails_${MATRIX_RAILS_VERSION}.gemfile"
76
+ bundle install --jobs 4 --retry 3
77
+
78
+ - name: Setup database
79
+ run: |
80
+ mysql -e 'create database IF NOT EXISTS unread_test;' -u root --password=password -P 3306 -h 127.0.0.1
81
+
82
+ - name: RSpec
83
+ run: bundle exec rake
84
+
85
+ test_postgres:
86
+ runs-on: ubuntu-latest
87
+
88
+ services:
89
+ postgres:
90
+ image: postgres
91
+ env:
92
+ POSTGRES_PASSWORD: postgres
93
+ options: >-
94
+ --health-cmd pg_isready
95
+ --health-interval 10s
96
+ --health-timeout 5s
97
+ --health-retries 5
98
+ ports:
99
+ - 5432:5432
100
+
101
+ strategy:
102
+ fail-fast: false
103
+ matrix:
104
+ ruby: [ '2.7', '3.0', '3.1' ]
105
+ rails: [ '6.0', '6.1', '7.0' ]
106
+
107
+ name: PostgreSQL / Ruby ${{ matrix.ruby }} / Rails ${{ matrix.rails }}
108
+
109
+ steps:
110
+ - uses: actions/checkout@v2
111
+
112
+ - name: Setup Ruby
113
+ uses: ruby/setup-ruby@v1
114
+ with:
115
+ ruby-version: ${{ matrix.ruby }}
116
+
117
+ - name: Install gems
118
+ env:
119
+ MATRIX_RAILS_VERSION: ${{ matrix.rails }}
120
+ run: |
121
+ export BUNDLE_GEMFILE="${GITHUB_WORKSPACE}/gemfiles/rails_${MATRIX_RAILS_VERSION}.gemfile"
122
+ bundle install --jobs 4 --retry 3
123
+
124
+ - name: Setup database
125
+ run: |
126
+ PGPASSWORD=postgres psql -c 'create database unread_test;' -U postgres -p 5432 -h localhost
127
+
128
+ - name: RSpec
129
+ run: bundle exec rake
data/Appraisals CHANGED
@@ -1,48 +1,20 @@
1
- appraise "rails-6-0" do
2
- gem "activerecord", "~> 6.0.0.beta3"
3
- gem "mysql2", ">= 0.4.4"
4
- gem "pg", ">= 0.18", "< 2.0"
1
+ appraise "rails-7.0" do
2
+ gem "activerecord", "~> 7.0.0"
3
+ gem "mysql2", "~> 0.5"
4
+ gem "pg", "~> 1.1"
5
5
  gem "sqlite3", "~> 1.4"
6
6
  end
7
7
 
8
- appraise "rails-5-2" do
9
- gem "activerecord", "~> 5.2.3"
10
- gem "mysql2", ">= 0.4.4", "< 0.6.0"
11
- gem "pg", ">= 0.18", "< 2.0"
12
- gem "sqlite3", "~> 1.3", ">= 1.3.6"
13
- end
14
-
15
- appraise "rails-5-1" do
16
- gem "activerecord", "~> 5.1.7"
17
- gem "mysql2", ">= 0.3.18", "< 0.6.0"
18
- gem "pg", ">= 0.18", "< 2.0"
19
- gem "sqlite3", "~> 1.3", ">= 1.3.6"
8
+ appraise "rails-6.1" do
9
+ gem "activerecord", "~> 6.1.2", ">= 6.1.2.1"
10
+ gem "mysql2", "~> 0.5"
11
+ gem "pg", "~> 1.1"
12
+ gem "sqlite3", "~> 1.4"
20
13
  end
21
14
 
22
- appraise "rails-5-0" do
23
- gem "activerecord", "~> 5.0.7"
24
- gem 'mysql2', '>= 0.3.18', '< 0.6.0'
15
+ appraise "rails-6.0" do
16
+ gem "activerecord", "~> 6.0.0"
17
+ gem "mysql2", ">= 0.4.4"
25
18
  gem "pg", ">= 0.18", "< 2.0"
26
- gem 'sqlite3', '~> 1.3.6'
27
- end
28
-
29
- appraise "rails-4-2" do
30
- gem "activerecord", "~> 4.2.11"
31
- gem 'mysql2', '>= 0.3.13', '< 0.6.0'
32
- gem "pg", "~> 0.15"
33
- gem 'sqlite3', '~> 1.3.6'
34
- end
35
-
36
- appraise "rails-4-1" do
37
- gem "activerecord", "~> 4.1.16"
38
- gem 'mysql2', '~> 0.3.13'
39
- gem "pg", "~> 0.11"
40
- gem 'sqlite3', '~> 1.3.6'
41
- end
42
-
43
- appraise "rails-4-0" do
44
- gem "activerecord", "~> 4.0.13"
45
- gem "mysql2", '~> 0.3.10'
46
- gem "pg", "~> 0.11"
47
- gem 'sqlite3', '~> 1.3.6'
19
+ gem "sqlite3", "~> 1.4"
48
20
  end
data/MIT-LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2010-2019 Georg Ledermann
3
+ Copyright (c) 2010-2022 Georg Ledermann
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining
6
6
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -3,7 +3,7 @@ Unread
3
3
 
4
4
  Ruby gem to manage read/unread status of ActiveRecord objects - and it's fast.
5
5
 
6
- [![Build Status](https://travis-ci.org/ledermann/unread.svg?branch=master)](https://travis-ci.org/ledermann/unread)
6
+ [![Build Status](https://github.com/ledermann/unread/workflows/Test/badge.svg?branch=master)](https://github.com/ledermann/unread/actions)
7
7
  [![Maintainability](https://api.codeclimate.com/v1/badges/930c8df0f99b20324444/maintainability)](https://codeclimate.com/github/ledermann/unread/maintainability)
8
8
  [![Coverage Status](https://coveralls.io/repos/ledermann/unread/badge.svg?branch=master)](https://coveralls.io/r/ledermann/unread?branch=master)
9
9
 
@@ -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 2.4 or newer
23
- * Rails 4.0 or newer (including Rails 6)
22
+ * Ruby 2.7 or newer
23
+ * Rails 6.0 or newer (including Rails 7)
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
 
@@ -223,4 +223,4 @@ AND messages.created_at > '2010-10-20 08:50:00'
223
223
  Hint: You should add a database index on `messages.created_at`.
224
224
 
225
225
 
226
- Copyright (c) 2010-2019 [Georg Ledermann](http://www.georg-ledermann.de) and [contributors](https://github.com/ledermann/unread/graphs/contributors), released under the MIT license
226
+ Copyright (c) 2010-2022 [Georg Ledermann](https://ledermann.dev) and [contributors](https://github.com/ledermann/unread/graphs/contributors), released under the MIT license
@@ -2,7 +2,7 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "activerecord", "~> 6.0.0.beta3"
5
+ gem "activerecord", "~> 6.0.0"
6
6
  gem "mysql2", ">= 0.4.4"
7
7
  gem "pg", ">= 0.18", "< 2.0"
8
8
  gem "sqlite3", "~> 1.4"
@@ -0,0 +1,10 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "activerecord", "~> 6.1.2", ">= 6.1.2.1"
6
+ gem "mysql2", "~> 0.5"
7
+ gem "pg", "~> 1.1"
8
+ gem "sqlite3", "~> 1.4"
9
+
10
+ gemspec path: "../"
@@ -0,0 +1,10 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "activerecord", "~> 7.0.0"
6
+ gem "mysql2", "~> 0.5"
7
+ gem "pg", "~> 1.1"
8
+ gem "sqlite3", "~> 1.4"
9
+
10
+ gemspec path: "../"
@@ -1,9 +1,9 @@
1
- class UnreadMigration < Unread::MIGRATION_BASE_CLASS
1
+ class UnreadMigration < ActiveRecord::Migration[6.0]
2
2
  def self.up
3
3
  create_table ReadMark, force: true, options: create_options do |t|
4
4
  t.references :readable, polymorphic: { null: false }
5
5
  t.references :reader, polymorphic: { null: false }
6
- t.datetime :timestamp
6
+ t.datetime :timestamp, null: false
7
7
  end
8
8
 
9
9
  add_index ReadMark, [:reader_id, :reader_type, :readable_type, :readable_id], name: 'read_marks_reader_readable_index', unique: true
@@ -1,4 +1,4 @@
1
- class UnreadPolymorphicReaderMigration < Unread::MIGRATION_BASE_CLASS
1
+ class UnreadPolymorphicReaderMigration < ActiveRecord::Migration[6.0]
2
2
  def self.up
3
3
  remove_index :read_marks, [:user_id, :readable_type, :readable_id]
4
4
  rename_column :read_marks, :user_id, :reader_id
data/lib/unread/base.rb CHANGED
@@ -8,7 +8,7 @@ module Unread
8
8
  ReadMark.reader_classes ||= []
9
9
 
10
10
  unless ReadMark.reader_classes.include?(self)
11
- ReadMark.belongs_to :reader, polymorphic: true, inverse_of: :read_marks
11
+ ReadMark.belongs_to :reader, polymorphic: true, inverse_of: :read_marks, optional: true
12
12
 
13
13
  has_many :read_marks, dependent: :delete_all, as: :reader, inverse_of: :reader
14
14
 
data/lib/unread/reader.rb CHANGED
@@ -16,7 +16,13 @@ module Unread
16
16
  def read_mark_global(klass)
17
17
  @read_mark_global ||= {}
18
18
  readable_klass = klass.readable_parent
19
- @read_mark_global[readable_klass] ||= read_marks.where(readable_type: readable_klass.name).global.first
19
+
20
+ # Memoize with NIL handling
21
+ if @read_mark_global.has_key?(readable_klass)
22
+ @read_mark_global[readable_klass]
23
+ else
24
+ @read_mark_global[readable_klass] = read_marks.where(readable_type: readable_klass.name).global.first
25
+ end
20
26
  end
21
27
 
22
28
  def forget_memoized_read_mark_global
@@ -1,3 +1,3 @@
1
1
  module Unread
2
- VERSION = '0.11.0'
2
+ VERSION = '0.12.0'
3
3
  end
data/lib/unread.rb CHANGED
@@ -1,7 +1,6 @@
1
1
  require 'active_record'
2
2
 
3
3
  require 'unread/base'
4
- require 'unread/read_mark'
5
4
  require 'unread/readable'
6
5
  require 'unread/reader'
7
6
  require 'unread/readable_scopes'
@@ -9,10 +8,8 @@ require 'unread/reader_scopes'
9
8
  require 'unread/garbage_collector'
10
9
  require 'unread/version'
11
10
 
12
- ActiveRecord::Base.send :include, Unread
11
+ ActiveSupport.on_load(:active_record) do
12
+ require 'unread/read_mark'
13
13
 
14
- Unread::MIGRATION_BASE_CLASS = if ActiveRecord::VERSION::MAJOR >= 5
15
- ActiveRecord::Migration[5.0]
16
- else
17
- ActiveRecord::Migration
14
+ include Unread
18
15
  end
data/unread.gemspec CHANGED
@@ -8,11 +8,11 @@ Gem::Specification.new do |s|
8
8
  s.version = Unread::VERSION
9
9
  s.licenses = ['MIT']
10
10
  s.authors = ["Georg Ledermann"]
11
- s.email = ["mail@georg-ledermann.de"]
11
+ s.email = ["georg@ledermann.dev"]
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 = '>= 2.4'
15
+ s.required_ruby_version = '>= 2.7'
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.11.0
4
+ version: 0.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Georg Ledermann
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-08-25 00:00:00.000000000 Z
11
+ date: 2022-11-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -181,13 +181,13 @@ dependencies:
181
181
  description: 'This gem creates a scope for unread objects and adds methods to mark
182
182
  objects as read '
183
183
  email:
184
- - mail@georg-ledermann.de
184
+ - georg@ledermann.dev
185
185
  executables: []
186
186
  extensions: []
187
187
  extra_rdoc_files: []
188
188
  files:
189
+ - ".github/workflows/main.yml"
189
190
  - ".gitignore"
190
- - ".travis.yml"
191
191
  - Appraisals
192
192
  - Gemfile
193
193
  - MIT-LICENSE
@@ -195,13 +195,9 @@ files:
195
195
  - Rakefile
196
196
  - UPGRADE.md
197
197
  - bin/console
198
- - gemfiles/rails_4_0.gemfile
199
- - gemfiles/rails_4_1.gemfile
200
- - gemfiles/rails_4_2.gemfile
201
- - gemfiles/rails_5_0.gemfile
202
- - gemfiles/rails_5_1.gemfile
203
- - gemfiles/rails_5_2.gemfile
204
- - gemfiles/rails_6_0.gemfile
198
+ - gemfiles/rails_6.0.gemfile
199
+ - gemfiles/rails_6.1.gemfile
200
+ - gemfiles/rails_7.0.gemfile
205
201
  - lib/generators/unread/migration/migration_generator.rb
206
202
  - lib/generators/unread/migration/templates/migration.rb
207
203
  - lib/generators/unread/polymorphic_reader_migration/polymorphic_reader_migration_generator.rb
@@ -220,7 +216,7 @@ homepage: https://github.com/ledermann/unread
220
216
  licenses:
221
217
  - MIT
222
218
  metadata: {}
223
- post_install_message:
219
+ post_install_message:
224
220
  rdoc_options: []
225
221
  require_paths:
226
222
  - lib
@@ -228,15 +224,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
228
224
  requirements:
229
225
  - - ">="
230
226
  - !ruby/object:Gem::Version
231
- version: '2.4'
227
+ version: '2.7'
232
228
  required_rubygems_version: !ruby/object:Gem::Requirement
233
229
  requirements:
234
230
  - - ">="
235
231
  - !ruby/object:Gem::Version
236
232
  version: '0'
237
233
  requirements: []
238
- rubygems_version: 3.0.6
239
- signing_key:
234
+ rubygems_version: 3.3.26
235
+ signing_key:
240
236
  specification_version: 4
241
237
  summary: Manages read/unread status of ActiveRecord objects
242
238
  test_files: []
data/.travis.yml DELETED
@@ -1,44 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.4.6
4
- - 2.5.5
5
- - 2.6.3
6
- gemfile:
7
- - gemfiles/rails_6_0.gemfile
8
- - gemfiles/rails_5_2.gemfile
9
- - gemfiles/rails_5_1.gemfile
10
- - gemfiles/rails_5_0.gemfile
11
- - gemfiles/rails_4_2.gemfile
12
- - gemfiles/rails_4_1.gemfile
13
- - gemfiles/rails_4_0.gemfile
14
- matrix:
15
- exclude:
16
- - rvm: 2.4.6
17
- gemfile: gemfiles/rails_4_0.gemfile
18
- - rvm: 2.4.6
19
- gemfile: gemfiles/rails_4_1.gemfile
20
- - rvm: 2.4.6
21
- gemfile: gemfiles/rails_6_0.gemfile
22
- - rvm: 2.5.5
23
- gemfile: gemfiles/rails_4_0.gemfile
24
- - rvm: 2.5.5
25
- gemfile: gemfiles/rails_4_1.gemfile
26
- - rvm: 2.6.3
27
- gemfile: gemfiles/rails_4_0.gemfile
28
- - rvm: 2.6.3
29
- gemfile: gemfiles/rails_4_1.gemfile
30
- before_install: gem update bundler
31
- sudo: false
32
- env:
33
- - DB=sqlite
34
- - DB=mysql
35
- - DB=postgres
36
- services:
37
- - mysql
38
- - postgres
39
- before_script:
40
- - gem update --system # https://github.com/travis-ci/travis-ci/issues/8978
41
- - sh -c "if [ '$DB' = 'mysql' ]; then mysql -e 'create database IF NOT EXISTS unread_test;'; fi"
42
- - sh -c "if [ '$DB' = 'postgres' ]; then psql -c 'create database unread_test;' -U postgres; fi"
43
- addons:
44
- postgresql: "9.4"
@@ -1,10 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "activerecord", "~> 4.0.13"
6
- gem "mysql2", "~> 0.3.10"
7
- gem "pg", "~> 0.11"
8
- gem "sqlite3", "~> 1.3.6"
9
-
10
- gemspec path: "../"
@@ -1,10 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "activerecord", "~> 4.1.16"
6
- gem "mysql2", "~> 0.3.13"
7
- gem "pg", "~> 0.11"
8
- gem "sqlite3", "~> 1.3.6"
9
-
10
- gemspec path: "../"
@@ -1,10 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "activerecord", "~> 4.2.11"
6
- gem "mysql2", ">= 0.3.13", "< 0.6.0"
7
- gem "pg", "~> 0.15"
8
- gem "sqlite3", "~> 1.3.6"
9
-
10
- gemspec path: "../"
@@ -1,10 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "activerecord", "~> 5.0.7"
6
- gem "mysql2", ">= 0.3.18", "< 0.6.0"
7
- gem "pg", ">= 0.18", "< 2.0"
8
- gem "sqlite3", "~> 1.3.6"
9
-
10
- gemspec path: "../"
@@ -1,10 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "activerecord", "~> 5.1.7"
6
- gem "mysql2", ">= 0.3.18", "< 0.6.0"
7
- gem "pg", ">= 0.18", "< 2.0"
8
- gem "sqlite3", "~> 1.3", ">= 1.3.6"
9
-
10
- gemspec path: "../"
@@ -1,10 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "activerecord", "~> 5.2.3"
6
- gem "mysql2", ">= 0.4.4", "< 0.6.0"
7
- gem "pg", ">= 0.18", "< 2.0"
8
- gem "sqlite3", "~> 1.3", ">= 1.3.6"
9
-
10
- gemspec path: "../"