graphite_client 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
- data/graphite_client.gemspec +2 -2
- data/lib/graphite_client.rb +5 -2
- data/spec/graphite_client_spec.rb +8 -0
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.3.0
|
data/graphite_client.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "graphite_client"
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.3.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Alex Dean"]
|
12
|
-
s.date = "2012-11-
|
12
|
+
s.date = "2012-11-10"
|
13
13
|
s.description = "Original code by https://github.com/joakimk."
|
14
14
|
s.email = "alex@crackpot.org"
|
15
15
|
s.extra_rdoc_files = [
|
data/lib/graphite_client.rb
CHANGED
@@ -1,13 +1,16 @@
|
|
1
1
|
require 'socket'
|
2
2
|
|
3
3
|
class GraphiteClient
|
4
|
+
# "host" or "host:port"
|
4
5
|
def initialize(host)
|
5
|
-
@host = host
|
6
|
+
@host, @port = host.split ':'
|
7
|
+
@port = 2003 if ! @port
|
8
|
+
@port = @port.to_i
|
6
9
|
end
|
7
10
|
|
8
11
|
def socket
|
9
12
|
return @socket if @socket && !@socket.closed?
|
10
|
-
@socket = TCPSocket.new(@host,
|
13
|
+
@socket = TCPSocket.new(@host, @port)
|
11
14
|
end
|
12
15
|
|
13
16
|
def report(key, value, time = Time.now)
|
@@ -11,6 +11,14 @@ describe "GraphiteClient" do
|
|
11
11
|
graphite.report("hello.world", 10.5, time)
|
12
12
|
end
|
13
13
|
|
14
|
+
it "should accept an alternate port number" do
|
15
|
+
time = Time.now
|
16
|
+
TCPSocket.should_receive(:new).with("host", 2023).and_return(socket = mock(:closed? => false))
|
17
|
+
socket.should_receive(:write).with("hello.world 10.5 #{time.to_i}\n")
|
18
|
+
graphite = GraphiteClient.new("host:2023")
|
19
|
+
graphite.report("hello.world", 10.5, time)
|
20
|
+
end
|
21
|
+
|
14
22
|
it "should reuse the same socket" do
|
15
23
|
time = Time.now
|
16
24
|
TCPSocket.should_receive(:new).once.with("host", 2003).and_return(socket = mock(:closed? => false))
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: graphite_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
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-11-
|
12
|
+
date: 2012-11-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -110,7 +110,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
110
110
|
version: '0'
|
111
111
|
segments:
|
112
112
|
- 0
|
113
|
-
hash: -
|
113
|
+
hash: -2039767072647927840
|
114
114
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
115
115
|
none: false
|
116
116
|
requirements:
|