grosser-db_graph 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +6 -3
- data/VERSION.yml +1 -1
- data/lib/db_graph/line.rb +6 -0
- data/spec/db_graph/line_spec.rb +12 -0
- metadata +2 -2
data/README.markdown
CHANGED
@@ -19,11 +19,14 @@ Or as Rails plugin:
|
|
19
19
|
|
20
20
|
Usage
|
21
21
|
=====
|
22
|
-
|
22
|
+
Static interface for single lines
|
23
|
+
DBGraph::Line.url(:weeks, User, :created_at, :at=>Time.now)
|
24
|
+
|
25
|
+
Or instance interface for multiple lines
|
23
26
|
g = DBGraph::Line.new(:weeks)
|
24
27
|
|
25
|
-
#hours/days/weeks/months in a selected interval (
|
26
|
-
g = DBGraph::Line.new(:weeks, :at=>Time.parse('2009-01-02
|
28
|
+
#minutes/hours/days/weeks/months in a selected interval (:at is expanded to a interval, here: 2009-2010)
|
29
|
+
g = DBGraph::Line.new(:weeks, :at=>Time.parse('2009-01-02'))
|
27
30
|
|
28
31
|
g.add(User, :created_at)
|
29
32
|
g.add(Item, :sold_at, :label=>'Things we sold')
|
data/VERSION.yml
CHANGED
data/lib/db_graph/line.rb
CHANGED
@@ -54,6 +54,12 @@ module DBGraph
|
|
54
54
|
distribute_evently(values, NUM_Y_LABELS)
|
55
55
|
end
|
56
56
|
|
57
|
+
def self.url(style, model, attribute, options={})
|
58
|
+
g = self.new(style, :at=>options.delete(:at))
|
59
|
+
g.add model, attribute, options
|
60
|
+
g.to_url
|
61
|
+
end
|
62
|
+
|
57
63
|
private
|
58
64
|
|
59
65
|
def x_values
|
data/spec/db_graph/line_spec.rb
CHANGED
@@ -215,4 +215,16 @@ describe DBGraph::Line do
|
|
215
215
|
@line.send(:random_color).should == '0022aa'
|
216
216
|
end
|
217
217
|
end
|
218
|
+
|
219
|
+
describe :url do
|
220
|
+
it "can be called with 3 arguments" do
|
221
|
+
url = DBGraph::Line.url(:weeks, Product, :created_at)
|
222
|
+
url.should =~ /^http/
|
223
|
+
end
|
224
|
+
|
225
|
+
it "can be called with at option" do
|
226
|
+
url = DBGraph::Line.url(:weeks, Product, :created_at, :at=>Time.now)
|
227
|
+
url.should =~ /^http/
|
228
|
+
end
|
229
|
+
end
|
218
230
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: grosser-db_graph
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Grosser
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-05-
|
12
|
+
date: 2009-05-26 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|