active_recall 1.5.0 → 1.6.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 37b52862b045e1e9c7a189acd1a611e84b5bd260ff1149472ed5b724530a0943
4
- data.tar.gz: 7dbacf4db26d857144e91a68a4b4a5ea5c6012ec9579079d4b649c7fc7f8e388
3
+ metadata.gz: 2e993b98e9627ec06e8eae73c3fba15a6ed761b66dbb1092b1355140cb2bd366
4
+ data.tar.gz: 5402a3ae205e52b20587ab73a5d819eaf7102dea5d52cf983e4be5beddf5279d
5
5
  SHA512:
6
- metadata.gz: 10d110f43d6e845f1f3bc8269e7bf053a94ebb13bb1b9355d9915dd6e515b94492a7f4421d2e83978f24d45c471de4c881ea5d84f919f6eb9511cdec055dfacd
7
- data.tar.gz: 0a3ef619b273e692bb1ef325971a3baa79562bc013ac3fc999eaa87ca4e4c2ff29607c3491f22d2ad419d79cd44f41cb1a5fb2ba41cba01357784f15e14ca3cc
6
+ metadata.gz: aba48fb3870fd48fba35a371b48ceeaad4fb306acef718175f67451ee25111ec6389faaf0c52d9424ad1b87da94faf1c24b66f32f920392fa4b7e68ebbb27699
7
+ data.tar.gz: 2c9c4651bd1e4ac541ffb4c258e899bf311cd84ec6cc4490b643ef1a27bc236c9820e5e30b5af22ee4673413dfad5e0bacbdbcd7344494c9df2059e3472fee17
@@ -28,7 +28,7 @@ jobs:
28
28
  include:
29
29
  - os: ubuntu
30
30
  ruby: ruby-head
31
- allow_failures: true
31
+ allow_failures: false
32
32
  env:
33
33
  BUNDLE_GEMFILE: "${{ matrix.gemfile }}"
34
34
  ALLOW_FAILURES: "${{ matrix.allow_failures }}"
data/Gemfile.lock CHANGED
@@ -1,29 +1,29 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- active_recall (1.5.0)
5
- activerecord (>= 5.2.3, <= 6.1)
6
- activesupport (>= 5.2.3, <= 6.1)
4
+ active_recall (1.6.3)
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)
12
+ activesupport (= 6.1.4)
13
+ activerecord (6.1.4)
14
+ activemodel (= 6.1.4)
15
+ activesupport (= 6.1.4)
16
+ activesupport (6.1.4)
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
- minitest (5.14.3)
26
+ minitest (5.14.4)
27
27
  rake (12.3.3)
28
28
  rdoc (6.2.0)
29
29
  rspec (3.8.0)
@@ -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,10 +3,10 @@
3
3
  module ActiveRecall
4
4
  module DeckMethods
5
5
  def deck
6
- d = ActiveRecall::Deck.where(user_id: id, user_type: self.class.name).first_or_create
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.where(source_id: id, source_type: self.class.name).first
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
- 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
@@ -37,16 +37,19 @@ module ActiveRecall
37
37
  end
38
38
 
39
39
  def delete(source)
40
- item = ActiveRecall::Item.new(deck: self, source_id: source.id, source_type: source.class.name)
41
- item.destroy
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|
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActiveRecall
4
- VERSION = '1.5.0'
4
+ VERSION = '1.6.3'
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.5.0
4
+ version: 1.6.3
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-19 00:00:00.000000000 Z
12
+ date: 2021-08-12 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