repetition 1.0.1 → 1.0.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/.gitignore +17 -0
- data/Gemfile +4 -0
- data/README.md +70 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/repetition.rb +13 -9
- data/lib/repetition/version.rb +3 -0
- data/repetition.gemspec +25 -0
- metadata +49 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bab3c51f0e4592dd7fc82d9731b58a0fd323ca80
|
4
|
+
data.tar.gz: 524371c1e719cf976ca4986fb3aefed473565725
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0a3cbbabf457be18665be1c8f52f1867d109711f8c740e5ada8df8339dd74eca10c5189346cae00241793611d26582201c8f6f4da31c5d6c48f2947f33cbbe88
|
7
|
+
data.tar.gz: 813ad91b742549a0c9c9478cfaf7b0f9082032440919c1b3c7745040bd89f2bc62e1dc70619c44103cfa2293a64f4b11a97a121aa69565e3c2a83472f11e610e
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
# Repetition gem
|
2
|
+
Spaced repetition module which can be used as a mixin in Ruby apps. SuperMemo 2 is used as a repetition algorithm.
|
3
|
+
|
4
|
+
### Installation
|
5
|
+
Add to your Gemfile
|
6
|
+
|
7
|
+
gem 'repetition'
|
8
|
+
|
9
|
+
or install from RubyGems
|
10
|
+
|
11
|
+
gem install repetition
|
12
|
+
|
13
|
+
|
14
|
+
### Rails
|
15
|
+
|
16
|
+
Create a migration to add the new fields to your model.
|
17
|
+
```ruby
|
18
|
+
change_table :cards do |t|
|
19
|
+
t.decimal :easiness_factor, precision: 2, scale: 1, default: 2.5, null: false
|
20
|
+
t.integer :number_repetitions, default: 0, null: false
|
21
|
+
t.integer :quality_of_last_recall
|
22
|
+
t.date :next_repetition
|
23
|
+
t.integer :repetition_interval
|
24
|
+
t.date :last_studied
|
25
|
+
end
|
26
|
+
```
|
27
|
+
|
28
|
+
### Usage
|
29
|
+
Include module in your class or ActiveRecord model
|
30
|
+
```ruby
|
31
|
+
class Card < ActiveRecord::Base
|
32
|
+
# some code
|
33
|
+
include Repetition
|
34
|
+
end
|
35
|
+
```
|
36
|
+
|
37
|
+
This will add a bunch of properties to your model:
|
38
|
+
* easyness_factor
|
39
|
+
* number_repetitions
|
40
|
+
* quality_of_last_recall
|
41
|
+
* next_repetition
|
42
|
+
* repetition_interval
|
43
|
+
* last_studied
|
44
|
+
|
45
|
+
Make sure that appropriate fields are created in your database using migrations
|
46
|
+
|
47
|
+
You can now use all methods that are provided by gem, use `process_recall_result(quality)` method to update next repetition date. Method takes one argument which should be integer in range from 0 to 5 (0 - again, 5 - perfect).
|
48
|
+
```ruby
|
49
|
+
card = Card.first
|
50
|
+
card.reset_spaced_repetition_data # Reset data for first use
|
51
|
+
|
52
|
+
card.next_repetition # => nil
|
53
|
+
card.process_recall_result(4)
|
54
|
+
|
55
|
+
card.repetition_interval # => 1
|
56
|
+
card.next_repetition # Tomorrow
|
57
|
+
card.save # Don't forget to save your card!
|
58
|
+
```
|
59
|
+
|
60
|
+
### Changelog
|
61
|
+
#### 1.0
|
62
|
+
* Initial version
|
63
|
+
|
64
|
+
### Running Specs
|
65
|
+
|
66
|
+
`bundle exec rake`
|
67
|
+
|
68
|
+
### Contributing
|
69
|
+
Contributions are welcome! Feel free to post issues and create pull requests.
|
70
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "repetition"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/lib/repetition.rb
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
require 'repetition/version'
|
2
|
+
|
3
|
+
require 'date'
|
4
|
+
|
1
5
|
module Repetition
|
2
6
|
def reset_spaced_repetition_data
|
3
7
|
self.easiness_factor = 2.5
|
@@ -10,15 +14,15 @@ module Repetition
|
|
10
14
|
|
11
15
|
def process_recall_result(quality_of_recall)
|
12
16
|
unless (1..5).include?(quality_of_recall)
|
13
|
-
raise 'Invalid quality of recall. Should be in range from
|
17
|
+
raise 'Invalid quality of recall. Should be in range from 1 to 5.'
|
14
18
|
end
|
15
|
-
|
19
|
+
|
16
20
|
if quality_of_recall < 3
|
17
|
-
self.number_repetitions = 0
|
21
|
+
self.number_repetitions = 0
|
18
22
|
self.repetition_interval = 0
|
19
23
|
else
|
20
24
|
self.easiness_factor = calculate_easiness_factor(easiness_factor, quality_of_recall)
|
21
|
-
|
25
|
+
|
22
26
|
if quality_of_recall == 3
|
23
27
|
self.repetition_interval = 0
|
24
28
|
else
|
@@ -34,7 +38,7 @@ module Repetition
|
|
34
38
|
end
|
35
39
|
end
|
36
40
|
end
|
37
|
-
|
41
|
+
|
38
42
|
self.next_repetition = Date.today + repetition_interval
|
39
43
|
self.last_studied = Date.today
|
40
44
|
end
|
@@ -42,9 +46,9 @@ module Repetition
|
|
42
46
|
def scheduled_to_recall?
|
43
47
|
!next_repetition.nil? && next_repetition <= Date.today
|
44
48
|
end
|
45
|
-
|
46
|
-
private
|
47
|
-
|
49
|
+
|
50
|
+
private
|
51
|
+
|
48
52
|
def calculate_easiness_factor(easiness_factor, quality_of_recall)
|
49
53
|
q = quality_of_recall
|
50
54
|
ef_old = easiness_factor
|
@@ -52,4 +56,4 @@ module Repetition
|
|
52
56
|
result = ef_old - 0.8 + (0.28 * q) - (0.02 * q * q)
|
53
57
|
result < 1.3 ? 1.3 : result
|
54
58
|
end
|
55
|
-
end
|
59
|
+
end
|
data/repetition.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'repetition/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "repetition"
|
8
|
+
spec.version = Repetition::VERSION
|
9
|
+
spec.authors = ["Dan Kim"]
|
10
|
+
spec.email = ["itsdanya@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Spaced repetition algorithm}
|
13
|
+
spec.description = %q{Spaced repetition algorithm module that can be used as a mixin in Ruby apps}
|
14
|
+
spec.homepage = "http://github.com/danyakim/repetition"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = "exe"
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.13"
|
23
|
+
spec.add_development_dependency "rake", "~> 11.0"
|
24
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
25
|
+
end
|
metadata
CHANGED
@@ -1,37 +1,74 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: repetition
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- Dan Kim
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-04-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.13'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.13'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '11.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '11.0'
|
13
41
|
- !ruby/object:Gem::Dependency
|
14
42
|
name: rspec
|
15
43
|
requirement: !ruby/object:Gem::Requirement
|
16
44
|
requirements:
|
17
|
-
- - "
|
45
|
+
- - "~>"
|
18
46
|
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
47
|
+
version: '3.0'
|
20
48
|
type: :development
|
21
49
|
prerelease: false
|
22
50
|
version_requirements: !ruby/object:Gem::Requirement
|
23
51
|
requirements:
|
24
|
-
- - "
|
52
|
+
- - "~>"
|
25
53
|
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
27
|
-
description: Spaced repetition algorithm
|
28
|
-
|
29
|
-
email:
|
54
|
+
version: '3.0'
|
55
|
+
description: Spaced repetition algorithm module that can be used as a mixin in Ruby
|
56
|
+
apps
|
57
|
+
email:
|
58
|
+
- itsdanya@gmail.com
|
30
59
|
executables: []
|
31
60
|
extensions: []
|
32
61
|
extra_rdoc_files: []
|
33
62
|
files:
|
63
|
+
- ".gitignore"
|
64
|
+
- Gemfile
|
65
|
+
- README.md
|
66
|
+
- Rakefile
|
67
|
+
- bin/console
|
68
|
+
- bin/setup
|
34
69
|
- lib/repetition.rb
|
70
|
+
- lib/repetition/version.rb
|
71
|
+
- repetition.gemspec
|
35
72
|
homepage: http://github.com/danyakim/repetition
|
36
73
|
licenses:
|
37
74
|
- MIT
|
@@ -52,7 +89,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
52
89
|
version: '0'
|
53
90
|
requirements: []
|
54
91
|
rubyforge_project:
|
55
|
-
rubygems_version: 2.
|
92
|
+
rubygems_version: 2.6.11
|
56
93
|
signing_key:
|
57
94
|
specification_version: 4
|
58
95
|
summary: Spaced repetition algorithm
|