active_recall 1.6.0 → 1.6.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1784eaa3c18a644a3b7b16935626de436851355d6ec1f0ac19367ef2d789a873
4
- data.tar.gz: '08e4a478783a55852dbefa1d0f6703ab2e44b4c02cd493e7091ff8cd715f4f43'
3
+ metadata.gz: 90faada77c84371101ce19140d8c0e113fa06a831ed0c11613ac46bc7221a798
4
+ data.tar.gz: 6aaaf972df81c2341143307c4998bcb7c0b0017e1e0979bc54b8bddaf5a74d86
5
5
  SHA512:
6
- metadata.gz: d80c727f175317bb7173721981dba6eaea93e8e6a13793e3fc38ffebf0215b998c58904b936c6fb9cbd9784a3a6641ce35016402e6b85ef335f8df3c8bf622a5
7
- data.tar.gz: e645b4e3cd9ee513885f3a766d7d0566efa12bae1be14e0c3593c130bc6a10083544ffdb1e71a22e9a0cd313f1415811aa9fec3c734c9839c677a367f21e91be
6
+ metadata.gz: 3a4cf31bf1d9860b954aaaf482dfc4ac990012b6ea65432135f267d324505ddad9f856deca45318c3671b69b339c1a53bc8b6c10bb99ce3bad54db6f5b4736ea
7
+ data.tar.gz: 87cb8640cf8f2ed2bdcdda45c36064f943c303d001155676160f357b1190d64b6451ac3d68091d92f7db6cc7c64b6cb4c73a10781c390ea0edfb89185e69ad4f
data/Gemfile.lock CHANGED
@@ -1,27 +1,27 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- active_recall (1.6.0)
5
- activerecord (>= 5.2.3, <= 6.1)
6
- activesupport (>= 5.2.3, <= 6.1)
4
+ active_recall (1.6.4)
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.1.0)
12
- activesupport (= 6.1.0)
13
- activerecord (6.1.0)
14
- activemodel (= 6.1.0)
15
- activesupport (= 6.1.0)
16
- activesupport (6.1.0)
11
+ activemodel (6.1.4.1)
12
+ activesupport (= 6.1.4.1)
13
+ activerecord (6.1.4.1)
14
+ activemodel (= 6.1.4.1)
15
+ activesupport (= 6.1.4.1)
16
+ activesupport (6.1.4.1)
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
21
  zeitwerk (~> 2.3)
22
- concurrent-ruby (1.1.8)
22
+ concurrent-ruby (1.1.9)
23
23
  diff-lcs (1.3)
24
- i18n (1.8.9)
24
+ i18n (1.8.10)
25
25
  concurrent-ruby (~> 1.0)
26
26
  minitest (5.14.4)
27
27
  rake (12.3.3)
@@ -49,9 +49,9 @@ PLATFORMS
49
49
 
50
50
  DEPENDENCIES
51
51
  active_recall!
52
- rake (~> 12.0)
52
+ rake (>= 12.0)
53
53
  rdoc
54
- rspec (~> 3.0)
54
+ rspec (>= 3.0)
55
55
  sqlite3
56
56
 
57
57
  BUNDLED WITH
data/README.md CHANGED
@@ -2,7 +2,7 @@
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.0 and Ruby 3.0.
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. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
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`. 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).
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
 
@@ -32,10 +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 'rake', '~> 12.0'
35
+ spec.add_development_dependency 'rake', '>= 12.0'
36
36
  spec.add_development_dependency 'rdoc'
37
- spec.add_development_dependency 'rspec', '~> 3.0'
37
+ spec.add_development_dependency 'rspec', '>= 3.0'
38
38
  spec.add_development_dependency 'sqlite3'
39
- spec.add_runtime_dependency 'activerecord', '>= 5.2.3', '<= 6.1'
40
- spec.add_runtime_dependency 'activesupport', '>= 5.2.3', '<= 6.1'
39
+ spec.add_runtime_dependency 'activerecord', '>= 5.2.3', '<= 6.2'
40
+ spec.add_runtime_dependency 'activesupport', '>= 5.2.3', '<= 6.2'
41
41
  end
@@ -51,9 +51,11 @@ module ActiveRecall
51
51
 
52
52
  attr_reader :box, :current_time, :times_right, :times_wrong
53
53
 
54
+ SEQUENCE = [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765].freeze
55
+
54
56
  def fibonacci_number_at(index)
55
- if (0..1).cover?(index)
56
- index
57
+ if (0...SEQUENCE.length).cover?(index)
58
+ SEQUENCE[index]
57
59
  else
58
60
  fibonacci_number_at(index - 1) + fibonacci_number_at(index - 2)
59
61
  end
@@ -3,15 +3,11 @@
3
3
  module ActiveRecall
4
4
  module ItemMethods
5
5
  def right_answer_for!(item)
6
- i = deck.items.find_by(source_id: item.id)
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
- i = deck.items.find_by(source_id: item.id)
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
@@ -43,18 +43,11 @@ module ActiveRecall
43
43
  end
44
44
 
45
45
  def review
46
- %i[untested failed expired].inject([]) do |words, s|
47
- words += items.send(s).order(random_order_function).map(&:source)
48
- end
46
+ _review.map(&:source)
49
47
  end
50
48
 
51
49
  def next
52
- word = nil
53
- %i[untested failed expired].each do |category|
54
- word = items.send(category).order(random_order_function).limit(1).map(&:source).first
55
- break if word
56
- end
57
- word
50
+ _review.first.try(:source)
58
51
  end
59
52
 
60
53
  def last
@@ -87,6 +80,14 @@ module ActiveRecall
87
80
 
88
81
  private
89
82
 
83
+ def _review
84
+ items
85
+ .untested
86
+ .or(items.failed)
87
+ .or(items.expired)
88
+ .order(random_order_function)
89
+ end
90
+
90
91
  def random_order_function
91
92
  Arel.sql(mysql? ? 'RAND()' : 'random()')
92
93
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActiveRecall
4
- VERSION = '1.6.0'
4
+ VERSION = '1.6.4'
5
5
  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.6.0
4
+ version: 1.6.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Gravina
@@ -9,20 +9,20 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2021-02-28 00:00:00.000000000 Z
12
+ date: 2021-09-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - "~>"
18
+ - - ">="
19
19
  - !ruby/object:Gem::Version
20
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
27
  version: '12.0'
28
28
  - !ruby/object:Gem::Dependency
@@ -43,14 +43,14 @@ dependencies:
43
43
  name: rspec
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
- - - "~>"
46
+ - - ">="
47
47
  - !ruby/object:Gem::Version
48
48
  version: '3.0'
49
49
  type: :development
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
- - - "~>"
53
+ - - ">="
54
54
  - !ruby/object:Gem::Version
55
55
  version: '3.0'
56
56
  - !ruby/object:Gem::Dependency
@@ -76,7 +76,7 @@ dependencies:
76
76
  version: 5.2.3
77
77
  - - "<="
78
78
  - !ruby/object:Gem::Version
79
- version: '6.1'
79
+ version: '6.2'
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: '6.1'
89
+ version: '6.2'
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: '6.1'
99
+ version: '6.2'
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: '6.1'
109
+ version: '6.2'
110
110
  description: A spaced-repetition system to be used with ActiveRecord models
111
111
  email:
112
112
  - robert.gravina@gmail.com