acts_as_learnable 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +2 -9
- data/Rakefile +1 -0
- data/acts_as_learnable.gemspec +11 -11
- data/lib/acts_as_learnable/base.rb +2 -3
- data/lib/acts_as_learnable/version.rb +1 -1
- data/lib/acts_as_learnable.rb +1 -4
- data/lib/generators/flashcard/flashcard_generator.rb +9 -6
- data/lib/generators/flashcard/templates/add_fields_migration.rb +5 -13
- data/lib/generators/flashcard/templates/create_table_migration.rb +7 -11
- data/test/test_helper.rb +1 -1
- metadata +32 -33
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 6e65eaf9f25b641df9f9377c40997cadfeec15a64d28686c84ae1c1cb37d44e8
|
4
|
+
data.tar.gz: 5b76d804d68b1e557580b044cd56e93866aa5720544c5867b68be9ded5fd9a45
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fd561ac48b1c65675addbda453947414e7d063a2d1defc67fbf096658626334576dc36cdb0b125d8ce3b282eb2c918c98649bb260496d07d419c7a418bfe0db1
|
7
|
+
data.tar.gz: 8548a28b5433b4a7a7f0c1bac89377026a9cdcc94b43747ce631e01463fb04062c002f491100d3f58f9b89c37a4bb649a4baaec5ad5b9e5ffed39cc30dcffeeb
|
data/README.md
CHANGED
@@ -35,9 +35,7 @@ end
|
|
35
35
|
|
36
36
|
It will automatically extend your class with all necessary methods.
|
37
37
|
|
38
|
-
|
39
|
-
|
40
|
-
Then you can review items:
|
38
|
+
Then you can review flashcards:
|
41
39
|
|
42
40
|
```ruby
|
43
41
|
card = Flashcard.create
|
@@ -51,13 +49,8 @@ card.repetitions # => 1
|
|
51
49
|
|
52
50
|
## Contributing
|
53
51
|
|
54
|
-
1. Fork it ( https://github.com/
|
52
|
+
1. Fork it ( https://github.com/dankimio/acts_as_learnable/fork )
|
55
53
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
56
54
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
57
55
|
4. Push to the branch (`git push origin my-new-feature`)
|
58
56
|
5. Create a new Pull Request
|
59
|
-
|
60
|
-
## TODO
|
61
|
-
|
62
|
-
* More detailed README
|
63
|
-
* Other repetition algorithms (Anki)
|
data/Rakefile
CHANGED
data/acts_as_learnable.gemspec
CHANGED
@@ -6,23 +6,23 @@ require 'acts_as_learnable/version'
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = 'acts_as_learnable'
|
8
8
|
spec.version = ActsAsLearnable::VERSION
|
9
|
-
spec.authors = ['
|
10
|
-
spec.email = [
|
9
|
+
spec.authors = ['Dan Kim']
|
10
|
+
spec.email = ['itsdanya@gmail.com']
|
11
11
|
spec.summary = 'A simple way to create flashcards in your app.'
|
12
12
|
spec.description = 'ActsAsLearnable is a Ruby gem for ActiveRecord models. It provides a simple way to create flashcards in your app. It automatically schedules flashcards for review depending on recall quality (1 to 5). You can easily create a Spaced Repetition System (SRS) using this gem.'
|
13
|
-
spec.homepage = '
|
14
|
-
spec.license =
|
13
|
+
spec.homepage = 'https://github.com/itsdn/acts_as_learnable'
|
14
|
+
spec.license = 'MIT'
|
15
15
|
|
16
16
|
spec.files = `git ls-files -z`.split("\x0")
|
17
17
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test)/})
|
19
|
-
spec.require_paths = [
|
19
|
+
spec.require_paths = ['lib']
|
20
20
|
|
21
|
-
spec.add_dependency 'activerecord', '
|
22
|
-
spec.add_dependency 'activesupport', '
|
21
|
+
spec.add_dependency 'activerecord', '>= 5.2'
|
22
|
+
spec.add_dependency 'activesupport', '>= 5.2'
|
23
23
|
|
24
|
-
spec.add_development_dependency 'bundler'
|
25
|
-
spec.add_development_dependency 'rake'
|
26
|
-
spec.add_development_dependency 'sqlite3'
|
27
|
-
spec.add_development_dependency 'byebug'
|
24
|
+
spec.add_development_dependency 'bundler'
|
25
|
+
spec.add_development_dependency 'rake'
|
26
|
+
spec.add_development_dependency 'sqlite3'
|
27
|
+
spec.add_development_dependency 'byebug'
|
28
28
|
end
|
@@ -15,7 +15,7 @@ module ActsAsLearnable
|
|
15
15
|
|
16
16
|
module InstanceMethods
|
17
17
|
def review(recall_quality)
|
18
|
-
|
18
|
+
raise unless (1..5).include?(recall_quality)
|
19
19
|
|
20
20
|
# If the quality of response was lower than 3, then start repetitions from the beginning
|
21
21
|
reset and return if recall_quality <= 2
|
@@ -65,13 +65,12 @@ module ActsAsLearnable
|
|
65
65
|
|
66
66
|
# Update interval according to the formula
|
67
67
|
def update_interval
|
68
|
-
# TODO: Extract magic numbers
|
69
68
|
self.interval =
|
70
69
|
case repetitions
|
71
70
|
when 1 then 1
|
72
71
|
when 2 then 6
|
73
72
|
else
|
74
|
-
|
73
|
+
(repetitions - 1) * easiness_factor
|
75
74
|
end
|
76
75
|
end
|
77
76
|
|
data/lib/acts_as_learnable.rb
CHANGED
@@ -1,10 +1,7 @@
|
|
1
1
|
require 'active_record'
|
2
2
|
require 'acts_as_learnable/base'
|
3
|
-
require 'byebug'
|
4
3
|
|
5
4
|
module ActsAsLearnable
|
6
5
|
# Extend ActiveRecord if defined
|
7
|
-
if defined?(ActiveRecord::Base)
|
8
|
-
ActiveRecord::Base.extend(ActsAsLearnable::Base)
|
9
|
-
end
|
6
|
+
ActiveRecord::Base.extend(ActsAsLearnable::Base) if defined?(ActiveRecord::Base)
|
10
7
|
end
|
@@ -6,16 +6,19 @@ class FlashcardGenerator < ActiveRecord::Generators::Base
|
|
6
6
|
|
7
7
|
desc 'This generator creates a migration file with flashcard fields.'
|
8
8
|
|
9
|
-
source_root File.expand_path('
|
9
|
+
source_root File.expand_path('templates', __dir__)
|
10
10
|
|
11
11
|
def install_flashcards
|
12
|
-
if File.
|
13
|
-
|
14
|
-
migration_template(
|
15
|
-
'add_fields_migration.rb',
|
16
|
-
"db/migrate/add_flashcard_fields_to_#{table_name}.rb")
|
12
|
+
if schema_exists? && File.read("#{destination_root}/db/schema.rb") =~ /create_table "#{table_name}"/
|
13
|
+
migration_template('add_fields_migration.rb', "db/migrate/add_flashcard_fields_to_#{table_name}.rb")
|
17
14
|
else
|
18
15
|
migration_template('create_table_migration.rb', "db/migrate/create_#{table_name}.rb")
|
19
16
|
end
|
20
17
|
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def schema_exists?
|
22
|
+
File.exist?("#{destination_root}/db/schema.rb")
|
23
|
+
end
|
21
24
|
end
|
@@ -1,17 +1,9 @@
|
|
1
1
|
class <%= @migration_class_name %> < ActiveRecord::Migration
|
2
|
-
def
|
2
|
+
def change
|
3
3
|
add_column :<%= table_name %>, :easiness_factor, :float, default: 2.5
|
4
|
-
add_column :<%= table_name %>, :repetitions,
|
5
|
-
add_column :<%= table_name %>, :interval,
|
6
|
-
add_column :<%= table_name %>, :due,
|
7
|
-
add_column :<%= table_name %>, :studied_at,
|
8
|
-
end
|
9
|
-
|
10
|
-
def self.down
|
11
|
-
remove_column :<%= table_name %>, :easiness_factor
|
12
|
-
remove_column :<%= table_name %>, :repetitions
|
13
|
-
remove_column :<%= table_name %>, :interval
|
14
|
-
remove_column :<%= table_name %>, :due
|
15
|
-
remove_column :<%= table_name %>, :studied_at
|
4
|
+
add_column :<%= table_name %>, :repetitions, :integer, default: 0
|
5
|
+
add_column :<%= table_name %>, :interval, :integer, default: 0
|
6
|
+
add_column :<%= table_name %>, :due, :date, default: nil
|
7
|
+
add_column :<%= table_name %>, :studied_at, :date, default: nil
|
16
8
|
end
|
17
9
|
end
|
@@ -1,15 +1,11 @@
|
|
1
1
|
class <%= @migration_class_name %> < ActiveRecord::Migration
|
2
|
-
def
|
3
|
-
create_table
|
4
|
-
t.column :easiness_factor, :float,
|
5
|
-
t.column :repetitions,
|
6
|
-
t.column :interval,
|
7
|
-
t.column :due,
|
8
|
-
t.column :studied_at,
|
2
|
+
def change
|
3
|
+
create_table :<%= table_name %> do |t|
|
4
|
+
t.column :easiness_factor, :float, default: 2.5
|
5
|
+
t.column :repetitions, :integer, default: 0
|
6
|
+
t.column :interval, :integer, default: 0
|
7
|
+
t.column :due, :date, default: nil
|
8
|
+
t.column :studied_at, :date, default: nil
|
9
9
|
end
|
10
10
|
end
|
11
|
-
|
12
|
-
def self.down
|
13
|
-
drop_table '<%= table_name %>'
|
14
|
-
end
|
15
11
|
end
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,99 +1,99 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acts_as_learnable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
8
|
-
autorequire:
|
7
|
+
- Dan Kim
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-07-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '5.2'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '5.2'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: activesupport
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '5.2'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '5.2'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rake
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: sqlite3
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - "
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
75
|
+
version: '0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - "
|
80
|
+
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
82
|
+
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: byebug
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - "
|
87
|
+
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
89
|
+
version: '0'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- - "
|
94
|
+
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
96
|
+
version: '0'
|
97
97
|
description: ActsAsLearnable is a Ruby gem for ActiveRecord models. It provides a
|
98
98
|
simple way to create flashcards in your app. It automatically schedules flashcards
|
99
99
|
for review depending on recall quality (1 to 5). You can easily create a Spaced
|
@@ -118,11 +118,11 @@ files:
|
|
118
118
|
- lib/generators/flashcard/templates/create_table_migration.rb
|
119
119
|
- test/test_base.rb
|
120
120
|
- test/test_helper.rb
|
121
|
-
homepage:
|
121
|
+
homepage: https://github.com/itsdn/acts_as_learnable
|
122
122
|
licenses:
|
123
123
|
- MIT
|
124
124
|
metadata: {}
|
125
|
-
post_install_message:
|
125
|
+
post_install_message:
|
126
126
|
rdoc_options: []
|
127
127
|
require_paths:
|
128
128
|
- lib
|
@@ -137,9 +137,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: '0'
|
139
139
|
requirements: []
|
140
|
-
|
141
|
-
|
142
|
-
signing_key:
|
140
|
+
rubygems_version: 3.3.7
|
141
|
+
signing_key:
|
143
142
|
specification_version: 4
|
144
143
|
summary: A simple way to create flashcards in your app.
|
145
144
|
test_files:
|