Class: Ronin::Web::CLI::Commands::Diff Private
- Inherits:
-
Ronin::Web::CLI::Command
- Object
- Core::CLI::Command
- Ronin::Web::CLI::Command
- Ronin::Web::CLI::Commands::Diff
- Includes:
- CommandKit::Terminal
- Defined in:
- lib/ronin/web/cli/commands/diff.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Diffs two web pages.
Usage
ronin-web diff [options] {URL | FILE} {URL | FILE}
Arguments
URL | FILE The original URL or file
URL | FILE The modified URL or file
Options
-h, --help Print help information
Instance Method Summary collapse
-
#read(source) ⇒ String, File
private
Reads a web page.
-
#run(page1, page2) ⇒ Object
private
Runs the
ronin-web diff
command.
Instance Method Details
#read(source) ⇒ String, File
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Reads a web page.
94 95 96 97 98 99 100 101 |
# File 'lib/ronin/web/cli/commands/diff.rb', line 94 def read(source) if source.start_with?('https://') || source.start_with?('http://') Support::Network::HTTP.get_body(source) else File.new(source) end end |
#run(page1, page2) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Runs the ronin-web diff
command.
74 75 76 77 78 79 80 81 82 83 |
# File 'lib/ronin/web/cli/commands/diff.rb', line 74 def run(page1,page2) doc1 = Nokogiri::HTML(read(page1)) doc2 = Nokogiri::HTML(read(page2)) doc1.diff(doc2) do |change,node| unless change == ' ' puts "#{change} #{node}" end end end |