active_recall 1.6.4 → 1.8.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/tests.yml +0 -2
- data/.tool-versions +1 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +14 -16
- data/Rakefile +2 -2
- data/active_recall.gemspec +23 -22
- data/bin/setup +6 -0
- data/lib/active_recall/models/deck.rb +11 -11
- data/lib/active_recall/models/item.rb +5 -5
- data/lib/active_recall/version.rb +1 -1
- data/lib/active_recall.rb +9 -9
- data/lib/generators/active_recall/active_recall_generator.rb +8 -8
- data/lib/generators/active_recall/templates/create_active_recall_tables.rb +5 -5
- data/lib/generators/active_recall/templates/migrate_okubo_to_active_recall.rb +2 -2
- metadata +9 -10
- data/.ruby-version +0 -1
- data/bin/console +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 06e8582ffde66de89e30751aa0f170dfd77d83f4d3e14e200aec66b3acb48683
|
|
4
|
+
data.tar.gz: 80614546c9e7235846cd580bb76ab7aebea90945e35d484a4e50ab6f87a7bb4f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e68952e966e9201f32ecc43ba64984273ba5bb0cf741eedf3b9c8625c9a55829bfe19f3fc0e3ea6b333354a38cc053d3ea89272b6f0e1ea340d7eb84e12bdc0d
|
|
7
|
+
data.tar.gz: ed5fb58e109bc17333a7e4484b22f55e76eaf77c5f81513168613f834418c19bc9cc4d5de5e1a3889bc1fd1120a9c4c443c228ba727b060594a97fde0ac8e893
|
data/.github/workflows/tests.yml
CHANGED
data/.tool-versions
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ruby 3.0.2
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,29 +1,28 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
active_recall (1.
|
|
5
|
-
activerecord (>= 5.2.3, <=
|
|
6
|
-
activesupport (>= 5.2.3, <=
|
|
4
|
+
active_recall (1.8.0)
|
|
5
|
+
activerecord (>= 5.2.3, <= 7.1)
|
|
6
|
+
activesupport (>= 5.2.3, <= 7.1)
|
|
7
7
|
|
|
8
8
|
GEM
|
|
9
9
|
remote: https://rubygems.org/
|
|
10
10
|
specs:
|
|
11
|
-
activemodel (
|
|
12
|
-
activesupport (=
|
|
13
|
-
activerecord (
|
|
14
|
-
activemodel (=
|
|
15
|
-
activesupport (=
|
|
16
|
-
activesupport (
|
|
11
|
+
activemodel (7.0.4.3)
|
|
12
|
+
activesupport (= 7.0.4.3)
|
|
13
|
+
activerecord (7.0.4.3)
|
|
14
|
+
activemodel (= 7.0.4.3)
|
|
15
|
+
activesupport (= 7.0.4.3)
|
|
16
|
+
activesupport (7.0.4.3)
|
|
17
17
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
18
18
|
i18n (>= 1.6, < 2)
|
|
19
19
|
minitest (>= 5.1)
|
|
20
20
|
tzinfo (~> 2.0)
|
|
21
|
-
|
|
22
|
-
concurrent-ruby (1.1.9)
|
|
21
|
+
concurrent-ruby (1.2.2)
|
|
23
22
|
diff-lcs (1.3)
|
|
24
|
-
i18n (1.
|
|
23
|
+
i18n (1.12.0)
|
|
25
24
|
concurrent-ruby (~> 1.0)
|
|
26
|
-
minitest (5.
|
|
25
|
+
minitest (5.18.0)
|
|
27
26
|
rake (12.3.3)
|
|
28
27
|
rdoc (6.2.0)
|
|
29
28
|
rspec (3.8.0)
|
|
@@ -40,9 +39,8 @@ GEM
|
|
|
40
39
|
rspec-support (~> 3.8.0)
|
|
41
40
|
rspec-support (3.8.2)
|
|
42
41
|
sqlite3 (1.4.2)
|
|
43
|
-
tzinfo (2.0.
|
|
42
|
+
tzinfo (2.0.6)
|
|
44
43
|
concurrent-ruby (~> 1.0)
|
|
45
|
-
zeitwerk (2.4.2)
|
|
46
44
|
|
|
47
45
|
PLATFORMS
|
|
48
46
|
ruby
|
|
@@ -55,4 +53,4 @@ DEPENDENCIES
|
|
|
55
53
|
sqlite3
|
|
56
54
|
|
|
57
55
|
BUNDLED WITH
|
|
58
|
-
2.2.
|
|
56
|
+
2.2.22
|
data/Rakefile
CHANGED
data/active_recall.gemspec
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
lib = File.expand_path(
|
|
3
|
+
lib = File.expand_path("lib", __dir__)
|
|
4
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
5
|
-
require
|
|
5
|
+
require "active_recall/version"
|
|
6
6
|
|
|
7
7
|
Gem::Specification.new do |spec|
|
|
8
|
-
spec.name
|
|
9
|
-
spec.version
|
|
10
|
-
spec.authors
|
|
11
|
-
spec.email
|
|
12
|
-
spec.summary
|
|
13
|
-
spec.description
|
|
14
|
-
spec.homepage
|
|
15
|
-
spec.license
|
|
8
|
+
spec.name = "active_recall"
|
|
9
|
+
spec.version = ActiveRecall::VERSION
|
|
10
|
+
spec.authors = ["Robert Gravina", "Jayson Virissimo"]
|
|
11
|
+
spec.email = ["robert.gravina@gmail.com", "jayson.virissimo@asu.edu"]
|
|
12
|
+
spec.summary = "A spaced-repetition system"
|
|
13
|
+
spec.description = "A spaced-repetition system to be used with ActiveRecord models"
|
|
14
|
+
spec.homepage = "https://github.com/jaysonvirissimo/active_recall"
|
|
15
|
+
spec.license = "MIT"
|
|
16
16
|
|
|
17
17
|
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
|
18
18
|
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
|
19
19
|
if spec.respond_to?(:metadata)
|
|
20
|
-
spec.metadata[
|
|
20
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org/"
|
|
21
21
|
else
|
|
22
|
-
raise
|
|
23
|
-
|
|
22
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
|
23
|
+
"public gem pushes."
|
|
24
24
|
end
|
|
25
25
|
|
|
26
26
|
# Specify which files should be added to the gem when it is released.
|
|
@@ -28,14 +28,15 @@ Gem::Specification.new do |spec|
|
|
|
28
28
|
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
|
29
29
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
30
30
|
end
|
|
31
|
-
spec.bindir
|
|
32
|
-
spec.executables
|
|
33
|
-
spec.require_paths = [
|
|
31
|
+
spec.bindir = "exe"
|
|
32
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
33
|
+
spec.require_paths = ["lib"]
|
|
34
34
|
|
|
35
|
-
spec.add_development_dependency
|
|
36
|
-
spec.add_development_dependency
|
|
37
|
-
spec.add_development_dependency
|
|
38
|
-
spec.add_development_dependency
|
|
39
|
-
spec.add_runtime_dependency
|
|
40
|
-
spec.add_runtime_dependency
|
|
35
|
+
spec.add_development_dependency "rake", ">= 12.0"
|
|
36
|
+
spec.add_development_dependency "rdoc"
|
|
37
|
+
spec.add_development_dependency "rspec", ">= 3.0"
|
|
38
|
+
spec.add_development_dependency "sqlite3"
|
|
39
|
+
spec.add_runtime_dependency "activerecord", ">= 5.2.3", "<= 7.1"
|
|
40
|
+
spec.add_runtime_dependency "activesupport", ">= 5.2.3", "<= 7.1"
|
|
41
|
+
spec.required_ruby_version = ">= 2.6"
|
|
41
42
|
end
|
data/bin/setup
CHANGED
|
@@ -4,9 +4,9 @@ module ActiveRecall
|
|
|
4
4
|
class Deck < ActiveRecord::Base
|
|
5
5
|
include Enumerable
|
|
6
6
|
include ActiveRecall::Base
|
|
7
|
-
self.table_name =
|
|
7
|
+
self.table_name = "active_recall_decks"
|
|
8
8
|
belongs_to :user, polymorphic: true
|
|
9
|
-
has_many :items, class_name:
|
|
9
|
+
has_many :items, class_name: "ActiveRecall::Item", dependent: :destroy
|
|
10
10
|
|
|
11
11
|
def each
|
|
12
12
|
_items.each do |item|
|
|
@@ -27,7 +27,7 @@ module ActiveRecall
|
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
def <<(source)
|
|
30
|
-
raise ArgumentError,
|
|
30
|
+
raise ArgumentError, "Word already in the stack" if include?(source)
|
|
31
31
|
|
|
32
32
|
items << ActiveRecall::Item.new(deck: self, source_id: source.id, source_type: source.class.name)
|
|
33
33
|
end
|
|
@@ -43,7 +43,7 @@ module ActiveRecall
|
|
|
43
43
|
end
|
|
44
44
|
|
|
45
45
|
def review
|
|
46
|
-
_review.
|
|
46
|
+
source_class.where(id: _review.select(:source_id))
|
|
47
47
|
end
|
|
48
48
|
|
|
49
49
|
def next
|
|
@@ -51,23 +51,23 @@ module ActiveRecall
|
|
|
51
51
|
end
|
|
52
52
|
|
|
53
53
|
def last
|
|
54
|
-
items.order(
|
|
54
|
+
items.order("created_at desc").limit(1).first.try(:source)
|
|
55
55
|
end
|
|
56
56
|
|
|
57
57
|
def untested
|
|
58
|
-
source_class.
|
|
58
|
+
source_class.where(id: items.untested.select(:source_id))
|
|
59
59
|
end
|
|
60
60
|
|
|
61
61
|
def failed
|
|
62
|
-
source_class.
|
|
62
|
+
source_class.where(id: items.failed.select(:source_id))
|
|
63
63
|
end
|
|
64
64
|
|
|
65
65
|
def known
|
|
66
|
-
source_class.
|
|
66
|
+
source_class.where(id: items.known.select(:source_id))
|
|
67
67
|
end
|
|
68
68
|
|
|
69
69
|
def expired
|
|
70
|
-
source_class.
|
|
70
|
+
source_class.where(id: items.expired.select(:source_id))
|
|
71
71
|
end
|
|
72
72
|
|
|
73
73
|
def box(number)
|
|
@@ -89,11 +89,11 @@ module ActiveRecall
|
|
|
89
89
|
end
|
|
90
90
|
|
|
91
91
|
def random_order_function
|
|
92
|
-
Arel.sql(mysql? ?
|
|
92
|
+
Arel.sql(mysql? ? "RAND()" : "random()")
|
|
93
93
|
end
|
|
94
94
|
|
|
95
95
|
def mysql?
|
|
96
|
-
source_class.connection.adapter_name ==
|
|
96
|
+
source_class.connection.adapter_name == "Mysql2"
|
|
97
97
|
end
|
|
98
98
|
end
|
|
99
99
|
end
|
|
@@ -2,19 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
module ActiveRecall
|
|
4
4
|
class Item < ActiveRecord::Base
|
|
5
|
-
self.table_name =
|
|
5
|
+
self.table_name = "active_recall_items"
|
|
6
6
|
|
|
7
7
|
belongs_to :deck
|
|
8
8
|
|
|
9
|
-
scope :failed, -> { where([
|
|
10
|
-
scope :untested, -> { where([
|
|
9
|
+
scope :failed, -> { where(["box = ? and last_reviewed is not null", 0]) }
|
|
10
|
+
scope :untested, -> { where(["box = ? and last_reviewed is null", 0]) }
|
|
11
11
|
|
|
12
12
|
def self.expired(current_time: Time.current)
|
|
13
|
-
where([
|
|
13
|
+
where(["box > ? and next_review <= ?", 0, current_time])
|
|
14
14
|
end
|
|
15
15
|
|
|
16
16
|
def self.known(current_time: Time.current)
|
|
17
|
-
where([
|
|
17
|
+
where(["box > ? and next_review > ?", 0, current_time])
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
def source
|
data/lib/active_recall.rb
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require
|
|
4
|
-
require
|
|
5
|
-
require
|
|
6
|
-
require
|
|
7
|
-
require
|
|
8
|
-
require
|
|
9
|
-
require
|
|
10
|
-
require
|
|
11
|
-
require
|
|
3
|
+
require "active_recall/base"
|
|
4
|
+
require "active_recall/deck_methods"
|
|
5
|
+
require "active_recall/item_methods"
|
|
6
|
+
require "active_recall/algorithms/fibonacci_sequence"
|
|
7
|
+
require "active_recall/algorithms/leitner_system"
|
|
8
|
+
require "active_recall/configuration"
|
|
9
|
+
require "active_recall/models/deck"
|
|
10
|
+
require "active_recall/models/item"
|
|
11
|
+
require "active_recall/version"
|
|
12
12
|
|
|
13
13
|
ActiveRecord::Base.include ActiveRecall::Base
|
|
14
14
|
|
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require
|
|
4
|
-
require
|
|
5
|
-
require
|
|
3
|
+
require "rails/generators"
|
|
4
|
+
require "rails/generators/migration"
|
|
5
|
+
require "rails/generators/active_record"
|
|
6
6
|
|
|
7
7
|
class ActiveRecallGenerator < Rails::Generators::Base
|
|
8
8
|
include Rails::Generators::Migration
|
|
9
9
|
|
|
10
10
|
class_option :migrate_data, type: :boolean, default: false
|
|
11
11
|
|
|
12
|
-
desc
|
|
12
|
+
desc "Creates migration files required by the active_recall spaced repetition gem."
|
|
13
13
|
|
|
14
|
-
source_paths << File.join(File.dirname(__FILE__),
|
|
14
|
+
source_paths << File.join(File.dirname(__FILE__), "templates")
|
|
15
15
|
|
|
16
16
|
def self.next_migration_number(path)
|
|
17
17
|
ActiveRecord::Generators::Base.next_migration_number(path)
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
def create_migration_files
|
|
21
|
-
create_migration_file_if_not_exist
|
|
22
|
-
create_migration_file_if_not_exist
|
|
23
|
-
create_migration_file_if_not_exist
|
|
21
|
+
create_migration_file_if_not_exist "create_active_recall_tables"
|
|
22
|
+
create_migration_file_if_not_exist "add_active_recall_item_answer_counts"
|
|
23
|
+
create_migration_file_if_not_exist "migrate_okubo_to_active_recall" if options["migrate_data"]
|
|
24
24
|
end
|
|
25
25
|
|
|
26
26
|
private
|
|
@@ -9,11 +9,11 @@ class CreateActiveRecallTables < ActiveRecord::Migration[5.2]
|
|
|
9
9
|
add_index :active_recall_decks, %i[user_id user_type]
|
|
10
10
|
|
|
11
11
|
create_table :active_recall_items do |t|
|
|
12
|
-
t.references
|
|
13
|
-
t.references
|
|
14
|
-
t.integer
|
|
15
|
-
t.timestamp
|
|
16
|
-
t.timestamp
|
|
12
|
+
t.references :deck
|
|
13
|
+
t.references :source, polymorphic: true
|
|
14
|
+
t.integer :box, default: 0
|
|
15
|
+
t.timestamp :last_reviewed
|
|
16
|
+
t.timestamp :next_review
|
|
17
17
|
t.timestamps
|
|
18
18
|
end
|
|
19
19
|
add_index :active_recall_items, %i[source_id source_type]
|
|
@@ -17,8 +17,8 @@ class MigrateOkuboToActiveRecall < ActiveRecord::Migration[5.2]
|
|
|
17
17
|
deck_attributes[:id] == item_attributes[:deck_id]
|
|
18
18
|
end.each do |item_attributes|
|
|
19
19
|
item_create_attributes = item_attributes
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
.except(:id, :created_at, :updated_at)
|
|
21
|
+
.merge(deck_id: deck.id)
|
|
22
22
|
ActiveRecall::Item.create!(item_create_attributes)
|
|
23
23
|
end
|
|
24
24
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: active_recall
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.8.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Robert Gravina
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: exe
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date:
|
|
12
|
+
date: 2023-03-19 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: rake
|
|
@@ -76,7 +76,7 @@ dependencies:
|
|
|
76
76
|
version: 5.2.3
|
|
77
77
|
- - "<="
|
|
78
78
|
- !ruby/object:Gem::Version
|
|
79
|
-
version: '
|
|
79
|
+
version: '7.1'
|
|
80
80
|
type: :runtime
|
|
81
81
|
prerelease: false
|
|
82
82
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -86,7 +86,7 @@ dependencies:
|
|
|
86
86
|
version: 5.2.3
|
|
87
87
|
- - "<="
|
|
88
88
|
- !ruby/object:Gem::Version
|
|
89
|
-
version: '
|
|
89
|
+
version: '7.1'
|
|
90
90
|
- !ruby/object:Gem::Dependency
|
|
91
91
|
name: activesupport
|
|
92
92
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -96,7 +96,7 @@ dependencies:
|
|
|
96
96
|
version: 5.2.3
|
|
97
97
|
- - "<="
|
|
98
98
|
- !ruby/object:Gem::Version
|
|
99
|
-
version: '
|
|
99
|
+
version: '7.1'
|
|
100
100
|
type: :runtime
|
|
101
101
|
prerelease: false
|
|
102
102
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -106,7 +106,7 @@ dependencies:
|
|
|
106
106
|
version: 5.2.3
|
|
107
107
|
- - "<="
|
|
108
108
|
- !ruby/object:Gem::Version
|
|
109
|
-
version: '
|
|
109
|
+
version: '7.1'
|
|
110
110
|
description: A spaced-repetition system to be used with ActiveRecord models
|
|
111
111
|
email:
|
|
112
112
|
- robert.gravina@gmail.com
|
|
@@ -118,14 +118,13 @@ files:
|
|
|
118
118
|
- ".github/workflows/tests.yml"
|
|
119
119
|
- ".gitignore"
|
|
120
120
|
- ".rspec"
|
|
121
|
-
- ".
|
|
121
|
+
- ".tool-versions"
|
|
122
122
|
- Gemfile
|
|
123
123
|
- Gemfile.lock
|
|
124
124
|
- LICENSE
|
|
125
125
|
- README.md
|
|
126
126
|
- Rakefile
|
|
127
127
|
- active_recall.gemspec
|
|
128
|
-
- bin/console
|
|
129
128
|
- bin/setup
|
|
130
129
|
- lib/active_recall.rb
|
|
131
130
|
- lib/active_recall/algorithms/fibonacci_sequence.rb
|
|
@@ -154,14 +153,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
154
153
|
requirements:
|
|
155
154
|
- - ">="
|
|
156
155
|
- !ruby/object:Gem::Version
|
|
157
|
-
version: '
|
|
156
|
+
version: '2.6'
|
|
158
157
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
159
158
|
requirements:
|
|
160
159
|
- - ">="
|
|
161
160
|
- !ruby/object:Gem::Version
|
|
162
161
|
version: '0'
|
|
163
162
|
requirements: []
|
|
164
|
-
rubygems_version: 3.
|
|
163
|
+
rubygems_version: 3.3.5
|
|
165
164
|
signing_key:
|
|
166
165
|
specification_version: 4
|
|
167
166
|
summary: A spaced-repetition system
|
data/.ruby-version
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
3.0.0
|
data/bin/console
DELETED
|
File without changes
|