check_host 0.0.0 → 0.0.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c448d06ac3895bb4e27358cd5fde364f66e79f3e
4
- data.tar.gz: 1e9d6ebf03586bcb831baa09b13b05d6c56c0ac6
3
+ metadata.gz: 46d50b552dfe87c5da4658c7a60b5e5dd7c7a9e8
4
+ data.tar.gz: e493e95dded3d92ea715dc6407b7bbce6e52a5fa
5
5
  SHA512:
6
- metadata.gz: 0efbd6bb1f23e8f947a98c9e5165a1c897bc89279e3777d73fbfb2cc32775069aac110f452f201e09b7fe952b4e8075aea3203f1e31f099333075cda8f46d0cc
7
- data.tar.gz: e5a861d8bd8432fa9a2ca9b3f6355af8c3fe3fb95f0d8883b0202342d51cfb12fc9f970711b32edfa7e0504db3790b958961c7bb67ec60da849086b46b663425
6
+ metadata.gz: 409927f6e8a2f408426bf61f92feeda93ebb1cbd43565c382a71edb9143bf89d2e4ac8f843963e751e85ac1b0e5c7b6def0e07bf6bfc0150b0eede6f6c7e17a9
7
+ data.tar.gz: 2fc591e520b7d5f0aa81ca754a02ee580cc099bdfea57dad88ed9bca904a7bd12d990a1aee40cbd1a412bfcbffd161d016b125a50f669e37f43bf2f8b489fd8d
data/lib/check_host.rb CHANGED
@@ -1,9 +1,12 @@
1
1
  require 'check_host/check_host_ip'
2
2
 
3
3
  class CheckHost
4
+ # run
5
+ # @param: host [String] the host name
6
+ # @param: ip [String] the host IP address
7
+ # @return [Boolean] true if notification has taken place, otherwise returns false
4
8
  def self.run(host, ip)
5
9
  c = CheckHostIp.new(host, ip)
6
10
  c.notify
7
- true
8
11
  end
9
12
  end
@@ -2,29 +2,18 @@ require "check_host/send_mail"
2
2
 
3
3
  class CheckHostIp
4
4
 
5
+ # @!attribute
5
6
  attr_accessor :host, :ip
6
7
 
8
+ # @param: host (String) The host name
9
+ # @param: ip (String) The host IP
7
10
  def initialize(host, ip)
8
11
  @host = host
9
12
  @ip = ip
10
13
  end
11
14
 
12
- # Runs the host cmd and returns just the A record
13
- # @return String
14
- # example: "fawazalhokairfashion.com has address 91.109.13.176\n"
15
- def cmd
16
- `host -t A #{host}`
17
- end
18
-
19
- # Checks whether a string contains the ip address
20
- # @return Boolean
21
- def result?
22
- !cmd.include? ip
23
- end
24
-
25
15
  # Sends an email if result? is true
26
16
  # @return Boolean
27
- # If result? is true then SendMail
28
17
  def notify
29
18
  if result?
30
19
  SendMail.new
@@ -33,4 +22,18 @@ class CheckHostIp
33
22
  false
34
23
  end
35
24
  end
25
+
26
+ private
27
+ # Runs the host cmd and returns just the A record
28
+ # example: "fawazalhokairfashion.com has address 91.109.13.176\\n"
29
+ # @return String
30
+ def cmd
31
+ `host -t A #{host}`
32
+ end
33
+
34
+ # Checks whether a string contains the ip address
35
+ # @return Boolean
36
+ def result?
37
+ !cmd.include? ip
38
+ end
36
39
  end
@@ -6,10 +6,12 @@ class SendMail
6
6
  end
7
7
 
8
8
  private
9
+ # @return [Mail::Message]
9
10
  def send
10
11
  message
11
12
  end
12
13
 
14
+ # @return [Mail::Message]
13
15
  def message
14
16
  recipient = 'mike@smswmedia.com'
15
17
  mail = Mail.new do
@@ -21,6 +23,5 @@ class SendMail
21
23
 
22
24
  mail.delivery_method :sendmail
23
25
  mail.deliver
24
- `echo 'Email sent'`
25
26
  end
26
27
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: check_host
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Watts