graphite-dashboard-api 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/graphite_dashboard_api.gemspec +1 -1
- data/lib/graphite-dashboard-api.rb +1 -0
- data/lib/graphite-dashboard-api/extra_options.rb +27 -0
- data/lib/graphite-dashboard-api/graph.rb +7 -0
- data/spec/graph_spec.rb +13 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2986b39ea2e5915a6fe7f54b9b891b9ddc84b869
|
4
|
+
data.tar.gz: dbf8d5a884fdf4ec775694fd2d9bef170d557ca0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 179c205d7101339b6ff71166baa163889e7cd8ece666f9e9cabf5c402008cb93f0f3aecb0e8d3f3fd48e7274c90bbc81f2063fc12c2988682fc48a709dd43f64
|
7
|
+
data.tar.gz: 71e130024a27b3b19e616846e440c5402bae3718ac0e3c1ac164b9ea3ebf362396fddbba1e8f087e2a80285a9bfa3f1ce33222a36648c8de3a9c93261b283d4a
|
data/README.md
CHANGED
@@ -2,6 +2,8 @@ Graphite Dashboard API
|
|
2
2
|
----------------------
|
3
3
|
|
4
4
|
[![Build Status](https://travis-ci.org/criteo/graphite-dashboard-api.png?branch=master)](https://travis-ci.org/criteo/graphite-dashboard-api)
|
5
|
+
[![Gem Version](https://badge.fury.io/rb/graphite-dashboard-api.png)](http://badge.fury.io/rb/graphite-dashboard-api)
|
6
|
+
[![Dependency Status](https://gemnasium.com/criteo/graphite-dashboard-api.png)](https://gemnasium.com/criteo/graphite-dashboard-api)
|
5
7
|
|
6
8
|
|
7
9
|
Graphite dashboard api is a ruby gem which help to create and update graphite dashboards.
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module GraphiteDashboardApi
|
2
|
+
module ExtraOptions
|
3
|
+
attr_accessor :extra_options
|
4
|
+
def method_missing(m, *args)
|
5
|
+
if args && args.size > 0
|
6
|
+
@extra_options[m.to_s] = args[0]
|
7
|
+
end
|
8
|
+
@extra_options[m.to_s]
|
9
|
+
end
|
10
|
+
|
11
|
+
def extra_options_to_hash
|
12
|
+
hash = {}
|
13
|
+
@extra_options.each do |k,v|
|
14
|
+
hash[k.to_s] = v
|
15
|
+
end
|
16
|
+
hash
|
17
|
+
end
|
18
|
+
|
19
|
+
def extra_options_from_hash!(std_options, hash)
|
20
|
+
extra_options = hash.keys - std_options
|
21
|
+
extra_options.each do |k|
|
22
|
+
@extra_options[k] = hash[k]
|
23
|
+
end
|
24
|
+
self
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -2,6 +2,9 @@ require 'uri'
|
|
2
2
|
|
3
3
|
module GraphiteDashboardApi
|
4
4
|
class Graph
|
5
|
+
|
6
|
+
include ExtraOptions
|
7
|
+
|
5
8
|
PROPS = [:from, :until, :width, :height]
|
6
9
|
[PROPS, :targets, :titles, :compact_leading].flatten.each do |a|
|
7
10
|
attr_accessor a
|
@@ -21,6 +24,7 @@ module GraphiteDashboardApi
|
|
21
24
|
@title = title
|
22
25
|
@targets = []
|
23
26
|
@compact_leading = false # this is tweaking stuff
|
27
|
+
@extra_options = {}
|
24
28
|
instance_eval(&block) if block
|
25
29
|
end
|
26
30
|
|
@@ -65,6 +69,7 @@ module GraphiteDashboardApi
|
|
65
69
|
hash[k.to_s] = v if v
|
66
70
|
end
|
67
71
|
hash['target'] = @targets
|
72
|
+
hash.merge!(extra_options_to_hash)
|
68
73
|
hash
|
69
74
|
end
|
70
75
|
|
@@ -79,6 +84,8 @@ module GraphiteDashboardApi
|
|
79
84
|
@targets << target
|
80
85
|
end
|
81
86
|
end
|
87
|
+
std_options = ['title', 'target', PROPS].map { |k| k.to_s }
|
88
|
+
extra_options_from_hash!(std_options, hash)
|
82
89
|
self
|
83
90
|
end
|
84
91
|
end
|
data/spec/graph_spec.rb
CHANGED
@@ -51,4 +51,17 @@ describe GraphiteDashboardApi::Graph do
|
|
51
51
|
new_graph = GraphiteDashboardApi::Graph.new
|
52
52
|
expect((new_graph.from_hash! graph.to_hash).to_hash).to eq graph.to_hash
|
53
53
|
end
|
54
|
+
|
55
|
+
it 'can have extra options' do
|
56
|
+
graph = GraphiteDashboardApi::Graph.new 'test' do
|
57
|
+
an_other_option 5
|
58
|
+
end
|
59
|
+
expect(graph.an_other_option).to eq 5
|
60
|
+
h = graph.to_hash
|
61
|
+
expect(h['an_other_option']).to eq 5
|
62
|
+
graph2 = GraphiteDashboardApi::Graph.new
|
63
|
+
graph2.from_hash! h
|
64
|
+
expect(graph2.an_other_option).to eq 5
|
65
|
+
end
|
66
|
+
|
54
67
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: graphite-dashboard-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Grégoire Seux
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-02-
|
11
|
+
date: 2014-02-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -52,6 +52,7 @@ files:
|
|
52
52
|
- lib/graphite-dashboard-api.rb
|
53
53
|
- lib/graphite-dashboard-api/api.rb
|
54
54
|
- lib/graphite-dashboard-api/dashboard.rb
|
55
|
+
- lib/graphite-dashboard-api/extra_options.rb
|
55
56
|
- lib/graphite-dashboard-api/graph.rb
|
56
57
|
- spec/dashboard_spec.rb
|
57
58
|
- spec/graph_spec.rb
|