Module: VerifyRedirects
- Defined in:
- lib/verify_redirects.rb,
lib/verify_redirects/cli.rb,
lib/verify_redirects/result.rb,
lib/verify_redirects/version.rb,
lib/verify_redirects/verifier.rb
Defined Under Namespace
Classes: CLI, Configuration, Result, Verifier
Constant Summary
collapse
- VERSION =
'0.2.1'.freeze
Class Method Summary
collapse
Class Method Details
.config ⇒ Object
27
28
29
|
# File 'lib/verify_redirects.rb', line 27
def self.config
configuration
end
|
.configuration ⇒ Object
23
24
25
|
# File 'lib/verify_redirects.rb', line 23
def self.configuration
@configuration ||= Configuration.new
end
|
31
32
33
34
|
# File 'lib/verify_redirects.rb', line 31
def self.configure
yield(configuration) if block_given?
configuration
end
|
.from_csv(input_path:, output_path:) ⇒ Object
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/verify_redirects.rb', line 7
def self.from_csv(input_path:, output_path:)
verifier = Verifier.new
input_csv = HoneyFormat::CSV.new(File.read(input_path))
= %w[success from redirected_to expected_redirect]
rows = input_csv.rows.map do |row|
result = verifier.call(row.from_url, row.to_url)
yield(result) if block_given?
result.to_a
end
output_csv = HoneyFormat::Matrix.new(rows, header: ).to_csv
File.write(output_path, output_csv)
end
|