Class: SiteChecker
Constant Summary collapse
- @@was_checked =
false
- @@available =
false
- @@site =
""
- @@proxy =
nil
Class Method Summary collapse
- .is_available? ⇒ Boolean
- .proxy ⇒ Object
- .proxy=(proxy) ⇒ Object
- .site ⇒ Object
- .site=(site) ⇒ Object
Class Method Details
.is_available? ⇒ Boolean
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/build/SiteChecker.rb', line 14 def is_available? if !@@was_checked @@available = false uri = URI.parse(@@site) begin if !(proxy.nil? || proxy.empty?) proxy_uri = URI.parse(proxy) http = Net::HTTP.new(uri.host, uri.port, proxy_uri.host, proxy_uri.port, proxy_uri.user, proxy_uri.password ) else http = Net::HTTP.new(uri.host, uri.port) end if uri.scheme == "https" # enable SSL/TLS http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_NONE end http.start { http.request_get(uri.path) {|res|} } @@available = true rescue => e puts "Error accessing #{uri.inspect}: #{e.inspect}" puts e.backtrace end @@was_checked = true end @@available end |
.proxy ⇒ Object
59 60 61 |
# File 'lib/build/SiteChecker.rb', line 59 def proxy @@proxy end |
.proxy=(proxy) ⇒ Object
54 55 56 57 |
# File 'lib/build/SiteChecker.rb', line 54 def proxy=(proxy) @@proxy = proxy @@was_checked = false end |
.site ⇒ Object
50 51 52 |
# File 'lib/build/SiteChecker.rb', line 50 def site @@site end |
.site=(site) ⇒ Object
45 46 47 48 |
# File 'lib/build/SiteChecker.rb', line 45 def site=(site) @@site = site @@was_checked = false end |