graphite_builder 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.2
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{graphite_builder}
8
- s.version = "0.0.1"
8
+ s.version = "0.0.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = [%q{Edward Muller}]
@@ -15,11 +15,12 @@ module Graphite
15
15
  # specific function signature
16
16
  class UnknownFunctionSignature < RuntimeError; end
17
17
 
18
- def initialize(opts=nil, &block)
19
- @args = {}
18
+ # args are optional arguments for constructing the url
19
+ # opts are data to retrieve
20
+ def initialize(args={}, opts=nil, &block)
21
+ @args = args
20
22
  @targets = []
21
23
  data opts
22
- @args[:base_url] = @data.delete(:base_url) if @data[:base_url]
23
24
  if block
24
25
  self.instance_eval(&block)
25
26
  end
@@ -20,7 +20,7 @@ describe Graphite::Builder do
20
20
 
21
21
  describe 'whithout using data' do
22
22
  it 'should render the correct <img/> tag' do
23
- Graphite::Builder.new(base_url: 'http://localhost/render', foo: :bar) do
23
+ Graphite::Builder.new({base_url: 'http://localhost/render'}, {foo: :bar}) do
24
24
  target '1.2.3'
25
25
  end.render.must_equal '<img src="http://localhost/render?target=1.2.3"/>'
26
26
  end
@@ -28,7 +28,7 @@ describe Graphite::Builder do
28
28
 
29
29
  describe 'using data' do
30
30
  it 'should render the correct <img/> tag' do
31
- Graphite::Builder.new(base_url: 'http://localhost/render', foo: :bar) do
31
+ Graphite::Builder.new({base_url: 'http://localhost/render'}, {foo: :bar}) do
32
32
  target data :foo
33
33
  target "#{data :foo}.stuff"
34
34
  end.render.must_equal '<img src="http://localhost/render?target=bar&target=bar.stuff"/>'
@@ -37,7 +37,7 @@ describe Graphite::Builder do
37
37
  describe 'setting params' do
38
38
 
39
39
  it 'should render the correct <img/> tag' do
40
- Graphite::Builder.new(base_url: 'http://localhost/render', foo: :bar) do
40
+ Graphite::Builder.new({base_url: 'http://localhost/render'}, {foo: :bar}) do
41
41
  width 800
42
42
  height 200
43
43
  target 'a.b.c'
@@ -47,7 +47,7 @@ describe Graphite::Builder do
47
47
 
48
48
  describe 'and applying a "function"' do
49
49
  it 'should render the correct <img/> tag' do
50
- Graphite::Builder.new(base_url: 'http://localhost/render', foo: :bar) do
50
+ Graphite::Builder.new({base_url: 'http://localhost/render'}, {foo: :bar}) do
51
51
  target data :foo
52
52
  target color("#{data :foo}.stuff", 'red')
53
53
  end.render.must_equal "<img src=\"http://localhost/render?target=bar&target=color(bar.stuff,'red')\"/>"
@@ -56,7 +56,7 @@ describe Graphite::Builder do
56
56
 
57
57
  describe 'and nesting functions' do
58
58
  it 'should render the correct <img/> tag' do
59
- Graphite::Builder.new(base_url: 'http://localhost/render', foo: :bar) do
59
+ Graphite::Builder.new({base_url: 'http://localhost/render'}, {foo: :bar}) do
60
60
  target data :foo
61
61
  target legend(color("#{data :foo}.stuff", 'red'), 'foozle')
62
62
  end.render.must_equal "<img src=\"http://localhost/render?target=bar&target=alias(color(bar.stuff,'red'),'foozle')\"/>"
@@ -73,7 +73,7 @@ describe Graphite::Builder do
73
73
 
74
74
  describe 'with a single data point' do
75
75
  it 'should render the correct <img/> tag' do
76
- Graphite::Builder.new(base_url: 'http://localhost/render', foo: :bar) do
76
+ Graphite::Builder.new({base_url: 'http://localhost/render'}, {foo: :bar}) do
77
77
  target sumSeries('a.b.*')
78
78
  end.render.must_equal "<img src=\"http://localhost/render?target=sumSeries(a.b.*)\"/>"
79
79
  end
@@ -81,7 +81,7 @@ describe Graphite::Builder do
81
81
 
82
82
  describe 'with multiple data points' do
83
83
  it 'should render the correct <img/> tag' do
84
- Graphite::Builder.new(base_url: 'http://localhost/render', foo: :bar) do
84
+ Graphite::Builder.new({base_url: 'http://localhost/render'}, {foo: :bar}) do
85
85
  target sumSeries('a.b.*','a.c.*','a.d.*')
86
86
  end.render.must_equal "<img src=\"http://localhost/render?target=sumSeries(a.b.*,a.c.*,a.d.*)\"/>"
87
87
  end
@@ -93,7 +93,7 @@ describe Graphite::Builder do
93
93
  describe 'with a single argument' do
94
94
  it 'should raise an ArgumentError' do
95
95
  Proc.new do
96
- Graphite::Builder.new(base_url: 'http://localhost/render', foo: :bar) do
96
+ Graphite::Builder.new({base_url: 'http://localhost/render'}, {foo: :bar}) do
97
97
  target asPercent(1)
98
98
  end.render
99
99
  end.must_raise ArgumentError
@@ -102,7 +102,7 @@ describe Graphite::Builder do
102
102
 
103
103
  describe 'with two arguments' do
104
104
  it 'should render the correct <img/> tag' do
105
- Graphite::Builder.new(base_url: 'http://localhost/render', foo: :bar) do
105
+ Graphite::Builder.new({base_url: 'http://localhost/render'}, {foo: :bar}) do
106
106
  target asPercent('a.b.c','a.c.b')
107
107
  end.render.must_equal "<img src=\"http://localhost/render?target=asPercent(a.b.c,a.c.b)\"/>"
108
108
  end
@@ -113,7 +113,7 @@ describe Graphite::Builder do
113
113
 
114
114
  describe 'with a single argument' do
115
115
  it 'should render the correct <img/> tag' do
116
- Graphite::Builder.new(base_url: 'http://localhost/render', foo: :bar) do
116
+ Graphite::Builder.new({base_url: 'http://localhost/render'}, {foo: :bar}) do
117
117
  target secondYAxis('a.b.c')
118
118
  end.render.must_equal "<img src=\"http://localhost/render?target=secondYAxis(a.b.c)\"/>"
119
119
  end
@@ -125,7 +125,7 @@ describe Graphite::Builder do
125
125
 
126
126
  describe 'with a single argument' do
127
127
  it 'should render the correct <img/> tag' do
128
- Graphite::Builder.new(base_url: 'http://localhost/render', foo: :bar) do
128
+ Graphite::Builder.new({base_url: 'http://localhost/render'}, {foo: :bar}) do
129
129
  target stacked('a.b.c')
130
130
  end.render.must_equal "<img src=\"http://localhost/render?target=stacked(a.b.c)\"/>"
131
131
  end
@@ -137,7 +137,7 @@ describe Graphite::Builder do
137
137
 
138
138
  describe 'with a single argument' do
139
139
  it 'should render the correct <img/> tag' do
140
- Graphite::Builder.new(base_url: 'http://localhost/render', foo: :bar) do
140
+ Graphite::Builder.new({base_url: 'http://localhost/render'}, {foo: :bar}) do
141
141
  target legend('a.b.c','A B C')
142
142
  end.render.must_equal "<img src=\"http://localhost/render?target=alias(a.b.c,'A+B+C')\"/>"
143
143
  end
@@ -149,7 +149,7 @@ describe Graphite::Builder do
149
149
 
150
150
  it 'should raise an UnknownFunctionSignature exception' do
151
151
  Proc.new do
152
- Graphite::Builder.new(base_url: 'http://localhost/render', foo: :bar) do
152
+ Graphite::Builder.new({base_url: 'http://localhost/render'}, {foo: :bar}) do
153
153
  target blargen(1,2,3)
154
154
  end.render
155
155
  end.must_raise Graphite::Builder::UnknownFunctionSignature
@@ -162,8 +162,7 @@ describe Graphite::Builder do
162
162
  describe "some complex graphs" do
163
163
 
164
164
  it "should render the correct <img/> tag" do
165
-
166
- Graphite::Builder.new(:hostname => 'foo') do
165
+ Graphite::Builder.new({},:hostname => 'foo') do
167
166
  base_url 'http://my_graphite.host/render/'
168
167
  width 800
169
168
  height 200
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graphite_builder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2011-10-11 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: minitest
16
- requirement: &70338624977220 !ruby/object:Gem::Requirement
16
+ requirement: &70335347140140 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70338624977220
24
+ version_requirements: *70335347140140
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: bundler
27
- requirement: &70338624976320 !ruby/object:Gem::Requirement
27
+ requirement: &70335347139460 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 1.0.0
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70338624976320
35
+ version_requirements: *70335347139460
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: jeweler
38
- requirement: &70338624975440 !ruby/object:Gem::Requirement
38
+ requirement: &70335347138720 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 1.6.4
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70338624975440
46
+ version_requirements: *70335347138720
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rcov
49
- requirement: &70338624974560 !ruby/object:Gem::Requirement
49
+ requirement: &70335347137940 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,7 +54,7 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70338624974560
57
+ version_requirements: *70335347137940
58
58
  description: A DSL for generating graphite graph urls. Meant to enable copy-and-paste
59
59
  from the graphite UI + simple substitution.
60
60
  email: edward@heroku.com
@@ -90,7 +90,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
90
90
  version: '0'
91
91
  segments:
92
92
  - 0
93
- hash: 372793677429185885
93
+ hash: 3608623686595645941
94
94
  required_rubygems_version: !ruby/object:Gem::Requirement
95
95
  none: false
96
96
  requirements: