reparty 0.3.1 → 0.3.2

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.
data/History.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## 0.3.2
2
+
3
+ - Separate out graph types for counter and gauge graphs
4
+ - Rotate through colors for each graph to provide variety
5
+
1
6
  ## 0.3.1
2
7
 
3
8
  - Total graphs were off by one day
@@ -3,6 +3,7 @@ require 'active_record'
3
3
  module Reparty
4
4
  class Report
5
5
  class ActiveRecord < Report
6
+ @@color_index = 0
6
7
  attr_reader :model, :operation, :field
7
8
 
8
9
  def initialize(*args, &block)
@@ -27,9 +28,10 @@ module Reparty
27
28
  end
28
29
 
29
30
  def attach(attachments)
30
- @graph = build_daily_graph
31
+ @graph = @operation == :total ? build_daily_area_graph : build_daily_bar_graph
31
32
 
32
- @graph.data(@model.to_s.pluralize, daily_dataset)
33
+ @graph.data(@model.to_s.pluralize, daily_dataset, @graph.colors[@@color_index])
34
+ @@color_index = (@@color_index + 1) % @graph.colors.length
33
35
 
34
36
  attachments.inline["#{self.hash}.png"] = @graph.to_blob
35
37
  end
@@ -19,7 +19,7 @@ module Reparty
19
19
  end
20
20
 
21
21
  def attach(attachments)
22
- @graph = build_daily_graph
22
+ @graph = build_daily_line_graph
23
23
 
24
24
  %W{requests delivered bounces spamreports}.each do |stat|
25
25
  @graph.data(stat.capitalize, stats.map{|s| s.fetch(stat,0)})
@@ -16,8 +16,19 @@ module Reparty
16
16
 
17
17
  protected
18
18
 
19
- def build_daily_graph(start_date=DateTime.now.utc)
20
- g = Gruff::Line.new(545)
19
+ def build_daily_line_graph(start_date=DateTime.now.utc)
20
+ build_daily_graph(Gruff::Line.new(545), start_date)
21
+ end
22
+
23
+ def build_daily_area_graph(start_date=DateTime.now.utc)
24
+ build_daily_graph(Gruff::Area.new(545), start_date)
25
+ end
26
+
27
+ def build_daily_bar_graph(start_date=DateTime.now.utc)
28
+ build_daily_graph(Gruff::Bar.new(545), start_date)
29
+ end
30
+
31
+ def build_daily_graph(g, start_date)
21
32
  g.title = @title
22
33
  g.labels = Hash[*(1..7).map{|x| [x-1, (start_date - (8-x)).strftime("%-m/%-d")] }.flatten]
23
34
  g
@@ -1,3 +1,3 @@
1
1
  module Reparty
2
- VERSION = "0.3.1"
2
+ VERSION = "0.3.2"
3
3
  end
metadata CHANGED
@@ -2,14 +2,14 @@
2
2
  name: reparty
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.3.1
5
+ version: 0.3.2
6
6
  platform: ruby
7
7
  authors:
8
8
  - Tim Dorr
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-05-09 00:00:00.000000000 Z
12
+ date: 2013-05-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: railties
@@ -289,7 +289,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
289
289
  - !ruby/object:Gem::Version
290
290
  segments:
291
291
  - 0
292
- hash: 1855217469676328277
292
+ hash: -1981622501360385862
293
293
  version: '0'
294
294
  none: false
295
295
  required_rubygems_version: !ruby/object:Gem::Requirement
@@ -298,7 +298,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
298
298
  - !ruby/object:Gem::Version
299
299
  segments:
300
300
  - 0
301
- hash: 1855217469676328277
301
+ hash: -1981622501360385862
302
302
  version: '0'
303
303
  none: false
304
304
  requirements: []