Host class that represents machine monitored.
This commit is contained in:
parent
6c7814d754
commit
ca40c4a229
2 changed files with 29 additions and 0 deletions
17
lib/nsca/client/host.rb
Normal file
17
lib/nsca/client/host.rb
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
require 'socket'
|
||||||
|
|
||||||
|
module NSCA
|
||||||
|
module Client
|
||||||
|
class Host
|
||||||
|
attr_reader :hostname
|
||||||
|
|
||||||
|
def initialize(options)
|
||||||
|
@hostname = options[:hostname]
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.current
|
||||||
|
Host.new(:hostname => Socket.gethostname)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
12
spec/nsca/client/host_spec.rb
Normal file
12
spec/nsca/client/host_spec.rb
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe NSCA::Client::Host do
|
||||||
|
subject { described_class.new(:hostname => 'dummy') }
|
||||||
|
its(:hostname) { should eq 'dummy' }
|
||||||
|
|
||||||
|
context "current machine" do
|
||||||
|
before { Socket.stub(:gethostname).and_return('dummy-client-machine') }
|
||||||
|
subject { described_class.current }
|
||||||
|
its(:hostname) { should eq 'dummy-client-machine' }
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in a new issue