Module: Acop
- Defined in:
- lib/acop.rb,
lib/acop/version.rb,
lib/acop/accessibility.rb
Defined Under Namespace
Classes: Enforcer, Helpers
Constant Summary
collapse
- VERSION =
"1.0.1"
Class Method Summary
collapse
Class Method Details
.run(*args) ⇒ Object
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/acop.rb', line 6
def self.run(*args)
options = {}
option_parser = OptionParser.new do |opts|
opts.banner = 'Usage: acop -u URL'
opts.on('-u', '--url URL', 'Url to be accessibility tested') do |tag|
options[:url] = tag
end
end
begin
option_parser.parse!
raise OptionParser::MissingArgument, "Url should be provided!" if options.keys.empty?
raise OptionParser::InvalidArgument, "Url cannot be resolved!" unless valid_url?(options[:url])
rescue OptionParser::ParseError => e
puts e.message
puts
puts option_parser
exit -1
end
Enforcer.new(options).accessibility_checks
end
|
.valid_url?(url) ⇒ Boolean
31
32
33
34
35
36
37
38
39
|
# File 'lib/acop.rb', line 31
def self.valid_url?(url)
begin
url = "http://" + url unless url.include?("http")
contents = open(url)
return true
rescue Exception => e
return false
end
end
|