custom_tracker 1.0.1 → 1.1.0
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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/custom_tracker/table.rb +6 -2
- data/lib/custom_tracker/tracker.rb +1 -4
- data/lib/custom_tracker/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2462d9658030de7f1937d77d30e6a05f40704e311179a170752f81e36f29f8ff
|
4
|
+
data.tar.gz: 9a8f21af5cb5fab6d64e778d2ea52037219eb1ed587718270e68a66bd6e7f37e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8e97d5021f48ab881e8c3e1ff859c4ff96128d7522d904b52372895c0ffcec7144037049267197ac2b502f96f56a2fafc45835ee3651888373e3906d8177a519
|
7
|
+
data.tar.gz: ac115c301831b0ee9b457a5231aa08cf7b1bef8cbfdd31439167142d0d61267d31575597dd0b8ba234fa9107fd46c2579d5e90dff2ff783cba8efeee958df5b9
|
data/Gemfile.lock
CHANGED
data/lib/custom_tracker/table.rb
CHANGED
@@ -35,7 +35,9 @@ module CustomTracker
|
|
35
35
|
# @option options [Array<Symbol>] columns array of column names all the entries
|
36
36
|
# which are added to this table are required to store it.
|
37
37
|
# @option options [#call] saving_block callable object which must accept
|
38
|
-
# +Array<Entry>+ - array of entries to save and +Table+ - +self
|
38
|
+
# +Array<Entry>+ - array of entries to save and +Table+ - +self+.
|
39
|
+
# @option options [Integer, nil] autosave (nil) if +Integer+ provided data will be
|
40
|
+
# automatically saved if amount of unsaved entries reach specified value.
|
39
41
|
def initialize(options)
|
40
42
|
@columns = options[:columns].select { |s| s.is_a? Symbol }
|
41
43
|
@columns.freeze
|
@@ -45,6 +47,8 @@ module CustomTracker
|
|
45
47
|
raise ArgumentError, "saving_block is not responding to call method!", caller
|
46
48
|
end
|
47
49
|
|
50
|
+
@autosave = options[:autosave] ? options[:autosave].to_i : nil
|
51
|
+
|
48
52
|
@size_saved = 0
|
49
53
|
@unsaved_entries = []
|
50
54
|
@mutex = Mutex.new
|
@@ -75,7 +79,7 @@ module CustomTracker
|
|
75
79
|
|
76
80
|
if accepts? entry
|
77
81
|
@unsaved_entries.push(entry)
|
78
|
-
save if instant_save
|
82
|
+
save if instant_save || (@autosave && size_unsaved >= @autosave)
|
79
83
|
entry
|
80
84
|
else
|
81
85
|
nil
|
@@ -39,10 +39,7 @@ module CustomTracker
|
|
39
39
|
# Create new table and add it to handling.
|
40
40
|
#
|
41
41
|
# @param sym [Symbol]
|
42
|
-
# @param options [Hash]
|
43
|
-
#
|
44
|
-
# @option options [Array<Symbol>] columns array of column names all the entries
|
45
|
-
# which are added to this table are required to store it.
|
42
|
+
# @param options [Hash] options which will be passed to {Table.initialize}.
|
46
43
|
#
|
47
44
|
# @return [Table] created table.
|
48
45
|
def new_table(sym, options)
|