json2graphite 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/json2graphite +1 -1
- data/lib/json2graphite.rb +6 -3
- metadata +3 -2
data/bin/json2graphite
CHANGED
data/lib/json2graphite.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
|
-
|
2
1
|
module Json2Graphite
|
3
2
|
module_function
|
4
3
|
|
5
|
-
#
|
4
|
+
# basically reaches into a hash tree and grabs the end value, joining the
|
5
|
+
# keys along the way returning the block.
|
6
|
+
|
6
7
|
def walk_the_forrest (obj=self, path=[], &blk)
|
7
8
|
obj.each do |key,value|
|
8
9
|
case value
|
@@ -18,10 +19,12 @@ module Json2Graphite
|
|
18
19
|
# outputs to STDOUT. Takes optional time argument, defaulting to now.
|
19
20
|
|
20
21
|
def to_graphite (hash, time=Time.now.to_i)
|
22
|
+
data = []
|
21
23
|
raise "Hash was not received" unless hash.is_a? Hash
|
22
24
|
walk_the_forrest(hash) {|target, value|
|
23
|
-
|
25
|
+
data << "#{target} #{value} #{time}"
|
24
26
|
}
|
27
|
+
data
|
25
28
|
end
|
26
29
|
|
27
30
|
# Return an array of hashes, each hash a single graphite target, value, and time
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: json2graphite
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-11-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json
|
@@ -63,3 +63,4 @@ signing_key:
|
|
63
63
|
specification_version: 3
|
64
64
|
summary: Convert json hash tree to graphite format
|
65
65
|
test_files: []
|
66
|
+
has_rdoc:
|