forgetful 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +21 -0
- data/Manifest +4 -3
- data/README.rdoc +74 -0
- data/bin/forgetful +7 -5
- data/forgetful.gemspec +6 -6
- data/lib/csv_ext/reminder.rb +31 -7
- data/test/test_reminder.rb +128 -0
- data/test/test_reminder_csv.rb +103 -0
- metadata +11 -8
- data/README +0 -51
- data/test/test_forgetful.rb +0 -0
data/MIT-LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
Copyright (c) 2008 Jonathan Palardy
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
data/Manifest
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
bin/forgetful
|
2
2
|
examples/katakana_romanji.csv
|
3
3
|
examples/romanji_katakana.csv
|
4
|
-
forgetful.gemspec
|
5
4
|
lib/csv_ext/reminder.rb
|
6
5
|
lib/forgetful.rb
|
7
6
|
lib/reminder.rb
|
8
7
|
Manifest
|
9
|
-
|
10
|
-
|
8
|
+
MIT-LICENSE
|
9
|
+
README.rdoc
|
10
|
+
test/test_reminder.rb
|
11
|
+
test/test_reminder_csv.rb
|
data/README.rdoc
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
= Forgetful
|
2
|
+
|
3
|
+
A minimal command-line app implementing the SuperMemo 2 algorithm.
|
4
|
+
|
5
|
+
The SuperMemo algorithm is designed to refresh your memory at
|
6
|
+
intervals based on how well you remembered something.
|
7
|
+
|
8
|
+
Put question-answer pairs in a file. Everyday, feed the file to forgetful and
|
9
|
+
it will quiz you on what you need to remember today. Based on your
|
10
|
+
self-evaluation, forgetful will reschedule at an appropriate time in the
|
11
|
+
future.
|
12
|
+
|
13
|
+
|
14
|
+
== Install
|
15
|
+
|
16
|
+
gem install forgetful
|
17
|
+
|
18
|
+
|
19
|
+
== Usage
|
20
|
+
|
21
|
+
forgetful filename.csv [more filenames]
|
22
|
+
|
23
|
+
The CSV files are formatted very simply:
|
24
|
+
|
25
|
+
question,answer
|
26
|
+
|
27
|
+
The interaction goes as follow:
|
28
|
+
|
29
|
+
forgetful: shows question
|
30
|
+
you: press enter
|
31
|
+
forgetful: shows answer
|
32
|
+
forgetful: asks for self-evaluation
|
33
|
+
you: type a number, press enter
|
34
|
+
|
35
|
+
You will be asked all of today's questions. After you will be asked, again, the
|
36
|
+
questions for which you scored less than 4.
|
37
|
+
|
38
|
+
Self-evaluation values:
|
39
|
+
|
40
|
+
5 - perfect response
|
41
|
+
4 - correct response after a hesitation
|
42
|
+
3 - correct response recalled with serious difficulty
|
43
|
+
2 - incorrect response; where the correct one seemed easy to recall
|
44
|
+
1 - incorrect response; the correct one remembered
|
45
|
+
0 - complete blackout.
|
46
|
+
|
47
|
+
WARNING: Statistics are written back to the input file. This is a feature. Put
|
48
|
+
your CSV files under source control to keep a history.
|
49
|
+
|
50
|
+
Enjoy!
|
51
|
+
|
52
|
+
|
53
|
+
== License
|
54
|
+
|
55
|
+
Copyright (c) 2008 Jonathan Palardy
|
56
|
+
|
57
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
58
|
+
a copy of this software and associated documentation files (the
|
59
|
+
"Software"), to deal in the Software without restriction, including
|
60
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
61
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
62
|
+
permit persons to whom the Software is furnished to do so, subject to
|
63
|
+
the following conditions:
|
64
|
+
|
65
|
+
The above copyright notice and this permission notice shall be
|
66
|
+
included in all copies or substantial portions of the Software.
|
67
|
+
|
68
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
69
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
70
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
71
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
72
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
73
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
74
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/bin/forgetful
CHANGED
@@ -25,9 +25,11 @@ end
|
|
25
25
|
#-------------------------------------------------
|
26
26
|
|
27
27
|
def ask_about(reminder, i, n)
|
28
|
-
|
29
|
-
|
30
|
-
|
28
|
+
width = "#{n}/#{n}. ".size
|
29
|
+
padding = " " * width
|
30
|
+
ask "#{i}/#{n}. ".rjust(width) + "Q: #{reminder.question}"
|
31
|
+
puts padding + "A: #{reminder.answer}"
|
32
|
+
q = ask_grade padding + "? "
|
31
33
|
puts
|
32
34
|
return q
|
33
35
|
end
|
@@ -46,14 +48,14 @@ end
|
|
46
48
|
|
47
49
|
def process_file(filename)
|
48
50
|
#--------------------- quiz ----------------------
|
49
|
-
reminders = Reminder.
|
51
|
+
reminders = Reminder.read_csv(filename)
|
50
52
|
|
51
53
|
dues, not_dues = reminders.partition {|reminder| reminder.execute_on <= Date.today}
|
52
54
|
|
53
55
|
puts "### QUIZ: #{filename}"
|
54
56
|
gradeds = quiz(dues.sort_by { rand })
|
55
57
|
|
56
|
-
Reminder.
|
58
|
+
Reminder.write_csv(filename, (gradeds + not_dues).sort)
|
57
59
|
|
58
60
|
#-------------------- review ---------------------
|
59
61
|
faileds = gradeds.select {|reminder| reminder.review? }
|
data/forgetful.gemspec
CHANGED
@@ -1,23 +1,23 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = %q{forgetful}
|
3
|
-
s.version = "0.0.
|
3
|
+
s.version = "0.0.6"
|
4
4
|
|
5
5
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
6
6
|
s.authors = ["Jonathan Palardy"]
|
7
|
-
s.date = %q{2008-11-
|
7
|
+
s.date = %q{2008-11-13}
|
8
8
|
s.default_executable = %q{forgetful}
|
9
9
|
s.description = %q{A minimal command-line implementation of the SuperMemo 2 algorithm.}
|
10
10
|
s.email = %q{jonathan.palardy@gmail.com}
|
11
11
|
s.executables = ["forgetful"]
|
12
|
-
s.extra_rdoc_files = ["bin/forgetful", "lib/csv_ext/reminder.rb", "lib/forgetful.rb", "lib/reminder.rb", "README"]
|
13
|
-
s.files = ["bin/forgetful", "examples/katakana_romanji.csv", "examples/romanji_katakana.csv", "
|
12
|
+
s.extra_rdoc_files = ["bin/forgetful", "lib/csv_ext/reminder.rb", "lib/forgetful.rb", "lib/reminder.rb", "README.rdoc"]
|
13
|
+
s.files = ["bin/forgetful", "examples/katakana_romanji.csv", "examples/romanji_katakana.csv", "lib/csv_ext/reminder.rb", "lib/forgetful.rb", "lib/reminder.rb", "Manifest", "MIT-LICENSE", "README.rdoc", "test/test_reminder.rb", "test/test_reminder_csv.rb", "forgetful.gemspec"]
|
14
14
|
s.homepage = %q{http://github.com/jpalardy/forgetful}
|
15
|
-
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Forgetful", "--main", "README"]
|
15
|
+
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Forgetful", "--main", "README.rdoc"]
|
16
16
|
s.require_paths = ["lib"]
|
17
17
|
s.rubyforge_project = %q{forgetful}
|
18
18
|
s.rubygems_version = %q{1.2.0}
|
19
19
|
s.summary = %q{A minimal command-line implementation of the SuperMemo 2 algorithm.}
|
20
|
-
s.test_files = ["test/
|
20
|
+
s.test_files = ["test/test_reminder.rb", "test/test_reminder_csv.rb"]
|
21
21
|
|
22
22
|
if s.respond_to? :specification_version then
|
23
23
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
data/lib/csv_ext/reminder.rb
CHANGED
@@ -4,19 +4,43 @@ require 'fastercsv'
|
|
4
4
|
|
5
5
|
class Reminder
|
6
6
|
|
7
|
-
def self.
|
8
|
-
|
7
|
+
def self.read_csv(filename)
|
8
|
+
File.open(filename) do |file|
|
9
|
+
self.parse_csv(file)
|
10
|
+
end
|
11
|
+
end
|
9
12
|
|
10
|
-
|
11
|
-
|
13
|
+
def self.parse_csv(io)
|
14
|
+
converters = [lambda {|question| question},
|
15
|
+
lambda {|answer| answer},
|
16
|
+
lambda {|execute_on| Date.parse(execute_on)},
|
17
|
+
lambda {|ef| ef.to_f},
|
18
|
+
lambda {|i| i.to_i},
|
19
|
+
lambda {|interval| interval.to_i},
|
20
|
+
lambda {|q| q.nil? ? q : q.to_i}]
|
21
|
+
|
22
|
+
FasterCSV.parse(io, :skip_blanks => true).collect do |list|
|
23
|
+
list = list.zip(converters).collect {|col, converter| converter[col]}
|
12
24
|
self.new(*list)
|
13
25
|
end
|
14
26
|
end
|
15
27
|
|
16
|
-
|
17
|
-
|
28
|
+
############################################################
|
29
|
+
|
30
|
+
def self.write_csv(filename, reminders)
|
31
|
+
File.open(filename, "w") do |file|
|
32
|
+
file.write(generate_csv(reminders))
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.generate_csv(reminders)
|
37
|
+
FasterCSV.generate do |csv|
|
18
38
|
reminders.each do |reminder|
|
19
|
-
|
39
|
+
if reminder.to_a.last.nil? # future reminder, never graded
|
40
|
+
csv << reminder.to_a.first(3)
|
41
|
+
else
|
42
|
+
csv << reminder.to_a
|
43
|
+
end
|
20
44
|
end
|
21
45
|
end
|
22
46
|
end
|
@@ -0,0 +1,128 @@
|
|
1
|
+
|
2
|
+
require 'test/unit'
|
3
|
+
require "#{File.dirname(__FILE__)}/../lib/forgetful"
|
4
|
+
|
5
|
+
|
6
|
+
class TestReminder < Test::Unit::TestCase
|
7
|
+
|
8
|
+
def assert_raise_message(error, re)
|
9
|
+
exception = assert_raise(error) do
|
10
|
+
yield
|
11
|
+
end
|
12
|
+
assert_match re, exception.message
|
13
|
+
end
|
14
|
+
|
15
|
+
#-------------------------------------------------
|
16
|
+
|
17
|
+
def assert_equal_inspect(expected, actual)
|
18
|
+
assert_equal expected.inspect, actual.inspect
|
19
|
+
end
|
20
|
+
|
21
|
+
def setup
|
22
|
+
@carbon_question = Reminder.new 'carbon', '6'
|
23
|
+
end
|
24
|
+
|
25
|
+
#-------------------------------------------------
|
26
|
+
|
27
|
+
def test_empty
|
28
|
+
assert_raise_message ArgumentError, /wrong number of arguments \(0 for 2\)/ do
|
29
|
+
Reminder.new
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_just_question
|
34
|
+
assert_raise_message ArgumentError, /wrong number of arguments \(1 for 2\)/ do
|
35
|
+
Reminder.new 'carbon'
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
#-------------------------------------------------
|
40
|
+
|
41
|
+
def test_minimum
|
42
|
+
assert_equal 'carbon', @carbon_question.question
|
43
|
+
assert_equal '6', @carbon_question.answer
|
44
|
+
assert_equal Date.today, @carbon_question.execute_on
|
45
|
+
assert_equal 2.5, @carbon_question.ef
|
46
|
+
assert_equal 0, @carbon_question.i
|
47
|
+
assert_equal 0, @carbon_question.interval
|
48
|
+
assert_equal nil, @carbon_question.q
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_minium_array
|
52
|
+
assert_equal ['carbon', '6', Date.today, 2.5, 0, 0, nil], [@carbon_question.question, @carbon_question.answer, @carbon_question.execute_on, @carbon_question.ef, @carbon_question.i, @carbon_question.interval, @carbon_question.q]
|
53
|
+
end
|
54
|
+
|
55
|
+
#-------------------------------------------------
|
56
|
+
|
57
|
+
def test_next
|
58
|
+
assert_equal_inspect ['carbon', '6', Date.today+1, 1.7, 0, 1, 0], @carbon_question.next(0).to_a
|
59
|
+
assert_equal_inspect ['carbon', '6', Date.today+1, 1.96, 0, 1, 1], @carbon_question.next(1).to_a
|
60
|
+
assert_equal_inspect ['carbon', '6', Date.today+1, 2.18, 0, 1, 2], @carbon_question.next(2).to_a
|
61
|
+
assert_equal_inspect ['carbon', '6', Date.today+1, 2.36, 1, 1, 3], @carbon_question.next(3).to_a
|
62
|
+
assert_equal_inspect ['carbon', '6', Date.today+1, 2.5, 1, 1, 4], @carbon_question.next(4).to_a
|
63
|
+
assert_equal_inspect ['carbon', '6', Date.today+1, 2.6, 1, 1, 5], @carbon_question.next(5).to_a
|
64
|
+
end
|
65
|
+
|
66
|
+
def test_next_after_0
|
67
|
+
assert_equal_inspect ['carbon', '6', Date.today+1, 1.3, 0, 1, 0], @carbon_question.next(0).next(0).to_a
|
68
|
+
assert_equal_inspect ['carbon', '6', Date.today+1, 1.3, 0, 1, 1], @carbon_question.next(0).next(1).to_a
|
69
|
+
assert_equal_inspect ['carbon', '6', Date.today+1, 1.38, 0, 1, 2], @carbon_question.next(0).next(2).to_a
|
70
|
+
assert_equal_inspect ['carbon', '6', Date.today+1, 1.56, 1, 1, 3], @carbon_question.next(0).next(3).to_a
|
71
|
+
assert_equal_inspect ['carbon', '6', Date.today+1, 1.7, 1, 1, 4], @carbon_question.next(0).next(4).to_a
|
72
|
+
assert_equal_inspect ['carbon', '6', Date.today+1, 1.8, 1, 1, 5], @carbon_question.next(0).next(5).to_a
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_next_after_1
|
76
|
+
assert_equal_inspect ['carbon', '6', Date.today+1, 1.3, 0, 1, 0], @carbon_question.next(1).next(0).to_a
|
77
|
+
assert_equal_inspect ['carbon', '6', Date.today+1, 1.42, 0, 1, 1], @carbon_question.next(1).next(1).to_a
|
78
|
+
assert_equal_inspect ['carbon', '6', Date.today+1, 1.64, 0, 1, 2], @carbon_question.next(1).next(2).to_a
|
79
|
+
assert_equal_inspect ['carbon', '6', Date.today+1, 1.82, 1, 1, 3], @carbon_question.next(1).next(3).to_a
|
80
|
+
assert_equal_inspect ['carbon', '6', Date.today+1, 1.96, 1, 1, 4], @carbon_question.next(1).next(4).to_a
|
81
|
+
assert_equal_inspect ['carbon', '6', Date.today+1, 2.06, 1, 1, 5], @carbon_question.next(1).next(5).to_a
|
82
|
+
end
|
83
|
+
|
84
|
+
def test_next_after_2
|
85
|
+
assert_equal_inspect ['carbon', '6', Date.today+1, 1.38, 0, 1, 0], @carbon_question.next(2).next(0).to_a
|
86
|
+
assert_equal_inspect ['carbon', '6', Date.today+1, 1.64, 0, 1, 1], @carbon_question.next(2).next(1).to_a
|
87
|
+
assert_equal_inspect ['carbon', '6', Date.today+1, 1.86, 0, 1, 2], @carbon_question.next(2).next(2).to_a
|
88
|
+
assert_equal_inspect ['carbon', '6', Date.today+1, 2.04, 1, 1, 3], @carbon_question.next(2).next(3).to_a
|
89
|
+
assert_equal_inspect ['carbon', '6', Date.today+1, 2.18, 1, 1, 4], @carbon_question.next(2).next(4).to_a
|
90
|
+
assert_equal_inspect ['carbon', '6', Date.today+1, 2.28, 1, 1, 5], @carbon_question.next(2).next(5).to_a
|
91
|
+
end
|
92
|
+
|
93
|
+
def test_next_after_3
|
94
|
+
assert_equal_inspect ['carbon', '6', Date.today+1, 1.56, 0, 1, 0], @carbon_question.next(3).next(0).to_a
|
95
|
+
assert_equal_inspect ['carbon', '6', Date.today+1, 1.82, 0, 1, 1], @carbon_question.next(3).next(1).to_a
|
96
|
+
assert_equal_inspect ['carbon', '6', Date.today+1, 2.04, 0, 1, 2], @carbon_question.next(3).next(2).to_a
|
97
|
+
assert_equal_inspect ['carbon', '6', Date.today+6, 2.22, 2, 6, 3], @carbon_question.next(3).next(3).to_a
|
98
|
+
assert_equal_inspect ['carbon', '6', Date.today+6, 2.36, 2, 6, 4], @carbon_question.next(3).next(4).to_a
|
99
|
+
assert_equal_inspect ['carbon', '6', Date.today+6, 2.46, 2, 6, 5], @carbon_question.next(3).next(5).to_a
|
100
|
+
end
|
101
|
+
|
102
|
+
def test_next_after_4
|
103
|
+
assert_equal_inspect ['carbon', '6', Date.today+1, 1.7, 0, 1, 0], @carbon_question.next(4).next(0).to_a
|
104
|
+
assert_equal_inspect ['carbon', '6', Date.today+1, 1.96, 0, 1, 1], @carbon_question.next(4).next(1).to_a
|
105
|
+
assert_equal_inspect ['carbon', '6', Date.today+1, 2.18, 0, 1, 2], @carbon_question.next(4).next(2).to_a
|
106
|
+
assert_equal_inspect ['carbon', '6', Date.today+6, 2.36, 2, 6, 3], @carbon_question.next(4).next(3).to_a
|
107
|
+
assert_equal_inspect ['carbon', '6', Date.today+6, 2.5, 2, 6, 4], @carbon_question.next(4).next(4).to_a
|
108
|
+
assert_equal_inspect ['carbon', '6', Date.today+6, 2.6, 2, 6, 5], @carbon_question.next(4).next(5).to_a
|
109
|
+
end
|
110
|
+
|
111
|
+
def test_next_after_5
|
112
|
+
assert_equal_inspect ['carbon', '6', Date.today+1, 1.8, 0, 1, 0], @carbon_question.next(5).next(0).to_a
|
113
|
+
assert_equal_inspect ['carbon', '6', Date.today+1, 2.06, 0, 1, 1], @carbon_question.next(5).next(1).to_a
|
114
|
+
assert_equal_inspect ['carbon', '6', Date.today+1, 2.28, 0, 1, 2], @carbon_question.next(5).next(2).to_a
|
115
|
+
assert_equal_inspect ['carbon', '6', Date.today+6, 2.46, 2, 6, 3], @carbon_question.next(5).next(3).to_a
|
116
|
+
assert_equal_inspect ['carbon', '6', Date.today+6, 2.6, 2, 6, 4], @carbon_question.next(5).next(4).to_a
|
117
|
+
assert_equal_inspect ['carbon', '6', Date.today+6, 2.7, 2, 6, 5], @carbon_question.next(5).next(5).to_a
|
118
|
+
end
|
119
|
+
|
120
|
+
#-------------------------------------------------
|
121
|
+
|
122
|
+
# will ask tomorrow?
|
123
|
+
def test_fail_after_long_interval
|
124
|
+
oxygen_question = Reminder.new('oxygen', '8', Date.today, 3.2, 7, 393)
|
125
|
+
assert_equal_inspect ['oxygen', '8', Date.today+1, 2.4, 0, 1, 0], oxygen_question.next(0).to_a
|
126
|
+
end
|
127
|
+
|
128
|
+
end
|
@@ -0,0 +1,103 @@
|
|
1
|
+
|
2
|
+
require 'test/unit'
|
3
|
+
require "#{File.dirname(__FILE__)}/../lib/forgetful"
|
4
|
+
|
5
|
+
|
6
|
+
class TestReminderCSV < Test::Unit::TestCase
|
7
|
+
|
8
|
+
def assert_equal_inspect(expected, actual)
|
9
|
+
assert_equal expected.inspect, actual.inspect
|
10
|
+
end
|
11
|
+
|
12
|
+
#-------------------------------------------------
|
13
|
+
|
14
|
+
def test_parse_csv_bare
|
15
|
+
csv = <<END
|
16
|
+
carbon,6
|
17
|
+
nitrogen,7
|
18
|
+
oxygen,8
|
19
|
+
END
|
20
|
+
|
21
|
+
reminders = Reminder.parse_csv(csv)
|
22
|
+
|
23
|
+
assert_equal 3, reminders.length
|
24
|
+
|
25
|
+
assert_equal_inspect ['carbon', '6',Date.today, 2.5, 0, 0, nil], reminders[0].to_a
|
26
|
+
assert_equal_inspect ['nitrogen','7',Date.today, 2.5, 0, 0, nil], reminders[1].to_a
|
27
|
+
assert_equal_inspect ['oxygen', '8',Date.today, 2.5, 0, 0, nil], reminders[2].to_a
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_parse_csv_with_dates
|
31
|
+
csv = <<END
|
32
|
+
carbon,6,2008-11-11
|
33
|
+
nitrogen,7,2008-11-11
|
34
|
+
oxygen,8,2008-11-11
|
35
|
+
END
|
36
|
+
|
37
|
+
reminders = Reminder.parse_csv(csv)
|
38
|
+
|
39
|
+
assert_equal 3, reminders.length
|
40
|
+
|
41
|
+
assert_equal_inspect ['carbon', '6',Date.parse('2008-11-11'), 2.5, 0, 0, nil], reminders[0].to_a
|
42
|
+
assert_equal_inspect ['nitrogen','7',Date.parse('2008-11-11'), 2.5, 0, 0, nil], reminders[1].to_a
|
43
|
+
assert_equal_inspect ['oxygen', '8',Date.parse('2008-11-11'), 2.5, 0, 0, nil], reminders[2].to_a
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_parse_csv_full
|
47
|
+
csv = <<END
|
48
|
+
carbon,6,2008-11-11,2.5,0,0,
|
49
|
+
nitrogen,7,2008-11-11,2.5,0,0,
|
50
|
+
oxygen,8,2008-11-11,2.5,0,0,
|
51
|
+
END
|
52
|
+
|
53
|
+
reminders = Reminder.parse_csv(csv)
|
54
|
+
|
55
|
+
assert_equal 3, reminders.length
|
56
|
+
|
57
|
+
assert_equal_inspect ['carbon', '6',Date.parse('2008-11-11'), 2.5, 0, 0, nil], reminders[0].to_a
|
58
|
+
assert_equal_inspect ['nitrogen','7',Date.parse('2008-11-11'), 2.5, 0, 0, nil], reminders[1].to_a
|
59
|
+
assert_equal_inspect ['oxygen', '8',Date.parse('2008-11-11'), 2.5, 0, 0, nil], reminders[2].to_a
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_parse_csv_full_with_spaces
|
63
|
+
csv = <<END
|
64
|
+
|
65
|
+
carbon,6,2008-11-11,2.5,0,0,
|
66
|
+
|
67
|
+
|
68
|
+
nitrogen,7,2008-11-11,2.5,0,0,
|
69
|
+
oxygen,8,2008-11-11,2.5,0,0,
|
70
|
+
|
71
|
+
END
|
72
|
+
|
73
|
+
reminders = Reminder.parse_csv(csv)
|
74
|
+
|
75
|
+
assert_equal 3, reminders.length
|
76
|
+
|
77
|
+
assert_equal_inspect ['carbon', '6',Date.parse('2008-11-11'), 2.5, 0, 0, nil], reminders[0].to_a
|
78
|
+
assert_equal_inspect ['nitrogen','7',Date.parse('2008-11-11'), 2.5, 0, 0, nil], reminders[1].to_a
|
79
|
+
assert_equal_inspect ['oxygen', '8',Date.parse('2008-11-11'), 2.5, 0, 0, nil], reminders[2].to_a
|
80
|
+
end
|
81
|
+
|
82
|
+
############################################################
|
83
|
+
|
84
|
+
def test_generate_csv
|
85
|
+
reminders = []
|
86
|
+
reminders << Reminder.new('carbon','6')
|
87
|
+
reminders << Reminder.new('nitrogen','7').next(5).next(5).next(5)
|
88
|
+
reminders << Reminder.new('oxygen','8').next(1).next(1).next(1)
|
89
|
+
reminders << Reminder.new('fluorine','9').next(1).next(5).next(1).next(5)
|
90
|
+
reminders << Reminder.new('neon','10',Date.today+5)
|
91
|
+
|
92
|
+
expected =<<END
|
93
|
+
carbon,6,#{Date.today}
|
94
|
+
nitrogen,7,#{(Date.today+16)},2.8,3,16,5
|
95
|
+
oxygen,8,#{(Date.today+1)},1.3,0,1,1
|
96
|
+
fluorine,9,#{(Date.today+1)},1.62,1,1,5
|
97
|
+
neon,10,#{(Date.today+5)}
|
98
|
+
END
|
99
|
+
|
100
|
+
assert_equal expected, Reminder.generate_csv(reminders)
|
101
|
+
end
|
102
|
+
|
103
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: forgetful
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonathan Palardy
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-11-
|
12
|
+
date: 2008-11-13 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -36,18 +36,20 @@ extra_rdoc_files:
|
|
36
36
|
- lib/csv_ext/reminder.rb
|
37
37
|
- lib/forgetful.rb
|
38
38
|
- lib/reminder.rb
|
39
|
-
- README
|
39
|
+
- README.rdoc
|
40
40
|
files:
|
41
41
|
- bin/forgetful
|
42
42
|
- examples/katakana_romanji.csv
|
43
43
|
- examples/romanji_katakana.csv
|
44
|
-
- forgetful.gemspec
|
45
44
|
- lib/csv_ext/reminder.rb
|
46
45
|
- lib/forgetful.rb
|
47
46
|
- lib/reminder.rb
|
48
47
|
- Manifest
|
49
|
-
-
|
50
|
-
-
|
48
|
+
- MIT-LICENSE
|
49
|
+
- README.rdoc
|
50
|
+
- test/test_reminder.rb
|
51
|
+
- test/test_reminder_csv.rb
|
52
|
+
- forgetful.gemspec
|
51
53
|
has_rdoc: false
|
52
54
|
homepage: http://github.com/jpalardy/forgetful
|
53
55
|
post_install_message:
|
@@ -57,7 +59,7 @@ rdoc_options:
|
|
57
59
|
- --title
|
58
60
|
- Forgetful
|
59
61
|
- --main
|
60
|
-
- README
|
62
|
+
- README.rdoc
|
61
63
|
require_paths:
|
62
64
|
- lib
|
63
65
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -80,4 +82,5 @@ signing_key:
|
|
80
82
|
specification_version: 2
|
81
83
|
summary: A minimal command-line implementation of the SuperMemo 2 algorithm.
|
82
84
|
test_files:
|
83
|
-
- test/
|
85
|
+
- test/test_reminder.rb
|
86
|
+
- test/test_reminder_csv.rb
|
data/README
DELETED
@@ -1,51 +0,0 @@
|
|
1
|
-
|
2
|
-
A minimal command-line app implementing the SuperMemo 2 algorithm.
|
3
|
-
|
4
|
-
The SuperMemo algorithm is designed to refresh your memory at
|
5
|
-
intervals based on how well you remembered something.
|
6
|
-
|
7
|
-
Put question-answer pairs in a file. Everyday, feed the file to forgetful and
|
8
|
-
it will quiz you on what you need to remember today. Based on your
|
9
|
-
self-evaluation, forgetful will reschedule at an appropriate time in the
|
10
|
-
future.
|
11
|
-
|
12
|
-
Usage:
|
13
|
-
|
14
|
-
forgetful filename.csv [more filenames]
|
15
|
-
|
16
|
-
Format:
|
17
|
-
|
18
|
-
A CSV file to contain your questions and answers, in the following format:
|
19
|
-
|
20
|
-
question,answer
|
21
|
-
|
22
|
-
Flow:
|
23
|
-
|
24
|
-
1. shows question (press enter)
|
25
|
-
2. shows answer
|
26
|
-
3. asks for self-evaluation (type number, and enter)
|
27
|
-
4. repeats for all questions
|
28
|
-
5. repeats for questions that scored less than 4
|
29
|
-
|
30
|
-
Self-evaluation:
|
31
|
-
|
32
|
-
5 - perfect response
|
33
|
-
4 - correct response after a hesitation
|
34
|
-
3 - correct response recalled with serious difficulty
|
35
|
-
2 - incorrect response; where the correct one seemed easy to recall
|
36
|
-
1 - incorrect response; the correct one remembered
|
37
|
-
0 - complete blackout.
|
38
|
-
|
39
|
-
WARNING:
|
40
|
-
|
41
|
-
Statistics are written back to the input file. This is a feature. Put your CSV
|
42
|
-
files under source control to keep a history.
|
43
|
-
|
44
|
-
Enjoy!
|
45
|
-
|
46
|
-
############################################################
|
47
|
-
|
48
|
-
The article that sparked my interest: http://www.wired.com/medtech/health/magazine/16-05/ff_wozniak
|
49
|
-
|
50
|
-
The algorithm itself: http://www.supermemo.com/english/ol/sm2.htm
|
51
|
-
|
data/test/test_forgetful.rb
DELETED
File without changes
|