Class: SiteChecker
- Inherits:
-
Object
- Object
- SiteChecker
- Defined in:
- SiteChecker.rb
Constant Summary
- @@was_checked =
false
- @@available =
false
- @@site =
""
- @@proxy =
nil
Class Method Summary (collapse)
- + (Boolean) is_available?
- + (Object) proxy
- + (Object) proxy=(proxy)
- + (Object) site
- + (Object) site=(site)
Class Method Details
+ (Boolean) is_available?
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 '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 |
+ (Object) proxy
59 60 61 |
# File 'SiteChecker.rb', line 59 def proxy @@proxy end |
+ (Object) proxy=(proxy)
54 55 56 57 |
# File 'SiteChecker.rb', line 54 def proxy=(proxy) @@proxy = proxy @@was_checked = false end |
+ (Object) site
50 51 52 |
# File 'SiteChecker.rb', line 50 def site @@site end |
+ (Object) site=(site)
45 46 47 48 |
# File 'SiteChecker.rb', line 45 def site=(site) @@site = site @@was_checked = false end |