statval 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -29,6 +29,7 @@ module StatVal
29
29
  when :max then max
30
30
  when :sum then sum
31
31
  when :sq_sum then sq_sum
32
+ when :std_ratio then std_ratio
32
33
  when :avg then avg
33
34
  when :std then std
34
35
  when :avg_sq then avg_sq
@@ -89,10 +90,10 @@ module StatVal
89
90
  @max = value if value > @max
90
91
  else
91
92
  if value.respond_to?(:each_pair)
92
- value.each_pair { |k, v| this << v }
93
- else
93
+ value.each_pair { |k, v| this << v }
94
+ else
94
95
  if value.respond_to?(:each)
95
- value.each { |v| this << v }
96
+ value.each { |v| this << v }
96
97
  else
97
98
  raise ArgumentError
98
99
  end
@@ -112,7 +113,7 @@ module StatVal
112
113
  self << (stop-start)
113
114
  end
114
115
  end
115
-
116
+
116
117
  def to_hash(which_keys = nil, convert_to_s = false)
117
118
  ::StatVal.key_hash(which_keys).inject({}) { |h, (attr, name)| h[(if convert_to_s then name.to_s else name end)] = self[attr]; h }
118
119
  end
@@ -1,3 +1,3 @@
1
1
  module StatVal
2
- VERSION = '0.1.2'
2
+ VERSION = '0.1.3'
3
3
  end
@@ -63,17 +63,23 @@ module StatVal
63
63
  @it[:avg].should be == 5.0
64
64
  @it[:sq_sum].should be == 148
65
65
  @it[:var].should be == 49
66
- @it[:std].should be == 7
66
+ @it[:std].should be == 7
67
67
  end
68
68
 
69
69
  it 'renders hashes' do
70
70
  @it = StatVal.new
71
71
  @it.reset num: 2, min: -2, max: +12, sum: 10, sq_sum: 148
72
- @it = { a: 7, h: @it }
72
+ @it = { a: 7, h: @it }
73
73
  ::StatVal.map_hash(@it).keys.to_set.should be == [ :h, :a ].to_set
74
74
  ::StatVal.flatmap_hash(@it).keys.to_set.should be == [ 'a', 'num_h', 'std_h', 'min_h', 'max_h', 'avg_h' ].to_set
75
75
  end
76
76
 
77
+ it 'renders hashes with all keys' do
78
+ @it = StatVal.new
79
+ all_keys = [ :num, :min, :max, :sum, :sq_sum, :std_ratio, :avg, :std, :avg_sq, :var ]
80
+ @it.to_hash(:all).keys.to_set.should be == all_keys.to_set
81
+ end
82
+
77
83
  it 'renders statvals with key renaming as if they were hashes' do
78
84
  @it = ::StatVal.flatmap_hash(StatVal.new, ::StatVal.key_hash(nil).tap {|h| h[:max] = :susi } ).keys.to_set
79
85
  @it.should be == ['min', 'susi', 'num', 'std', 'avg'].to_set
metadata CHANGED
@@ -1,18 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: statval
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
5
- prerelease:
4
+ prerelease:
5
+ version: 0.1.3
6
6
  platform: ruby
7
7
  authors:
8
8
  - Stefan Plantikow
9
- autorequire:
9
+ autorequire:
10
10
  bindir: script
11
11
  cert_chain: []
12
- date: 2012-04-17 00:00:00.000000000 Z
12
+ date: 2012-06-27 00:00:00.000000000Z
13
13
  dependencies: []
14
- description: Utility class for incrementally recording measured values and reporting
15
- avg, variance, min, and max
14
+ description: Utility class for incrementally recording measured values and reporting avg, variance, min, and max
16
15
  email: stefanp@moviepilot.com
17
16
  executables: []
18
17
  extensions: []
@@ -33,28 +32,30 @@ files:
33
32
  homepage: https://github.com/moviepilot/statval
34
33
  licenses:
35
34
  - PUBLIC DOMAIN WITHOUT ANY WARRANTY
36
- post_install_message:
35
+ post_install_message:
37
36
  rdoc_options: []
38
37
  require_paths:
39
38
  - lib
40
39
  required_ruby_version: !ruby/object:Gem::Requirement
41
- none: false
42
40
  requirements:
43
41
  - - ! '>='
44
42
  - !ruby/object:Gem::Version
45
43
  version: '0'
46
- required_rubygems_version: !ruby/object:Gem::Requirement
47
44
  none: false
45
+ required_rubygems_version: !ruby/object:Gem::Requirement
48
46
  requirements:
49
47
  - - ! '>='
50
48
  - !ruby/object:Gem::Version
51
49
  version: '0'
50
+ none: false
52
51
  requirements: []
53
52
  rubyforge_project: statval
54
- rubygems_version: 1.8.17
55
- signing_key:
53
+ rubygems_version: 1.8.15
54
+ signing_key:
56
55
  specification_version: 3
57
56
  summary: Very simple statistics collector
58
57
  test_files:
59
58
  - spec/lib/statval/statval_spec.rb
60
59
  - spec/spec_helper.rb
60
+ has_rdoc:
61
+ ...