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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fa3e96edf227ce2525992ceca2c33157c747e551e63d462a25598df8a045e666
4
- data.tar.gz: 5afccb4036378327bc8b2c3d08eabed131b361fd909912f658853e76810b8c0e
3
+ metadata.gz: 2462d9658030de7f1937d77d30e6a05f40704e311179a170752f81e36f29f8ff
4
+ data.tar.gz: 9a8f21af5cb5fab6d64e778d2ea52037219eb1ed587718270e68a66bd6e7f37e
5
5
  SHA512:
6
- metadata.gz: 294c17f3dbbf35a343cac2694fef06e16b281e8d2a5b108e712e328c60a8da8ea578e0ba617f1790c1705e28d9d995a3952c02c3201f87665956a1e2b4efb050
7
- data.tar.gz: 369708a814e7ef952be0ea562e90aa7b42e5c3220db7ce1397d09736dfe69958c36dc90a67474715d52010b1ba26777924e6a8d09e017a0344cd3fdbded22b26
6
+ metadata.gz: 8e97d5021f48ab881e8c3e1ff859c4ff96128d7522d904b52372895c0ffcec7144037049267197ac2b502f96f56a2fafc45835ee3651888373e3906d8177a519
7
+ data.tar.gz: ac115c301831b0ee9b457a5231aa08cf7b1bef8cbfdd31439167142d0d61267d31575597dd0b8ba234fa9107fd46c2579d5e90dff2ff783cba8efeee958df5b9
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- custom_tracker (1.0.1)
4
+ custom_tracker (1.1.0)
5
5
  csv (~> 3.1)
6
6
  date (~> 2.0)
7
7
 
@@ -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)
@@ -2,6 +2,6 @@ module CustomTracker
2
2
 
3
3
  ##
4
4
  # Gem version.
5
- VERSION = "1.0.1"
5
+ VERSION = "1.1.0"
6
6
 
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: custom_tracker
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fizvlad