Class: Neetob::CLI::Redirections::Check
- Defined in:
- lib/neetob/cli/redirections/check.rb
Constant Summary
Constants inherited from Base
Instance Attribute Summary collapse
-
#destination ⇒ Object
Returns the value of attribute destination.
-
#sandbox ⇒ Object
Returns the value of attribute sandbox.
-
#source ⇒ Object
Returns the value of attribute source.
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(source, destination, sandbox = false) ⇒ Check
constructor
A new instance of Check.
- #run ⇒ Object
Methods included from Utils
#camel_case_to_slug, #is_upper?, #symbolize_keys
Constructor Details
#initialize(source, destination, sandbox = false) ⇒ Check
Returns a new instance of Check.
9 10 11 12 13 14 |
# File 'lib/neetob/cli/redirections/check.rb', line 9 def initialize(source, destination, sandbox = false) super() @source = source @destination = destination @sandbox = sandbox end |
Instance Attribute Details
#destination ⇒ Object
Returns the value of attribute destination.
7 8 9 |
# File 'lib/neetob/cli/redirections/check.rb', line 7 def destination @destination end |
#sandbox ⇒ Object
Returns the value of attribute sandbox.
7 8 9 |
# File 'lib/neetob/cli/redirections/check.rb', line 7 def sandbox @sandbox end |
#source ⇒ Object
Returns the value of attribute source.
7 8 9 |
# File 'lib/neetob/cli/redirections/check.rb', line 7 def source @source end |
Instance Method Details
#run ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/neetob/cli/redirections/check.rb', line 16 def run source_url = URI.parse(source) destination_url = URI.parse(destination) response = Net::HTTP.get_response(source_url) if response.code.in? %w(301 302 308) if response["location"].chomp("/") == destination.chomp("/") ui.success("The redirection from #{source} to #{destination} is working properly.") else ui.error("The redirection from #{source} to #{destination} is not working properly.") end else ui.error("The redirection from #{source} to #{destination} is not working properly.") end end |