Top Level Namespace
Instance Method Summary collapse
- #check_host(host) ⇒ Object
- #count_issues(host) ⇒ Object
- #get_host_argv ⇒ Object
- #load_paths ⇒ Object
- #summary(issues) ⇒ Object
Instance Method Details
#check_host(host) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/webcheck.rb', line 14 def check_host(host) begin Net::HTTP.get_response host, '/' rescue SocketError abort "http://#{host}/ is not available. Is the host name correct?".red end end |
#count_issues(host) ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/webcheck.rb', line 22 def count_issues(host) load_paths.map do |path, doc| if Net::HTTP.get_response(host, path).code.to_i >= 400 puts "Could not find http://#{host+path}. Refer to #{doc} to find out more about this file.".red doc else puts "Found http://#{host+path}".green end end.reject { |item| item.nil?}.length end |
#get_host_argv ⇒ Object
9 10 11 12 |
# File 'lib/webcheck.rb', line 9 def get_host_argv abort "Usage #{$0} HOST" unless ARGV.length == 1 ARGV[0] end |
#load_paths ⇒ Object
4 5 6 7 |
# File 'lib/webcheck.rb', line 4 def load_paths spec = Gem::Specification.find_by_name("webcheck") YAML.load(File.read("#{spec.gem_dir}/lib/urls.yaml")) end |
#summary(issues) ⇒ Object
33 34 35 36 |
# File 'lib/webcheck.rb', line 33 def summary(issues) abort "Found #{issues} issues.".red unless issues == 0 puts "No issues found.".green end |