json2graphite 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/bin/json2graphite +1 -1
  2. data/lib/json2graphite.rb +6 -3
  3. metadata +3 -2
@@ -9,7 +9,7 @@ def run
9
9
  body += STDIN.read
10
10
  hash = JSON.parse(body)
11
11
  data = Json2Graphite.to_graphite(hash)
12
+ puts data.join("\n")
12
13
  end
13
14
 
14
15
  run()
15
-
@@ -1,8 +1,9 @@
1
-
2
1
  module Json2Graphite
3
2
  module_function
4
3
 
5
- # DOCUMENT THIS!!!
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
- puts "#{target} #{value} #{time}"
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.5
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-08-22 00:00:00.000000000 Z
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: