hosted_graphite 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a0d29154a861702dfcd2155ef22739d047c17fc6
4
- data.tar.gz: 476a3169cfa6373caca77419637ad6adea807197
3
+ metadata.gz: 54635381836c0823f0c0372589924c3bee7ff317
4
+ data.tar.gz: ea2a81048ebe887e1947c573795050f71e5f7fb1
5
5
  SHA512:
6
- metadata.gz: 9545456f268a0565ab8722caeb444ce7ea6f3f9ec8fa49193c7cbdce54966a027aa984b14e7df1a5f0f3e4934b2e7c6f6f4c5d6f4b41305ce850aa7f51af6dbf
7
- data.tar.gz: 973d23666396403fde56a792fb52a7fbf2becb6af05ceb1da597aaf336ee1d03433324a421fed1e6c8a00226d839f8498b5a59a0470e2837939a3782a708c78f
6
+ metadata.gz: da17091a4da06deb24e9e8634b9738dbcbd23ebc0b08bea239057ab640d567f5d8b4da500038a72910ea351756eb9696d7d699f7793d1fb4880d471a264e97b1
7
+ data.tar.gz: 47bb71c1f0f701670b727faa234b3505561f9fa9becc82f18f8fccaa867e9fc6ab8d0223143618ab4311389c8b4778f63ec2379ff7156da5dfe1f2a4caad4ca5
data/README.md CHANGED
@@ -1,5 +1,6 @@
1
1
  [![Build Status](https://travis-ci.org/seuros/hosted_graphite.svg?branch=master)](https://travis-ci.org/seuros/hosted_graphite)
2
2
  [![Code Climate](https://codeclimate.com/github/seuros/hosted_graphite/badges/gpa.svg)](https://codeclimate.com/github/seuros/hosted_graphite)
3
+
3
4
  # HostedGraphite
4
5
 
5
6
  A Ruby client for HostedGraphite
@@ -37,19 +38,19 @@ HostedGraphite.api_key = 'YOUR API KEY'
37
38
 
38
39
  #### Sending a metric via UDP
39
40
  ```ruby
40
- HostedGraphite.protocol = HostedGraphite::UDP
41
+ HostedGraphite.protocol = :udp
41
42
  HostedGraphite.send_metric('foo.udp', 1.2)
42
43
  ```
43
44
 
44
45
  #### Sending a metric via TCP
45
46
  ```ruby
46
- HostedGraphite.protocol = HostedGraphite::TCP
47
+ HostedGraphite.protocol = :tcp
47
48
  HostedGraphite.send_metric('foo.tcp', 1.2)
48
49
  ```
49
50
 
50
51
  #### Sending a metric via HTTP
51
52
  ```ruby
52
- HostedGraphite.protocol = HostedGraphite::HTTP
53
+ HostedGraphite.protocol = :http
53
54
  HostedGraphite.send_metric('foo.http', 1.2)
54
55
  ```
55
56
 
@@ -80,7 +81,7 @@ HostedGraphite.timing 'foo', 320
80
81
  HostedGraphite.gauge 'bar', 100
81
82
 
82
83
  # Use {#time} to time the execution of a block
83
- HostedGraphite.time('newsletter.monthly') { @newletter.deliver_now }
84
+ HostedGraphite.time('newsletter.monthly') { @newsletter.deliver_now }
84
85
  ```
85
86
 
86
87
  ## Contributing
@@ -32,8 +32,13 @@ module HostedGraphite
32
32
  end
33
33
 
34
34
  def protocol=(protocol)
35
- # TODO, accept symbols and string (:udp, 'tcp')
36
- @@protocol = protocol.new
35
+ case protocol
36
+ when Class
37
+ @@protocol = protocol.new
38
+ when String, Symbol
39
+ protocol = protocol.to_s.upcase
40
+ @@protocol = const_get(protocol).new
41
+ end
37
42
  end
38
43
  end
39
44
  end
@@ -1,3 +1,3 @@
1
1
  module HostedGraphite
2
- VERSION = '0.0.6'
2
+ VERSION = '0.0.7'
3
3
  end
@@ -13,6 +13,10 @@ class HTTPProtocolTest < Minitest::Test
13
13
  HostedGraphite.api_key = @previous_api_key
14
14
  end
15
15
 
16
+ def test_http_protocol
17
+ assert_instance_of HostedGraphite::HTTP, HostedGraphite.protocol
18
+ end
19
+
16
20
  def test_correct_query
17
21
  query = HostedGraphite.send_metric('foo', 1.2, 1421792423)
18
22
  assert_equal 'foo 1.2 1421792423', query
@@ -2,17 +2,22 @@ require_relative 'helper'
2
2
 
3
3
  class TCPProtocolTest < Minitest::Test
4
4
  attr_reader :api_key
5
+
5
6
  def setup
6
7
  @previous_api_key = HostedGraphite.api_key
7
8
  @api_key = SecureRandom.uuid
8
9
  HostedGraphite.api_key = @api_key
9
- HostedGraphite.protocol = HostedGraphite::TCP
10
+ HostedGraphite.protocol = 'tcp'
10
11
  end
11
12
 
12
13
  def teardown
13
14
  HostedGraphite.api_key = @previous_api_key
14
15
  end
15
16
 
17
+ def test_tcp_protocol
18
+ assert_instance_of HostedGraphite::TCP, HostedGraphite.protocol
19
+ end
20
+
16
21
  def test_correct_query
17
22
  query = HostedGraphite.send_metric('foo', 1.2, 1421792423)
18
23
  assert_equal "#{api_key}.foo 1.2 1421792423\n", query
@@ -6,13 +6,17 @@ class UDPProtocolTest < Minitest::Test
6
6
  @previous_api_key = HostedGraphite.api_key
7
7
  @api_key = SecureRandom.uuid
8
8
  HostedGraphite.api_key = @api_key
9
- HostedGraphite.protocol = HostedGraphite::UDP
9
+ HostedGraphite.protocol = :udp
10
10
  end
11
11
 
12
12
  def teardown
13
13
  HostedGraphite.api_key = @previous_api_key
14
14
  end
15
15
 
16
+ def test_udp_protocol
17
+ assert_instance_of HostedGraphite::UDP, HostedGraphite.protocol
18
+ end
19
+
16
20
  def test_correct_query
17
21
  query = HostedGraphite.send_metric('foo', 1.2, 1421792423)
18
22
  assert_equal "#{api_key}.foo 1.2 1421792423\n", query
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hosted_graphite
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Abdelkader Boudih
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-23 00:00:00.000000000 Z
11
+ date: 2015-01-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler