active_graph 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +4 -0
- data/Manifest.txt +16 -0
- data/PostInstall.txt +7 -0
- data/README.rdoc +130 -0
- data/Rakefile +29 -0
- data/init.rb +3 -0
- data/lib/active_graph/active_record_extension.rb +78 -0
- data/lib/active_graph.rb +18 -0
- data/rails/init.rb +3 -0
- data/script/console +10 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/spec/active_graph_spec.rb +148 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +10 -0
- data/tasks/rspec.rake +21 -0
- metadata +122 -0
data/History.txt
ADDED
data/Manifest.txt
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
History.txt
|
2
|
+
Manifest.txt
|
3
|
+
PostInstall.txt
|
4
|
+
README.rdoc
|
5
|
+
Rakefile
|
6
|
+
lib/active_graph.rb
|
7
|
+
lib/active_graph/active_record_extension.rb
|
8
|
+
script/console
|
9
|
+
script/destroy
|
10
|
+
script/generate
|
11
|
+
spec/active_graph_spec.rb
|
12
|
+
spec/spec.opts
|
13
|
+
spec/spec_helper.rb
|
14
|
+
tasks/rspec.rake
|
15
|
+
rails/init.rb
|
16
|
+
init.rb
|
data/PostInstall.txt
ADDED
data/README.rdoc
ADDED
@@ -0,0 +1,130 @@
|
|
1
|
+
= active_graph
|
2
|
+
|
3
|
+
http://github.com/kazjote/active_graph/tree/master
|
4
|
+
|
5
|
+
== DESCRIPTION:
|
6
|
+
|
7
|
+
Gem which makes filling data for Gruff graphs based on ActiveRecord objects much easier.
|
8
|
+
|
9
|
+
== FEATURES/PROBLEMS:
|
10
|
+
|
11
|
+
Good points:
|
12
|
+
* Ease of use
|
13
|
+
* Flexible
|
14
|
+
* Created in model but enable to customize presentation in controller
|
15
|
+
|
16
|
+
Bad points:
|
17
|
+
* Slow - requires many database calls (it is intended to create cacheable graphs)
|
18
|
+
* Do not allow to customize options after model is loaded (TODO)
|
19
|
+
|
20
|
+
== SYNOPSIS:
|
21
|
+
|
22
|
+
The simplies case (mosts are defaults - you probably won't use it):
|
23
|
+
|
24
|
+
|
25
|
+
class User < ActiveRecord::Base
|
26
|
+
active_graph :posts,
|
27
|
+
:series => {:submited_posts => {:value => :count_have_posts_between, :caption => "posts"}}
|
28
|
+
|
29
|
+
def self.count_have_posts_between(min, max)
|
30
|
+
count(:all, :conditions => "posts_count > #{min} AND posts_count <= #{max}")
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
Now, featured one. It will create a line graph, which
|
35
|
+
* starts at User.start_time,
|
36
|
+
* end one week later
|
37
|
+
* shows data with 1 day step
|
38
|
+
* defines x_axis with formated labels
|
39
|
+
* presents 2 data series
|
40
|
+
|
41
|
+
|
42
|
+
class User < ActiveRecord::Base
|
43
|
+
|
44
|
+
active_graph :new_posts,
|
45
|
+
:type => :line,
|
46
|
+
:start => Proc.new {@@start_time}, :end => Proc.new { @@start_time + 1.week },
|
47
|
+
:step => 1.day,
|
48
|
+
:x_axis => {:interval => 3, :method => Proc.new {|time| time.strftime("%d-%m") }},
|
49
|
+
:width => 100,
|
50
|
+
:series => {:submited_posts => {:value => :count_have_posts_between, :caption => "posts"},
|
51
|
+
:submited_posts2 => {:value => :count_have_posts2_between, :caption => "posts2"}}
|
52
|
+
|
53
|
+
def self.count_have_posts_between(min, max); end
|
54
|
+
def self.count_have_posts2_between(min, max); end
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
Statistic on user age?
|
59
|
+
|
60
|
+
active_graph :age, :type => :bar,
|
61
|
+
:start => 0, :end => 100, :step => 10,
|
62
|
+
:x_axis => {:interval => 1, :method => Proc.new {|age| "#{age}-#{age + 10}" }},
|
63
|
+
:series => {
|
64
|
+
:age => {:value => :count_aged_between, :caption => "Age" }
|
65
|
+
}
|
66
|
+
|
67
|
+
Now, create an action in your controller:
|
68
|
+
|
69
|
+
class UsersController < ApplicationController
|
70
|
+
def new_posts_graph
|
71
|
+
graph = User.new_posts_graph
|
72
|
+
send_data graph.to_blob, :type => "image/png", :disposition => "inline",
|
73
|
+
:filename => "new_users_graph.png"
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
graph is a normal Gruff object, so you can customize presentation before rendering.
|
78
|
+
|
79
|
+
== REQUIREMENTS:
|
80
|
+
|
81
|
+
* gem 'activesupport' >= 2.0.2
|
82
|
+
* gem 'metaid' >= 1.0
|
83
|
+
* gem 'gruff' >= 0.3.1
|
84
|
+
|
85
|
+
It can run without Rails (testcase does not use rails at all).
|
86
|
+
|
87
|
+
== INSTALL:
|
88
|
+
|
89
|
+
* sudo gem install active_graph
|
90
|
+
|
91
|
+
In your envrionment.rb:
|
92
|
+
|
93
|
+
config.gem "metaid"
|
94
|
+
config.gem "gruff"
|
95
|
+
config.gem "active_graph"
|
96
|
+
|
97
|
+
If you have older rails you can load it with initializer or directly in your model:
|
98
|
+
|
99
|
+
require 'gruff'
|
100
|
+
require 'active_graph'
|
101
|
+
|
102
|
+
class User < ActiveRecord::Base
|
103
|
+
extend ActiveGraph::ActiveRecordExtension
|
104
|
+
...
|
105
|
+
end
|
106
|
+
|
107
|
+
== LICENSE:
|
108
|
+
|
109
|
+
(The MIT License)
|
110
|
+
|
111
|
+
Copyright (c) 2008 FIXME full name
|
112
|
+
|
113
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
114
|
+
a copy of this software and associated documentation files (the
|
115
|
+
'Software'), to deal in the Software without restriction, including
|
116
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
117
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
118
|
+
permit persons to whom the Software is furnished to do so, subject to
|
119
|
+
the following conditions:
|
120
|
+
|
121
|
+
The above copyright notice and this permission notice shall be
|
122
|
+
included in all copies or substantial portions of the Software.
|
123
|
+
|
124
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
125
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
126
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
127
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
128
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
129
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
130
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
%w[rubygems rake rake/clean fileutils newgem rubigen].each { |f| require f }
|
2
|
+
require File.dirname(__FILE__) + '/lib/active_graph'
|
3
|
+
|
4
|
+
# Generate all the Rake tasks
|
5
|
+
# Run 'rake -T' to see list of generated tasks (from gem root directory)
|
6
|
+
$hoe = Hoe.new('active_graph', ActiveGraph::VERSION) do |p|
|
7
|
+
p.developer('Kacper Bielecki', 'kazjote@gmail.com')
|
8
|
+
p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
|
9
|
+
p.rubyforge_name = 'activegraph'
|
10
|
+
p.extra_deps = [
|
11
|
+
['activesupport','>= 2.0.2'],
|
12
|
+
['metaid', '>= 1.0'],
|
13
|
+
['gruff', '>= 0.3.1']
|
14
|
+
]
|
15
|
+
p.extra_dev_deps = [
|
16
|
+
['newgem', ">= #{::Newgem::VERSION}"]
|
17
|
+
]
|
18
|
+
|
19
|
+
p.clean_globs |= %w[**/.DS_Store tmp *.log]
|
20
|
+
path = (p.rubyforge_name == p.name) ? p.rubyforge_name : "\#{p.rubyforge_name}/\#{p.name}"
|
21
|
+
p.remote_rdoc_dir = File.join(path.gsub(/^#{p.rubyforge_name}\/?/,''), 'rdoc')
|
22
|
+
p.rsync_args = '-av --delete --ignore-errors'
|
23
|
+
end
|
24
|
+
|
25
|
+
require 'newgem/tasks' # load /tasks/*.rake
|
26
|
+
Dir['tasks/**/*.rake'].each { |t| load t }
|
27
|
+
|
28
|
+
# TODO - want other tests/tasks run by default? Add them to the list
|
29
|
+
# task :default => [:spec, :features]
|
data/init.rb
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'metaid'
|
3
|
+
|
4
|
+
module ActiveGraph
|
5
|
+
module Support # :nodoc:
|
6
|
+
def self.valualize(value_or_proc)
|
7
|
+
value_or_proc.is_a?(Proc) ? value_or_proc.call : value_or_proc
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
module ActiveRecordExtension
|
12
|
+
# See README for examples and ActiveGraph for defaults.
|
13
|
+
#
|
14
|
+
# Available options are:
|
15
|
+
# * :start - proc or value - first value taken into consideration while creating a graph
|
16
|
+
# * :end - proc or value - last value
|
17
|
+
# * :step - x-axis step
|
18
|
+
# * :type - type of the graph (for example :line, :bar, see gruff documentation for other)
|
19
|
+
# * :width - target width of the image
|
20
|
+
# * :x_axis - options for x_axis
|
21
|
+
# * :series - data series
|
22
|
+
#
|
23
|
+
# x_axis is a hash with following keys allowed:
|
24
|
+
# * :interval - number of steps between two value labels
|
25
|
+
# * :method - proc which creates the label for particular x point
|
26
|
+
#
|
27
|
+
# series is a hash, which keys are the symbols of data series and value is a hash with following keys:
|
28
|
+
# * :value - symbol of the two argument method which gathers data for the graph
|
29
|
+
# * :caption - caption
|
30
|
+
def active_graph(name, options)
|
31
|
+
graph_start = options[:start] || ActiveGraph::DEFAULT_START
|
32
|
+
graph_end = options[:end] || ActiveGraph::DEFAULT_END
|
33
|
+
graph_type = options[:type] || ActiveGraph::DEFAULT_TYPE
|
34
|
+
width = options[:width] || ActiveGraph::DEFAULT_WIDTH
|
35
|
+
step = options[:step] || ActiveGraph::DEFAULT_STEP
|
36
|
+
x_axis_interval = (options[:x_axis] && options[:x_axis][:interval]) ||
|
37
|
+
ActiveGraph::DEFAULT_X_AXIS_INTERVAL
|
38
|
+
x_axis_method = (options[:x_axis] && options[:x_axis][:method]) ||
|
39
|
+
ActiveGraph::DEFAULT_X_AXIS_METHOD
|
40
|
+
series = options[:series]
|
41
|
+
raise "You must provide at least one data serie" unless series.is_a?(Hash)
|
42
|
+
|
43
|
+
graph_class = begin
|
44
|
+
"Gruff::#{graph_type.to_s.camelize}".constantize
|
45
|
+
rescue NameError
|
46
|
+
raise "No such graph type '#{graph_type}'"
|
47
|
+
end
|
48
|
+
|
49
|
+
meta_def("#{name}_graph") do
|
50
|
+
local_graph_start = Support.valualize(graph_start)
|
51
|
+
local_graph_end = Support.valualize(graph_end)
|
52
|
+
periods_count = ((local_graph_end - local_graph_start) / step).ceil
|
53
|
+
g = graph_class.new(width)
|
54
|
+
|
55
|
+
series.each_pair do |serie_name, serie_options|
|
56
|
+
data_method = serie_options[:value]
|
57
|
+
caption = serie_options[:caption]
|
58
|
+
|
59
|
+
data = Array.new(periods_count) do |i|
|
60
|
+
period_start = local_graph_start + i * step
|
61
|
+
period_end = period_start + step
|
62
|
+
send(data_method, period_start, period_end)
|
63
|
+
end
|
64
|
+
g.data(caption, data)
|
65
|
+
end
|
66
|
+
|
67
|
+
labels = Array.new((periods_count / x_axis_interval.to_f).ceil) do |i|
|
68
|
+
period_start = local_graph_start + i * x_axis_interval * step
|
69
|
+
label = x_axis_method.is_a?(Proc) ?
|
70
|
+
x_axis_method.call(period_start) : self.send(x_axis_method, period_start)
|
71
|
+
[i * x_axis_interval, label]
|
72
|
+
end.flatten
|
73
|
+
g.labels = Hash[*labels]
|
74
|
+
g
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
data/lib/active_graph.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
$:.unshift(File.dirname(__FILE__)) unless
|
2
|
+
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
3
|
+
|
4
|
+
require 'active_graph/active_record_extension'
|
5
|
+
require 'rubygems'
|
6
|
+
require 'activesupport'
|
7
|
+
|
8
|
+
module ActiveGraph
|
9
|
+
VERSION = '0.0.2'
|
10
|
+
|
11
|
+
DEFAULT_START = 0
|
12
|
+
DEFAULT_END = 7
|
13
|
+
DEFAULT_TYPE = :bar
|
14
|
+
DEFAULT_STEP = 1
|
15
|
+
DEFAULT_X_AXIS_INTERVAL = 1
|
16
|
+
DEFAULT_X_AXIS_METHOD = Proc.new {|x| "#{x} - #{x + ActiveGraph::DEFAULT_X_AXIS_INTERVAL}"}
|
17
|
+
DEFAULT_WIDTH=400
|
18
|
+
end
|
data/rails/init.rb
ADDED
data/script/console
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# File: script/console
|
3
|
+
irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
|
4
|
+
|
5
|
+
libs = " -r irb/completion"
|
6
|
+
# Perhaps use a console_lib to store any extra methods I may want available in the cosole
|
7
|
+
# libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
|
8
|
+
libs << " -r #{File.dirname(__FILE__) + '/../lib/active_graph.rb'}"
|
9
|
+
puts "Loading active_graph gem"
|
10
|
+
exec "#{irb} #{libs} --simple-prompt"
|
data/script/destroy
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'rubigen'
|
6
|
+
rescue LoadError
|
7
|
+
require 'rubygems'
|
8
|
+
require 'rubigen'
|
9
|
+
end
|
10
|
+
require 'rubigen/scripts/destroy'
|
11
|
+
|
12
|
+
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
+
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
14
|
+
RubiGen::Scripts::Destroy.new.run(ARGV)
|
data/script/generate
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'rubigen'
|
6
|
+
rescue LoadError
|
7
|
+
require 'rubygems'
|
8
|
+
require 'rubigen'
|
9
|
+
end
|
10
|
+
require 'rubigen/scripts/generate'
|
11
|
+
|
12
|
+
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
+
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
14
|
+
RubiGen::Scripts::Generate.new.run(ARGV)
|
@@ -0,0 +1,148 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
|
+
|
3
|
+
module Gruff # :nodoc:all
|
4
|
+
module BasicMethods
|
5
|
+
attr_accessor :labels
|
6
|
+
attr_accessor :width
|
7
|
+
|
8
|
+
def data(label, data); end
|
9
|
+
|
10
|
+
def initialize(width)
|
11
|
+
@width = width
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
class Bar
|
16
|
+
include BasicMethods
|
17
|
+
end
|
18
|
+
|
19
|
+
class Line
|
20
|
+
include BasicMethods
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
class ActiveGraphTestModel # :nodoc:
|
25
|
+
extend ActiveGraph::ActiveRecordExtension
|
26
|
+
|
27
|
+
attr_accessor :start_time
|
28
|
+
|
29
|
+
active_graph :posts,
|
30
|
+
:series => {:submited_posts => {:value => :count_have_posts_between, :caption => "posts"}}
|
31
|
+
|
32
|
+
active_graph :new_posts,
|
33
|
+
:type => :line,
|
34
|
+
:start => Proc.new {@@start_time}, :end => Proc.new { @@start_time + 1.week },
|
35
|
+
:step => 1.day,
|
36
|
+
:x_axis => {:interval => 3, :method => Proc.new {|time| time.strftime("%d-%m") }},
|
37
|
+
:width => 100,
|
38
|
+
:series => {:submited_posts => {:value => :count_have_posts_between, :caption => "posts"},
|
39
|
+
:submited_posts2 => {:value => :count_have_posts2_between, :caption => "posts2"}}
|
40
|
+
|
41
|
+
def self.count_have_posts_between(min, max); end
|
42
|
+
def self.count_have_posts2_between(min, max); end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe "ActiveGraph" do
|
46
|
+
it "should define method for creating the graph" do
|
47
|
+
ActiveGraphTestModel.respond_to?(:posts_graph).should be_true
|
48
|
+
end
|
49
|
+
|
50
|
+
describe "while based on defaults" do
|
51
|
+
before do
|
52
|
+
@graph = Gruff::Bar.new(400)
|
53
|
+
Gruff::Bar.should_receive(:new).with(400).and_return(@graph)
|
54
|
+
default_start = ActiveGraph::DEFAULT_START
|
55
|
+
default_end = ActiveGraph::DEFAULT_END
|
56
|
+
@number_of_periods = default_end - default_start
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should gather data from default number of periods" do
|
60
|
+
@number_of_periods.times do |i|
|
61
|
+
ActiveGraphTestModel.should_receive(:count_have_posts_between).
|
62
|
+
with(i, i+1)
|
63
|
+
end
|
64
|
+
ActiveGraphTestModel.posts_graph
|
65
|
+
end
|
66
|
+
|
67
|
+
it "should set correct labels" do
|
68
|
+
labels = Hash[*Array.new(@number_of_periods) {|i| [i, "#{i} - #{i+1}"]}.flatten]
|
69
|
+
ActiveGraphTestModel.posts_graph
|
70
|
+
@graph.labels.should == labels
|
71
|
+
end
|
72
|
+
|
73
|
+
it "should set data properly" do
|
74
|
+
@number_of_periods.times do |i|
|
75
|
+
ActiveGraphTestModel.should_receive(:count_have_posts_between).
|
76
|
+
with(i, i+1).and_return(i)
|
77
|
+
end
|
78
|
+
data = Array.new(@number_of_periods) {|i| i}
|
79
|
+
@graph.should_receive(:data).with("posts", data)
|
80
|
+
ActiveGraphTestModel.posts_graph
|
81
|
+
end
|
82
|
+
|
83
|
+
it "should create the graph" do
|
84
|
+
ActiveGraphTestModel.posts_graph.should == @graph
|
85
|
+
end
|
86
|
+
|
87
|
+
it "should set default width" do
|
88
|
+
ActiveGraphTestModel.posts_graph.width.should == 400
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
describe "while used with all custom parameters" do
|
93
|
+
before do
|
94
|
+
@start_time = Time.now - 1.month
|
95
|
+
ActiveGraphTestModel.send(:class_variable_set, :@@start_time, @start_time)
|
96
|
+
end
|
97
|
+
|
98
|
+
it "should raise error on unknown graph type" do
|
99
|
+
lambda do
|
100
|
+
ActiveGraphTestModel.active_graph :wrong_type,
|
101
|
+
:type => :unknown,
|
102
|
+
:series => {:submited_posts => {:value => :count_have_posts_between,
|
103
|
+
:caption => "posts"}}
|
104
|
+
end.should raise_error
|
105
|
+
end
|
106
|
+
|
107
|
+
it "should be possible to specify start and end options with proc and step with value" do
|
108
|
+
7.times do |i|
|
109
|
+
ActiveGraphTestModel.should_receive(:count_have_posts_between).
|
110
|
+
with(@start_time + i.days, @start_time + (i + 1).days)
|
111
|
+
end
|
112
|
+
ActiveGraphTestModel.new_posts_graph
|
113
|
+
end
|
114
|
+
|
115
|
+
it "should set correct width" do
|
116
|
+
ActiveGraphTestModel.new_posts_graph.width.should == 100
|
117
|
+
end
|
118
|
+
|
119
|
+
describe "and drawing the graph" do
|
120
|
+
before do
|
121
|
+
@graph = Gruff::Line.new(400)
|
122
|
+
Gruff::Line.should_receive(:new).and_return(@graph)
|
123
|
+
end
|
124
|
+
|
125
|
+
it "should be possible to specify graph type" do
|
126
|
+
ActiveGraphTestModel.new_posts_graph.class.should == Gruff::Line
|
127
|
+
end
|
128
|
+
|
129
|
+
it "should be possible to specify many series" do
|
130
|
+
@graph.should_receive(:data).with("posts", an_instance_of(Array))
|
131
|
+
@graph.should_receive(:data).with("posts2", an_instance_of(Array))
|
132
|
+
ActiveGraphTestModel.new_posts_graph
|
133
|
+
end
|
134
|
+
|
135
|
+
it "should be possible to set x_axis interval" do
|
136
|
+
ActiveGraphTestModel.new_posts_graph
|
137
|
+
@graph.labels.keys.sort.should == [0, 3, 6]
|
138
|
+
end
|
139
|
+
|
140
|
+
it "should be possible to specify x_axis labeling method" do
|
141
|
+
ActiveGraphTestModel.new_posts_graph
|
142
|
+
@graph.labels.should == {0 => @start_time.strftime("%d-%m"),
|
143
|
+
3 => (@start_time + 3.days).strftime("%d-%m"),
|
144
|
+
6 => (@start_time + 6.days).strftime("%d-%m")}
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
data/spec/spec.opts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--colour
|
data/spec/spec_helper.rb
ADDED
data/tasks/rspec.rake
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
begin
|
2
|
+
require 'spec'
|
3
|
+
rescue LoadError
|
4
|
+
require 'rubygems'
|
5
|
+
require 'spec'
|
6
|
+
end
|
7
|
+
begin
|
8
|
+
require 'spec/rake/spectask'
|
9
|
+
rescue LoadError
|
10
|
+
puts <<-EOS
|
11
|
+
To use rspec for testing you must install rspec gem:
|
12
|
+
gem install rspec
|
13
|
+
EOS
|
14
|
+
exit(0)
|
15
|
+
end
|
16
|
+
|
17
|
+
desc "Run the specs under spec/models"
|
18
|
+
Spec::Rake::SpecTask.new do |t|
|
19
|
+
t.spec_opts = ['--options', "spec/spec.opts"]
|
20
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
21
|
+
end
|
metadata
ADDED
@@ -0,0 +1,122 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: active_graph
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Kacper Bielecki
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-01-02 00:00:00 +01:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: activesupport
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 2.0.2
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: metaid
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: "1.0"
|
34
|
+
version:
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: gruff
|
37
|
+
type: :runtime
|
38
|
+
version_requirement:
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 0.3.1
|
44
|
+
version:
|
45
|
+
- !ruby/object:Gem::Dependency
|
46
|
+
name: newgem
|
47
|
+
type: :development
|
48
|
+
version_requirement:
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 1.2.3
|
54
|
+
version:
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: hoe
|
57
|
+
type: :development
|
58
|
+
version_requirement:
|
59
|
+
version_requirements: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: 1.8.0
|
64
|
+
version:
|
65
|
+
description: Gem which makes filling data for Gruff graphs based on ActiveRecord objects much easier.
|
66
|
+
email:
|
67
|
+
- kazjote@gmail.com
|
68
|
+
executables: []
|
69
|
+
|
70
|
+
extensions: []
|
71
|
+
|
72
|
+
extra_rdoc_files:
|
73
|
+
- History.txt
|
74
|
+
- Manifest.txt
|
75
|
+
- PostInstall.txt
|
76
|
+
- README.rdoc
|
77
|
+
files:
|
78
|
+
- History.txt
|
79
|
+
- Manifest.txt
|
80
|
+
- PostInstall.txt
|
81
|
+
- README.rdoc
|
82
|
+
- Rakefile
|
83
|
+
- lib/active_graph.rb
|
84
|
+
- lib/active_graph/active_record_extension.rb
|
85
|
+
- script/console
|
86
|
+
- script/destroy
|
87
|
+
- script/generate
|
88
|
+
- spec/active_graph_spec.rb
|
89
|
+
- spec/spec.opts
|
90
|
+
- spec/spec_helper.rb
|
91
|
+
- tasks/rspec.rake
|
92
|
+
- rails/init.rb
|
93
|
+
- init.rb
|
94
|
+
has_rdoc: true
|
95
|
+
homepage: http://github.com/kazjote/active_graph/tree/master
|
96
|
+
post_install_message:
|
97
|
+
rdoc_options:
|
98
|
+
- --main
|
99
|
+
- README.rdoc
|
100
|
+
require_paths:
|
101
|
+
- lib
|
102
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: "0"
|
107
|
+
version:
|
108
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
109
|
+
requirements:
|
110
|
+
- - ">="
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: "0"
|
113
|
+
version:
|
114
|
+
requirements: []
|
115
|
+
|
116
|
+
rubyforge_project: activegraph
|
117
|
+
rubygems_version: 1.2.0
|
118
|
+
signing_key:
|
119
|
+
specification_version: 2
|
120
|
+
summary: Gem which makes filling data for Gruff graphs based on ActiveRecord objects much easier.
|
121
|
+
test_files: []
|
122
|
+
|