Class: UrlChecker::Cli
- Inherits:
-
Object
- Object
- UrlChecker::Cli
- Defined in:
- lib/url_checker/cli.rb
Overview
The main class
Constant Summary collapse
- BAD_CALL_MSG =
'Please call with one CSV file with URLs in the first column'- RESULTS_HEADERS =
%w(Response URL).freeze
Instance Attribute Summary collapse
-
#file_path ⇒ Object
readonly
Returns the value of attribute file_path.
-
#results_file_path ⇒ Object
readonly
Returns the value of attribute results_file_path.
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(file_path:) ⇒ Cli
constructor
A new instance of Cli.
Constructor Details
#initialize(file_path:) ⇒ Cli
Returns a new instance of Cli.
11 12 13 |
# File 'lib/url_checker/cli.rb', line 11 def initialize(file_path:) @file_path = file_path end |
Instance Attribute Details
#file_path ⇒ Object (readonly)
Returns the value of attribute file_path.
9 10 11 |
# File 'lib/url_checker/cli.rb', line 9 def file_path @file_path end |
#results_file_path ⇒ Object (readonly)
Returns the value of attribute results_file_path.
9 10 11 |
# File 'lib/url_checker/cli.rb', line 9 def results_file_path @results_file_path end |
Class Method Details
.call ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/url_checker/cli.rb', line 22 def self.call if ARGV.length == 1 && ARGV.first.match?(/\.csv\z/) url_checker = new(file_path: ARGV.first).call else puts BAD_CALL_MSG.red end url_checker end |
Instance Method Details
#call ⇒ Object
15 16 17 18 19 20 |
# File 'lib/url_checker/cli.rb', line 15 def call @results = [RESULTS_HEADERS] @num_issues = 0 display_summary Benchmark.measure { check_urls_from_csv }.real write_results end |