slate 1.0.0 → 1.0.1

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.
@@ -2,7 +2,21 @@ require 'json'
2
2
 
3
3
  module Slate
4
4
  module Calculation
5
+ def self.all
6
+ [Mean, Last]
7
+ end
8
+
5
9
  class Base
10
+ def self.name(name=nil)
11
+ return @name if name.nil?
12
+ @name = name
13
+ end
14
+
15
+ def self.description(description=nil)
16
+ return @description if description.nil?
17
+ @description = description
18
+ end
19
+
6
20
  def initialize(graph)
7
21
  @graph = graph
8
22
  end
@@ -1,6 +1,9 @@
1
1
  module Slate
2
2
  module Calculation
3
3
  class Last < Base
4
+ name "Last Point"
5
+ description "Returns the last point in each of the targets."
6
+
4
7
  protected
5
8
 
6
9
  def map(points)
@@ -1,6 +1,9 @@
1
1
  module Slate
2
2
  module Calculation
3
3
  class Mean < Base
4
+ name "Average"
5
+ description "Calculates the average of all points in each of the targets."
6
+
4
7
  protected
5
8
 
6
9
  def map(points)
@@ -1,3 +1,3 @@
1
1
  module Slate
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
@@ -17,6 +17,14 @@ describe Slate::Calculation::Last do
17
17
  @graph.stubs(:download).with(:json).returns(JSON.generate(data))
18
18
  end
19
19
 
20
+ it "should have a name" do
21
+ Slate::Calculation::Last.name.should == "Last Point"
22
+ end
23
+
24
+ it "should have a description" do
25
+ Slate::Calculation::Last.description.should == "Returns the last point in each of the targets."
26
+ end
27
+
20
28
  it "should calculate the mean of the series" do
21
29
  calculation = Slate::Calculation::Last.new(@graph)
22
30
  calculation.result.should == [{ "name" => "some.stat", "value" => 3.0 }]
@@ -17,6 +17,14 @@ describe Slate::Calculation::Mean do
17
17
  @graph.stubs(:download).with(:json).returns(JSON.generate(data))
18
18
  end
19
19
 
20
+ it "should have a name" do
21
+ Slate::Calculation::Mean.name.should == "Average"
22
+ end
23
+
24
+ it "should have a description" do
25
+ Slate::Calculation::Mean.description.should == "Calculates the average of all points in each of the targets."
26
+ end
27
+
20
28
  it "should calculate the mean of the series" do
21
29
  calculation = Slate::Calculation::Mean.new(@graph)
22
30
  calculation.result.should == [{ "name" => "some.stat", "value" => 1.5 }]
@@ -0,0 +1,7 @@
1
+ require File.join(File.dirname(__FILE__), '..', '..', 'spec_helper')
2
+
3
+ describe Slate::Calculation do
4
+ it "should list the available calculations" do
5
+ Slate::Calculation.all.should == [Slate::Calculation::Mean, Slate::Calculation::Last]
6
+ end
7
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slate
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
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-03-09 00:00:00.000000000 Z
12
+ date: 2013-03-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rest-client
@@ -183,6 +183,7 @@ files:
183
183
  - slate.gemspec
184
184
  - spec/lib/slate/calculation/last_spec.rb
185
185
  - spec/lib/slate/calculation/mean_spec.rb
186
+ - spec/lib/slate/calculation_spec.rb
186
187
  - spec/lib/slate/graph_spec.rb
187
188
  - spec/lib/slate/parser_spec.rb
188
189
  - spec/lib/slate_spec.rb
@@ -201,7 +202,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
201
202
  version: '0'
202
203
  segments:
203
204
  - 0
204
- hash: 4327532724324902652
205
+ hash: 454332446908567553
205
206
  required_rubygems_version: !ruby/object:Gem::Requirement
206
207
  none: false
207
208
  requirements:
@@ -210,7 +211,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
210
211
  version: '0'
211
212
  segments:
212
213
  - 0
213
- hash: 4327532724324902652
214
+ hash: 454332446908567553
214
215
  requirements: []
215
216
  rubyforge_project:
216
217
  rubygems_version: 1.8.23
@@ -220,6 +221,7 @@ summary: Simple wrapper on top of the graphite render api
220
221
  test_files:
221
222
  - spec/lib/slate/calculation/last_spec.rb
222
223
  - spec/lib/slate/calculation/mean_spec.rb
224
+ - spec/lib/slate/calculation_spec.rb
223
225
  - spec/lib/slate/graph_spec.rb
224
226
  - spec/lib/slate/parser_spec.rb
225
227
  - spec/lib/slate_spec.rb