active_recall 1.8.4 → 1.8.5

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: d38e08a2f83ec8a0b36852b6d7e10ab4798debfaa8d51f5f4f7c29f7467a1e78
4
- data.tar.gz: a41ee1c1b84ea9d8d5aa4c7fe51a0151bac1a54f7baea5e1b5f655b7daba304b
3
+ metadata.gz: 8e96531570c81f3e7457acc497a7db792708b6b765794e2294b00cce0bd0cfe2
4
+ data.tar.gz: 06c2f07e0438fc376beefe980dbdc579f06bb7d8bab77e692faed876b5a69629
5
5
  SHA512:
6
- metadata.gz: e3afc2c4dbf422117dbdcaef6b38389f26553c4726513fc4785fafa7a07a3a79f9e01f7c2f0daca4564feba60098290cddf2e1d742a370b27ead1dd2b618f8be
7
- data.tar.gz: 12808e551f259b31bfca025753855c764bd0a67dfe13a470122fe72e3f8544cac05a00d53d4c91a5f17aa4d4014a6e19eceb02f7c10b2e96adc6e37e7440ae8d
6
+ metadata.gz: c8c4385a5646b277f27b6a90505e6f55847eba3d5e96bb32e0694f9148a018f71846d5cb9d552078a5c215965e5d72f6661f96c64885e9199ff557e77b47b059
7
+ data.tar.gz: 9089edaa9ef21c0d1a8750d60b223ac4cda49c075268bee4bea25493b7951c3bd31747a129a93721f0e239efb41bb9d7db3a6f96d157d9b2f95930494f812c91
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- active_recall (1.8.4)
4
+ active_recall (1.8.5)
5
5
  activerecord (>= 5.2.3, <= 7.1)
6
6
  activesupport (>= 5.2.3, <= 7.1)
7
7
 
data/bin/console ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "active_recall"
5
+
6
+ # You can add here some code to start an interactive console or debug session.
7
+ # `binding.pry` from the Pry gem is often used for this purpose.
8
+ require "irb"
9
+ IRB.start(__FILE__)
@@ -1,5 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "active_record"
4
+ require "active_support/concern"
5
+
3
6
  module ActiveRecall
4
7
  module Base
5
8
  extend ActiveSupport::Concern
@@ -9,27 +9,21 @@ module ActiveRecall
9
9
  has_many :items, class_name: "ActiveRecall::Item", dependent: :destroy
10
10
 
11
11
  def each
12
- _items.each do |item|
13
- if block_given?
14
- yield item
15
- else
16
- yield item
17
- end
18
- end
12
+ _items.find_each { |item| yield item }
19
13
  end
20
14
 
21
15
  def ==(other)
22
16
  _items == other
23
17
  end
24
18
 
25
- def _items
26
- source_class.find(items.pluck(:source_id))
27
- end
28
-
29
19
  def <<(source)
30
- raise ArgumentError, "Word already in the stack" if include?(source)
20
+ attributes = {deck: self, source_id: source.id, source_type: source.class.name}
31
21
 
32
- items << ActiveRecall::Item.new(deck: self, source_id: source.id, source_type: source.class.name)
22
+ if ActiveRecall::Item.exists?(attributes)
23
+ raise ArgumentError, "Word already in the stack"
24
+ end
25
+
26
+ items << ActiveRecall::Item.new(attributes)
33
27
  end
34
28
 
35
29
  def self.add_deck(user)
@@ -71,7 +65,7 @@ module ActiveRecall
71
65
  end
72
66
 
73
67
  def box(number)
74
- source_class.find(items.where(box: number).pluck(:source_id))
68
+ source_class.where(id: items.where(box: number).select(:source_id))
75
69
  end
76
70
 
77
71
  def source_class
@@ -80,6 +74,10 @@ module ActiveRecall
80
74
 
81
75
  private
82
76
 
77
+ def _items
78
+ source_class.where(id: items.select(:source_id))
79
+ end
80
+
83
81
  def _review
84
82
  items
85
83
  .untested
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActiveRecall
4
- VERSION = "1.8.4"
4
+ VERSION = "1.8.5"
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.8.4
4
+ version: 1.8.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Gravina
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2023-06-30 00:00:00.000000000 Z
12
+ date: 2023-08-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -125,6 +125,7 @@ files:
125
125
  - README.md
126
126
  - Rakefile
127
127
  - active_recall.gemspec
128
+ - bin/console
128
129
  - bin/setup
129
130
  - lib/active_recall.rb
130
131
  - lib/active_recall/algorithms/fibonacci_sequence.rb