active_recall 1.3.0 → 1.6.2
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 +46 -0
- data/.ruby-version +1 -1
- data/Gemfile +0 -1
- data/Gemfile.lock +24 -29
- data/README.md +7 -4
- data/active_recall.gemspec +4 -5
- data/lib/active_recall.rb +1 -1
- data/lib/active_recall/algorithms/fibonacci_sequence.rb +3 -3
- data/lib/active_recall/algorithms/leitner_system.rb +3 -3
- data/lib/active_recall/deck_methods.rb +2 -2
- data/lib/active_recall/item_methods.rb +2 -6
- data/lib/active_recall/models/deck.rb +5 -2
- data/lib/active_recall/models/item.rb +2 -2
- data/lib/active_recall/version.rb +1 -1
- data/lib/generators/active_recall/active_recall_generator.rb +1 -3
- metadata +24 -27
- data/.travis.yml +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 45416341e36349534f31c031163739ad2c68da6141239c1429a3218900cc8882
|
4
|
+
data.tar.gz: 20e7473dab6cec259e94e9aa146e8429c2f8f6e4dcb7ba79da81e283f18bd172
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b17e1c048223c597767b5e411e70ce308126fff101e2879da81481b94207236cf2410b26f8cd4b3efacdbd500f3d5088d0ead858a62d2924e728c445ef4b15b8
|
7
|
+
data.tar.gz: aea8f7d8a27454d2f120f30d10c6fca12ba951c2a56ed5a23f26bd99b39b60f9250edcacd72939c3b59b9bc43f24e224e32f10364f9973a18ad2471760779f8c
|
@@ -0,0 +1,46 @@
|
|
1
|
+
name: Tests
|
2
|
+
|
3
|
+
on:
|
4
|
+
pull_request:
|
5
|
+
branches:
|
6
|
+
- master
|
7
|
+
push:
|
8
|
+
branches:
|
9
|
+
- master
|
10
|
+
|
11
|
+
jobs:
|
12
|
+
unit_tests:
|
13
|
+
name: Unit Tests
|
14
|
+
if: "contains(github.event.commits[0].message, '[ci skip]') == false"
|
15
|
+
strategy:
|
16
|
+
fail-fast: false
|
17
|
+
matrix:
|
18
|
+
os:
|
19
|
+
- macos
|
20
|
+
- ubuntu
|
21
|
+
ruby:
|
22
|
+
- 2.5
|
23
|
+
- 2.6
|
24
|
+
- 2.7
|
25
|
+
- 3.0
|
26
|
+
allow_failures:
|
27
|
+
- false
|
28
|
+
include:
|
29
|
+
- os: ubuntu
|
30
|
+
ruby: ruby-head
|
31
|
+
allow_failures: false
|
32
|
+
env:
|
33
|
+
BUNDLE_GEMFILE: "${{ matrix.gemfile }}"
|
34
|
+
ALLOW_FAILURES: "${{ matrix.allow_failures }}"
|
35
|
+
runs-on: ${{ matrix.os }}-latest
|
36
|
+
continue-on-error: ${{ endsWith(matrix.ruby, 'head') || matrix.ruby == 'debug' }}
|
37
|
+
steps:
|
38
|
+
- name: Checkout
|
39
|
+
uses: actions/checkout@v2
|
40
|
+
- name: Setup Ruby
|
41
|
+
uses: ruby/setup-ruby@v1
|
42
|
+
with:
|
43
|
+
ruby-version: ${{ matrix.ruby }}
|
44
|
+
bundler-cache: true
|
45
|
+
- name: Test
|
46
|
+
run: bundle exec rake spec || $ALLOW_FAILURES
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
3.0.0
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,30 +1,30 @@
|
|
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.6.2)
|
5
|
+
activerecord (>= 5.2.3, <= 6.2)
|
6
|
+
activesupport (>= 5.2.3, <= 6.2)
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
-
activemodel (6.
|
12
|
-
activesupport (= 6.
|
13
|
-
activerecord (6.
|
14
|
-
activemodel (= 6.
|
15
|
-
activesupport (= 6.
|
16
|
-
activesupport (6.
|
11
|
+
activemodel (6.1.3)
|
12
|
+
activesupport (= 6.1.3)
|
13
|
+
activerecord (6.1.3)
|
14
|
+
activemodel (= 6.1.3)
|
15
|
+
activesupport (= 6.1.3)
|
16
|
+
activesupport (6.1.3)
|
17
17
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
18
|
-
i18n (>=
|
19
|
-
minitest (
|
20
|
-
tzinfo (~>
|
21
|
-
zeitwerk (~> 2.
|
22
|
-
concurrent-ruby (1.1.
|
18
|
+
i18n (>= 1.6, < 2)
|
19
|
+
minitest (>= 5.1)
|
20
|
+
tzinfo (~> 2.0)
|
21
|
+
zeitwerk (~> 2.3)
|
22
|
+
concurrent-ruby (1.1.8)
|
23
23
|
diff-lcs (1.3)
|
24
|
-
i18n (1.
|
24
|
+
i18n (1.8.9)
|
25
25
|
concurrent-ruby (~> 1.0)
|
26
|
-
minitest (5.
|
27
|
-
rake (
|
26
|
+
minitest (5.14.4)
|
27
|
+
rake (12.3.3)
|
28
28
|
rdoc (6.2.0)
|
29
29
|
rspec (3.8.0)
|
30
30
|
rspec-core (~> 3.8.0)
|
@@ -39,25 +39,20 @@ GEM
|
|
39
39
|
diff-lcs (>= 1.2.0, < 2.0)
|
40
40
|
rspec-support (~> 3.8.0)
|
41
41
|
rspec-support (3.8.2)
|
42
|
-
sqlite3 (1.4.
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
zeitwerk (2.2.2)
|
42
|
+
sqlite3 (1.4.2)
|
43
|
+
tzinfo (2.0.4)
|
44
|
+
concurrent-ruby (~> 1.0)
|
45
|
+
zeitwerk (2.4.2)
|
47
46
|
|
48
47
|
PLATFORMS
|
49
48
|
ruby
|
50
49
|
|
51
50
|
DEPENDENCIES
|
52
51
|
active_recall!
|
53
|
-
|
54
|
-
rake (~> 10.0)
|
52
|
+
rake (>= 12.0)
|
55
53
|
rdoc
|
56
|
-
rspec (
|
54
|
+
rspec (>= 3.0)
|
57
55
|
sqlite3
|
58
56
|
|
59
|
-
RUBY VERSION
|
60
|
-
ruby 2.5.3p105
|
61
|
-
|
62
57
|
BUNDLED WITH
|
63
|
-
|
58
|
+
2.2.3
|
data/README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
# ActiveRecall
|
1
|
+
# ActiveRecall
|
2
2
|
|
3
3
|
**ActiveRecall** is a spaced-repetition system that allows you to treat arbitrary [ActiveRecord](https://github.com/rails/rails/tree/master/activerecord) models as if they were flashcards to be learned and reviewed.
|
4
4
|
It it based on, and is intended to be backwards compatible with, the [okubo](https://github.com/rgravina/okubo) gem.
|
5
|
-
The primary differentiating features are that it lets the user specify the scheduling algorithm and is fully compatible with Rails 6.
|
5
|
+
The primary differentiating features are that it lets the user specify the scheduling algorithm and is fully compatible with Rails 6.0 (and 6.1) and Ruby 3.0.
|
6
6
|
|
7
7
|
## Installation
|
8
8
|
|
@@ -116,9 +116,12 @@ user.words.next #=> nil
|
|
116
116
|
|
117
117
|
## Development
|
118
118
|
|
119
|
-
After checking out the repo, run `bin/setup` to install dependencies.
|
119
|
+
After checking out the repo, run `bin/setup` to install dependencies.
|
120
|
+
Then, run `rake spec` to run the tests.
|
121
|
+
You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
120
122
|
|
121
|
-
To install this gem onto your local machine, run `bundle exec rake install`.
|
123
|
+
To install this gem onto your local machine, run `bundle exec rake install`.
|
124
|
+
To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
122
125
|
|
123
126
|
## Contributing
|
124
127
|
|
data/active_recall.gemspec
CHANGED
@@ -32,11 +32,10 @@ Gem::Specification.new do |spec|
|
|
32
32
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
33
33
|
spec.require_paths = ['lib']
|
34
34
|
|
35
|
-
spec.add_development_dependency '
|
36
|
-
spec.add_development_dependency 'rake', '~> 10.0'
|
35
|
+
spec.add_development_dependency 'rake', '>= 12.0'
|
37
36
|
spec.add_development_dependency 'rdoc'
|
38
|
-
spec.add_development_dependency 'rspec', '
|
37
|
+
spec.add_development_dependency 'rspec', '>= 3.0'
|
39
38
|
spec.add_development_dependency 'sqlite3'
|
40
|
-
spec.add_runtime_dependency 'activerecord', '>= 5.2.3'
|
41
|
-
spec.add_runtime_dependency 'activesupport', '>= 5.2.3'
|
39
|
+
spec.add_runtime_dependency 'activerecord', '>= 5.2.3', '<= 6.2'
|
40
|
+
spec.add_runtime_dependency 'activesupport', '>= 5.2.3', '<= 6.2'
|
42
41
|
end
|
data/lib/active_recall.rb
CHANGED
@@ -10,7 +10,7 @@ require 'active_recall/models/deck'
|
|
10
10
|
require 'active_recall/models/item'
|
11
11
|
require 'active_recall/version'
|
12
12
|
|
13
|
-
ActiveRecord::Base.
|
13
|
+
ActiveRecord::Base.include ActiveRecall::Base
|
14
14
|
|
15
15
|
module ActiveRecall
|
16
16
|
class << self
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module ActiveRecall
|
4
4
|
class FibonacciSequence
|
5
|
-
def self.right(box:, current_time: Time.current
|
5
|
+
def self.right(box:, times_right:, times_wrong:, current_time: Time.current)
|
6
6
|
new(
|
7
7
|
box: box,
|
8
8
|
current_time: current_time,
|
@@ -11,7 +11,7 @@ module ActiveRecall
|
|
11
11
|
).right
|
12
12
|
end
|
13
13
|
|
14
|
-
def self.wrong(box:, current_time: Time.current
|
14
|
+
def self.wrong(box:, times_right:, times_wrong:, current_time: Time.current)
|
15
15
|
new(
|
16
16
|
box: box,
|
17
17
|
current_time: current_time,
|
@@ -20,7 +20,7 @@ module ActiveRecall
|
|
20
20
|
).wrong
|
21
21
|
end
|
22
22
|
|
23
|
-
def initialize(box:, current_time: Time.current
|
23
|
+
def initialize(box:, times_right:, times_wrong:, current_time: Time.current)
|
24
24
|
@box = box
|
25
25
|
@current_time = current_time
|
26
26
|
@times_right = times_right
|
@@ -4,7 +4,7 @@ module ActiveRecall
|
|
4
4
|
class LeitnerSystem
|
5
5
|
DELAYS = [3, 7, 14, 30, 60, 120, 240].freeze
|
6
6
|
|
7
|
-
def self.right(box:, current_time: Time.current
|
7
|
+
def self.right(box:, times_right:, times_wrong:, current_time: Time.current)
|
8
8
|
new(
|
9
9
|
box: box,
|
10
10
|
current_time: current_time,
|
@@ -13,7 +13,7 @@ module ActiveRecall
|
|
13
13
|
).right
|
14
14
|
end
|
15
15
|
|
16
|
-
def self.wrong(box:, current_time: Time.current
|
16
|
+
def self.wrong(box:, times_right:, times_wrong:, current_time: Time.current)
|
17
17
|
new(
|
18
18
|
box: box,
|
19
19
|
current_time: current_time,
|
@@ -22,7 +22,7 @@ module ActiveRecall
|
|
22
22
|
).wrong
|
23
23
|
end
|
24
24
|
|
25
|
-
def initialize(box:, current_time: Time.current
|
25
|
+
def initialize(box:, times_right:, times_wrong:, current_time: Time.current)
|
26
26
|
@box = box
|
27
27
|
@current_time = current_time
|
28
28
|
@times_right = times_right
|
@@ -3,10 +3,10 @@
|
|
3
3
|
module ActiveRecall
|
4
4
|
module DeckMethods
|
5
5
|
def deck
|
6
|
-
d = ActiveRecall::Deck.
|
6
|
+
d = ActiveRecall::Deck.find_or_create_by(user_id: id, user_type: self.class.name)
|
7
7
|
d.source_class.module_eval do
|
8
8
|
def stats
|
9
|
-
ActiveRecall::Item.
|
9
|
+
ActiveRecall::Item.find_by(source_id: id, source_type: self.class.name)
|
10
10
|
end
|
11
11
|
end
|
12
12
|
d
|
@@ -3,15 +3,11 @@
|
|
3
3
|
module ActiveRecall
|
4
4
|
module ItemMethods
|
5
5
|
def right_answer_for!(item)
|
6
|
-
|
7
|
-
i.right!
|
8
|
-
i.save!
|
6
|
+
deck.items.find_by(source_id: item.id).right!
|
9
7
|
end
|
10
8
|
|
11
9
|
def wrong_answer_for!(item)
|
12
|
-
|
13
|
-
i.wrong!
|
14
|
-
i.save!
|
10
|
+
deck.items.find_by(source_id: item.id).wrong!
|
15
11
|
end
|
16
12
|
end
|
17
13
|
end
|
@@ -37,16 +37,19 @@ module ActiveRecall
|
|
37
37
|
end
|
38
38
|
|
39
39
|
def delete(source)
|
40
|
-
|
41
|
-
|
40
|
+
ActiveRecall::Item
|
41
|
+
.find_by(deck: self, source_id: source.id, source_type: source.class.name)
|
42
|
+
.destroy
|
42
43
|
end
|
43
44
|
|
45
|
+
# OPTIMIZE: Attempt in active record, rather than array of Ruby records
|
44
46
|
def review
|
45
47
|
%i[untested failed expired].inject([]) do |words, s|
|
46
48
|
words += items.send(s).order(random_order_function).map(&:source)
|
47
49
|
end
|
48
50
|
end
|
49
51
|
|
52
|
+
# OPTIMIZE: Use optimized #review and build only the record to be returned
|
50
53
|
def next
|
51
54
|
word = nil
|
52
55
|
%i[untested failed expired].each do |category|
|
@@ -22,11 +22,11 @@ module ActiveRecall
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def right!
|
25
|
-
update!(algorithm_class.right(scoring_attributes))
|
25
|
+
update!(algorithm_class.right(**scoring_attributes))
|
26
26
|
end
|
27
27
|
|
28
28
|
def wrong!
|
29
|
-
update!(algorithm_class.wrong(scoring_attributes))
|
29
|
+
update!(algorithm_class.wrong(**scoring_attributes))
|
30
30
|
end
|
31
31
|
|
32
32
|
private
|
@@ -20,9 +20,7 @@ class ActiveRecallGenerator < Rails::Generators::Base
|
|
20
20
|
def create_migration_files
|
21
21
|
create_migration_file_if_not_exist 'create_active_recall_tables'
|
22
22
|
create_migration_file_if_not_exist 'add_active_recall_item_answer_counts'
|
23
|
-
if options['migrate_data']
|
24
|
-
create_migration_file_if_not_exist 'migrate_okubo_to_active_recall'
|
25
|
-
end
|
23
|
+
create_migration_file_if_not_exist 'migrate_okubo_to_active_recall' if options['migrate_data']
|
26
24
|
end
|
27
25
|
|
28
26
|
private
|
metadata
CHANGED
@@ -1,44 +1,30 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_recall
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.6.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Gravina
|
8
8
|
- Jayson Virissimo
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2021-03-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
|
-
name:
|
15
|
+
name: rake
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
18
|
- - ">="
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: '
|
20
|
+
version: '12.0'
|
21
21
|
type: :development
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
25
|
- - ">="
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version: '
|
28
|
-
- !ruby/object:Gem::Dependency
|
29
|
-
name: rake
|
30
|
-
requirement: !ruby/object:Gem::Requirement
|
31
|
-
requirements:
|
32
|
-
- - "~>"
|
33
|
-
- !ruby/object:Gem::Version
|
34
|
-
version: '10.0'
|
35
|
-
type: :development
|
36
|
-
prerelease: false
|
37
|
-
version_requirements: !ruby/object:Gem::Requirement
|
38
|
-
requirements:
|
39
|
-
- - "~>"
|
40
|
-
- !ruby/object:Gem::Version
|
41
|
-
version: '10.0'
|
27
|
+
version: '12.0'
|
42
28
|
- !ruby/object:Gem::Dependency
|
43
29
|
name: rdoc
|
44
30
|
requirement: !ruby/object:Gem::Requirement
|
@@ -57,14 +43,14 @@ dependencies:
|
|
57
43
|
name: rspec
|
58
44
|
requirement: !ruby/object:Gem::Requirement
|
59
45
|
requirements:
|
60
|
-
- - "
|
46
|
+
- - ">="
|
61
47
|
- !ruby/object:Gem::Version
|
62
48
|
version: '3.0'
|
63
49
|
type: :development
|
64
50
|
prerelease: false
|
65
51
|
version_requirements: !ruby/object:Gem::Requirement
|
66
52
|
requirements:
|
67
|
-
- - "
|
53
|
+
- - ">="
|
68
54
|
- !ruby/object:Gem::Version
|
69
55
|
version: '3.0'
|
70
56
|
- !ruby/object:Gem::Dependency
|
@@ -88,6 +74,9 @@ dependencies:
|
|
88
74
|
- - ">="
|
89
75
|
- !ruby/object:Gem::Version
|
90
76
|
version: 5.2.3
|
77
|
+
- - "<="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '6.2'
|
91
80
|
type: :runtime
|
92
81
|
prerelease: false
|
93
82
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -95,6 +84,9 @@ dependencies:
|
|
95
84
|
- - ">="
|
96
85
|
- !ruby/object:Gem::Version
|
97
86
|
version: 5.2.3
|
87
|
+
- - "<="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '6.2'
|
98
90
|
- !ruby/object:Gem::Dependency
|
99
91
|
name: activesupport
|
100
92
|
requirement: !ruby/object:Gem::Requirement
|
@@ -102,6 +94,9 @@ dependencies:
|
|
102
94
|
- - ">="
|
103
95
|
- !ruby/object:Gem::Version
|
104
96
|
version: 5.2.3
|
97
|
+
- - "<="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '6.2'
|
105
100
|
type: :runtime
|
106
101
|
prerelease: false
|
107
102
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -109,6 +104,9 @@ dependencies:
|
|
109
104
|
- - ">="
|
110
105
|
- !ruby/object:Gem::Version
|
111
106
|
version: 5.2.3
|
107
|
+
- - "<="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '6.2'
|
112
110
|
description: A spaced-repetition system to be used with ActiveRecord models
|
113
111
|
email:
|
114
112
|
- robert.gravina@gmail.com
|
@@ -117,10 +115,10 @@ executables: []
|
|
117
115
|
extensions: []
|
118
116
|
extra_rdoc_files: []
|
119
117
|
files:
|
118
|
+
- ".github/workflows/tests.yml"
|
120
119
|
- ".gitignore"
|
121
120
|
- ".rspec"
|
122
121
|
- ".ruby-version"
|
123
|
-
- ".travis.yml"
|
124
122
|
- Gemfile
|
125
123
|
- Gemfile.lock
|
126
124
|
- LICENSE
|
@@ -148,7 +146,7 @@ licenses:
|
|
148
146
|
- MIT
|
149
147
|
metadata:
|
150
148
|
allowed_push_host: https://rubygems.org/
|
151
|
-
post_install_message:
|
149
|
+
post_install_message:
|
152
150
|
rdoc_options: []
|
153
151
|
require_paths:
|
154
152
|
- lib
|
@@ -163,9 +161,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
163
161
|
- !ruby/object:Gem::Version
|
164
162
|
version: '0'
|
165
163
|
requirements: []
|
166
|
-
|
167
|
-
|
168
|
-
signing_key:
|
164
|
+
rubygems_version: 3.2.3
|
165
|
+
signing_key:
|
169
166
|
specification_version: 4
|
170
167
|
summary: A spaced-repetition system
|
171
168
|
test_files: []
|