sensu-transport 0.0.2 → 0.0.3

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: 65b0b8abe0837877e0d1b0b735a56fdfe13a4bac
4
- data.tar.gz: 32cae6e75dd1e07b41c90aa865fef65d80c0aa92
3
+ metadata.gz: 2cdc17cbd6f9e0e4fd7725b6942e8ed1690dba37
4
+ data.tar.gz: 93154f4c346571558290cb68891c414a24524381
5
5
  SHA512:
6
- metadata.gz: 76546576240a195207ce68cf6bd2cb457661412b9bb630e7597dfeeb8baf695617a5a1d6efcd0878e11a234c1d2996364a63fa2b148e89dbf19c4af42f2d1af5
7
- data.tar.gz: 31f9a25db107d8288d63777541f0d2cfdb88d4642c59f445ea6a41c3d57f430ef4634ec72c6567066e4a62a00832bbbcb9192d8ddeb1939d6478f0044e28e08c
6
+ metadata.gz: 04780b034644b8f23e5acd80c5a0a7df10bd247cecf39729d28ec20c968b931d73dc334eed69c6295054778a83d75e9471fdb52ece4b987dfe90b50ad51b5827
7
+ data.tar.gz: 92f1e633b476f33bc97e3bc2eeb6726cd3659d8c7790049c2a1b3eb3bd15006fd5169f398844c84017dba9ec4b077e8b84f0d4ed804f6b781e051c5ba84e6080
data/.travis.yml CHANGED
@@ -14,4 +14,4 @@ notifications:
14
14
  script: "rspec . --tag ~ssl"
15
15
  addons:
16
16
  code_climate:
17
- repo_token:629d024a848e2ebb1b0c0283c2046387c1b8c0d1cfd4d03289bef74a7b875d55
17
+ repo_token: 629d024a848e2ebb1b0c0283c2046387c1b8c0d1cfd4d03289bef74a7b875d55
data/Gemfile CHANGED
@@ -1,3 +1,4 @@
1
- source "https://rubygems.org"
1
+ source 'https://rubygems.org'
2
2
 
3
+ # Specify your gem's dependencies in sensu-spawn.gemspec
3
4
  gemspec
@@ -57,17 +57,6 @@ module Sensu
57
57
  # Close the transport connection.
58
58
  def close; end
59
59
 
60
- # Connects to the transport.
61
- #
62
- # @param options [Hash, String]
63
- # @return [Transport] the transport object.
64
- def self.connect(options={})
65
- options ||= {}
66
- transport = self.new
67
- transport.connect(options)
68
- transport
69
- end
70
-
71
60
  # Publish a message to the transport.
72
61
  #
73
62
  # @param type [Symbol] the transport pipe type, possible values
@@ -1,12 +1,27 @@
1
1
  module Sensu
2
2
  module Transport
3
- def self.connect(transport, options={})
4
- require("sensu/transport/#{transport}")
5
- klass = Base.descendants.detect do |klass|
6
- klass.name.downcase.split("::").last == transport
3
+ class << self
4
+ # Set the transport logger.
5
+ #
6
+ # @param logger [Object] transport logger.
7
+ def logger=(logger)
8
+ @logger = logger
9
+ end
10
+
11
+ # Connect to a transport.
12
+ #
13
+ # @param transport_name [String] transport name.
14
+ # @param options [Hash] transport options.
15
+ def connect(transport_name, options={})
16
+ require("sensu/transport/#{transport_name}")
17
+ klass = Base.descendants.detect do |klass|
18
+ klass.name.downcase.split("::").last == transport_name
19
+ end
20
+ transport = klass.new
21
+ transport.logger = @logger
22
+ transport.connect(options)
23
+ transport
7
24
  end
8
- object = klass.connect(options)
9
- object
10
25
  end
11
26
  end
12
27
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "sensu-transport"
5
- spec.version = "0.0.2"
5
+ spec.version = "0.0.3"
6
6
  spec.authors = ["Sean Porter"]
7
7
  spec.email = ["portertech@gmail.com"]
8
8
  spec.summary = "The Sensu transport abstraction library"
data/spec/base_spec.rb CHANGED
@@ -9,7 +9,6 @@ describe "Sensu::Transport::Base" do
9
9
  end
10
10
 
11
11
  it "provides a transport API (noop)" do
12
- Sensu::Transport::Base.should respond_to(:connect)
13
12
  @transport.should respond_to(:on_error, :before_reconnect, :after_reconnect,
14
13
  :connect, :connected?, :close,
15
14
  :publish, :subscribe, :unsubscribe,
data/spec/helpers.rb CHANGED
@@ -15,7 +15,7 @@ module Helpers
15
15
  end
16
16
 
17
17
  def async_wrapper(&callback)
18
- EM::run do
18
+ EM.run do
19
19
  timer(10) do
20
20
  raise "test timed out"
21
21
  end
@@ -24,6 +24,6 @@ module Helpers
24
24
  end
25
25
 
26
26
  def async_done
27
- EM::stop_event_loop
27
+ EM.stop_event_loop
28
28
  end
29
29
  end
@@ -12,7 +12,6 @@ describe "Sensu::Transport::RabbitMQ" do
12
12
  end
13
13
 
14
14
  it "provides a transport API" do
15
- Sensu::Transport::RabbitMQ.should respond_to(:connect)
16
15
  @transport.should respond_to(:on_error, :before_reconnect, :after_reconnect,
17
16
  :connect, :connected?, :close,
18
17
  :publish, :subscribe, :unsubscribe,
@@ -1,5 +1,6 @@
1
1
  require File.join(File.dirname(__FILE__), "helpers")
2
2
  require "sensu/transport"
3
+ require "logger"
3
4
 
4
5
  describe "Sensu::Transport" do
5
6
  include Helpers
@@ -14,4 +15,15 @@ describe "Sensu::Transport" do
14
15
  end
15
16
  end
16
17
  end
18
+
19
+ it "can set the transport logger" do
20
+ async_wrapper do
21
+ logger = Logger.new(STDOUT)
22
+ Sensu::Transport.logger = logger
23
+ transport = Sensu::Transport.connect("rabbitmq")
24
+ transport.logger.should eq(logger)
25
+ transport.logger.should respond_to(:error)
26
+ async_done
27
+ end
28
+ end
17
29
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sensu-transport
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean Porter
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-19 00:00:00.000000000 Z
11
+ date: 2014-05-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sensu-em