isup 0.0.2

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.
Files changed (4) hide show
  1. checksums.yaml +15 -0
  2. data/bin/isup +4 -0
  3. data/lib/isup.rb +39 -0
  4. metadata +63 -0
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ MWU0NTZlZTUyMDQ5MDNkODE2MDg5YTViMmIyMGY0NDU1ZjQzNDU1NA==
5
+ data.tar.gz: !binary |-
6
+ OTdlYWE3MGNiNWNiODkwZTMyMzJjYzhjOWE5OGZjODBjNTcyMGYyYQ==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ N2M0ZWVjY2Y1MzIwNTU0Y2I4MWQ1NzU5OTZkMmYzZmViNWY1NTc4M2NlNmE0
10
+ YWIyMDU1Y2Q3MTBhN2FlZjUzOGMzZDM5MzEzMTE1M2FmMWQ1MjJjZTFlYWJm
11
+ ODM3MmFmNjQwNTY5ZGJmZGM5NjRhMTgyMzhmMGRmZjBhNTBhOTg=
12
+ data.tar.gz: !binary |-
13
+ MWYyZGRlOTRlZGViNDIxNzM5NjRlYTdkMTBjNTMxNmM1ZTUwNmVlYTU5NTdi
14
+ NWVlNGI3ZTNjNDlhZjM2ZmNjMDQzM2E0YjEyNWUxYWFmY2Q2MTYxOGNiMDA3
15
+ YzQ2YjE4M2MzYTlkZThlZDljYzhlMDgxNWQ5ZTExZDMwNmVjODY=
data/bin/isup ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'isup'
4
+ Isup.new(ARGV[0])
data/lib/isup.rb ADDED
@@ -0,0 +1,39 @@
1
+ require "net/http"
2
+ require "colorize"
3
+
4
+ # A simple class to determine whether a website is down.
5
+ class Isup
6
+
7
+ def initialize(url)
8
+ @url = url
9
+ @response_code = self.fetch(url, 10)
10
+ end
11
+
12
+ public
13
+
14
+ def fetch(uri_str, limit = 10)
15
+ raise ArgumentError, 'Unable to complete the lookup.' if limit == 0
16
+ @response = Net::HTTP.get_response(URI(uri_str))
17
+ case @response
18
+ when Net::HTTPSuccess then
19
+ print "#{@url} ".blue
20
+ print "is "
21
+ print "UP\n".red
22
+ when Net::HTTPClientError then
23
+ print "#{@url} ".blue
24
+ print "is "
25
+ print "DOWN\n".red
26
+ when Net::HTTPServerError then
27
+ print "#{@url} ".blue
28
+ print "is either "
29
+ print "DOWN".red
30
+ print ", or your network is.\n"
31
+ when Net::HTTPRedirection then
32
+ @location = @response['location']
33
+ fetch(@location, limit - 1)
34
+ else
35
+ warn "Unable to complete the request."
36
+ end
37
+ end
38
+
39
+ end
metadata ADDED
@@ -0,0 +1,63 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: isup
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Andrew Brinker
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-04-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: colorize
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ! '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ! '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ description: A very simple Ruby gem to check whether a site is currently up. It does
28
+ not currently handle errors properly, and is more of a learning experience for me
29
+ than anything else. It can be used via the command line with the 'isup' command,
30
+ taking a url as the only parameter.
31
+ email: me@andrewbrinker.com
32
+ executables:
33
+ - isup
34
+ extensions: []
35
+ extra_rdoc_files: []
36
+ files:
37
+ - lib/isup.rb
38
+ - bin/isup
39
+ homepage: http://rubygems.org/gems/isup
40
+ licenses:
41
+ - Public Domain
42
+ metadata: {}
43
+ post_install_message:
44
+ rdoc_options: []
45
+ require_paths:
46
+ - lib
47
+ required_ruby_version: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - ! '>='
50
+ - !ruby/object:Gem::Version
51
+ version: '0'
52
+ required_rubygems_version: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ! '>='
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
57
+ requirements: []
58
+ rubyforge_project:
59
+ rubygems_version: 2.0.3
60
+ signing_key:
61
+ specification_version: 4
62
+ summary: Still a work in progress. Checks whether a site is up.
63
+ test_files: []