gmetric 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.1.2
@@ -0,0 +1,48 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{gmetric}
8
+ s.version = "0.1.2"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Ilya Grigorik"]
12
+ s.date = %q{2010-07-29}
13
+ s.description = %q{Pure Ruby interface for generating Ganglia gmetric packets}
14
+ s.email = %q{ilya@igvita.com}
15
+ s.extra_rdoc_files = [
16
+ "README.rdoc"
17
+ ]
18
+ s.files = [
19
+ "README.rdoc",
20
+ "Rakefile",
21
+ "VERSION",
22
+ "gmetric.gemspec",
23
+ "lib/gmetric.rb",
24
+ "spec/gmetric_spec.rb",
25
+ "spec/helper.rb"
26
+ ]
27
+ s.homepage = %q{http://github.com/igrigorik/gmetric}
28
+ s.rdoc_options = ["--charset=UTF-8"]
29
+ s.require_paths = ["lib"]
30
+ s.rubyforge_project = %q{gmetric}
31
+ s.rubygems_version = %q{1.3.6}
32
+ s.summary = %q{Pure Ruby interface for generating Ganglia gmetric packets}
33
+ s.test_files = [
34
+ "spec/gmetric_spec.rb",
35
+ "spec/helper.rb"
36
+ ]
37
+
38
+ if s.respond_to? :specification_version then
39
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
40
+ s.specification_version = 3
41
+
42
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
43
+ else
44
+ end
45
+ else
46
+ end
47
+ end
48
+
@@ -13,12 +13,22 @@ module Ganglia
13
13
  }
14
14
 
15
15
  def self.send(host, port, metric)
16
- conn = UDPSocket.new
17
- conn.connect(host, port)
18
16
  gmetric = self.pack(metric)
19
17
 
20
- conn.send gmetric[0], 0
21
- conn.send gmetric[1], 0
18
+ if defined?(EventMachine) and EventMachine.reactor_running?
19
+ # open an ephemereal UDP socket since
20
+ # we do not plan on recieving any data
21
+ conn = EM.open_datagram_socket('', 0)
22
+
23
+ conn.send_datagram gmetric[0], host, port
24
+ conn.send_datagram gmetric[1], host, port
25
+ else
26
+ conn = UDPSocket.new
27
+ conn.connect(host, port)
28
+
29
+ conn.send gmetric[0], 0
30
+ conn.send gmetric[1], 0
31
+ end
22
32
  end
23
33
 
24
34
  def self.pack(metric)
@@ -84,4 +84,23 @@ describe Ganglia::GMetric do
84
84
 
85
85
  }.should_not raise_error
86
86
  end
87
+
88
+ it "should use EM reactor if used within event loop" do
89
+ pending 'stub out connection class'
90
+
91
+ require 'rubygems'
92
+ require 'eventmachine'
93
+ EventMachine.run do
94
+ Ganglia::GMetric.send("127.0.0.1", 1111, {
95
+ :name => 'pageviews',
96
+ :units => 'req/min',
97
+ :type => 'uint8',
98
+ :value => 7000,
99
+ :tmax => 60,
100
+ :dmax => 300
101
+ })
102
+
103
+ EM.stop
104
+ end
105
+ end
87
106
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 1
9
- version: 0.1.1
8
+ - 2
9
+ version: 0.1.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Ilya Grigorik
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-06-13 00:00:00 -04:00
17
+ date: 2010-07-29 00:00:00 -04:00
18
18
  default_executable:
19
19
  dependencies: []
20
20
 
@@ -30,6 +30,7 @@ files:
30
30
  - README.rdoc
31
31
  - Rakefile
32
32
  - VERSION
33
+ - gmetric.gemspec
33
34
  - lib/gmetric.rb
34
35
  - spec/gmetric_spec.rb
35
36
  - spec/helper.rb