data_store 0.1.7 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
data/.travis.yml CHANGED
@@ -11,7 +11,8 @@ matrix:
11
11
  - rvm: rbx-19mode
12
12
  env: DB=sqlite
13
13
  allow_failures:
14
- - jruby-19mode
14
+ - rvm: jruby-19mode
15
+ - rvm: rbx-19mode
15
16
 
16
17
  branches:
17
18
  only:
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ##0.1.8
2
+
3
+ * Added factor feature to multiply value before adding to the database
4
+
1
5
  ##0.1.7
2
6
 
3
7
  * BUG FIX: keep table_index unchanged during calculation of averages
@@ -28,12 +28,14 @@ module DataStore
28
28
  # * created: timestamp
29
29
  # * type: gauge or counter
30
30
  # * table_index: in which compressed table
31
+ # * factor: multiply value with the given factor
31
32
  def add(value, options = {})
32
33
  created = options[:created] || Time.now.utc.to_f
33
34
  type = options[:type] || parent.type
35
+ factor = options[:factor] || 1
34
36
  original_idx = @table_index
35
37
  @table_index = options[:table_index] if options[:table_index]
36
- push(value, type, created)
38
+ push(value, type, created, factor)
37
39
  @table_index = original_idx
38
40
  end
39
41
 
@@ -88,9 +90,9 @@ module DataStore
88
90
  parent.table_names[index]
89
91
  end
90
92
 
91
- def push(value, type, created)
93
+ def push(value, type, created, factor)
92
94
  value = difference_with_previous(value) if type.to_s == 'counter'
93
- datapoint = { value: value, created: created }
95
+ datapoint = { value: value * factor, created: created }
94
96
  datapoint[:original_value] = original_value if original_value
95
97
  database.transaction do
96
98
  dataset << datapoint
@@ -1,3 +1,3 @@
1
1
  module DataStore
2
- VERSION = '0.1.7'
2
+ VERSION = '0.1.8'
3
3
  end
data/test/table_test.rb CHANGED
@@ -46,6 +46,20 @@ class TableTest < Test::Unit::TestCase
46
46
  end
47
47
  end
48
48
 
49
+
50
+ context 'adding datapoints with factor' do
51
+
52
+ setup do
53
+ @table.stubs(:calculate_average_values)
54
+ end
55
+
56
+ should 'return the last datapoint' do
57
+ @table.add(0.092345, factor: 1000)
58
+ assert_equal 92.345, @table.last.value
59
+ end
60
+
61
+ end
62
+
49
63
  should 'Trigger the average calculator after adding a value' do
50
64
  calculator = mock
51
65
  #Need to use any_parameters instead of @table because of Celluloid
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: data_store
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-14 00:00:00.000000000 Z
12
+ date: 2013-04-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sequel
@@ -78,7 +78,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
78
78
  version: '0'
79
79
  segments:
80
80
  - 0
81
- hash: -4573179353281624558
81
+ hash: -1364652122039742087
82
82
  required_rubygems_version: !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
@@ -87,7 +87,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
87
87
  version: '0'
88
88
  segments:
89
89
  - 0
90
- hash: -4573179353281624558
90
+ hash: -1364652122039742087
91
91
  requirements: []
92
92
  rubyforge_project:
93
93
  rubygems_version: 1.8.25