Module: Ronin::Web::CLI::BrowserOptions Private

Included in:
Commands::Browser, Commands::Screenshot
Defined in:
lib/ronin/web/cli/browser_options.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Adds options for opening a browser.

Since:

  • 2.0.0

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(command) ⇒ 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.

Adds the browser options to the command including Ronin::Web::CLI::BrowserOptions.

Parameters:

Since:

  • 2.0.0



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/ronin/web/cli/browser_options.rb', line 38

def self.included(command)
  command.option :browser, short: '-B',
                           value: {
                             type: String,
                             usage: 'NAME|PATH'
                           },
                           desc: 'The browser name or path to execute'

  command.option :width, short: '-W',
                         value: {
                           type:    Integer,
                           default: 1024,
                           usage:   'WIDTH'
                         },
                         desc: 'Sets the width of the browser viewport'

  command.option :height, short: '-H',
                          value: {
                            type:    Integer,
                            default: 768,
                            usage:   'HEIGHT'
                          },
                          desc: 'Sets the height of the browser viewport'
end

Instance Method Details

#browserRonin::Web::Browser::Agent

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.

The browser agent.

Returns:

  • (Ronin::Web::Browser::Agent)

Since:

  • 2.0.0



68
69
70
# File 'lib/ronin/web/cli/browser_options.rb', line 68

def browser
  @browser ||= Web::Browser.new(**browser_kwargs)
end

#browser_kwargsHash{Symbol => 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.

Keyword arguments for Ronin::Web::Browser.new.

Returns:

  • (Hash{Symbol => Object})

    The keyword arguments.

Since:

  • 2.0.0



78
79
80
81
82
83
84
85
86
87
88
# File 'lib/ronin/web/cli/browser_options.rb', line 78

def browser_kwargs
  kwargs = {
    window_size: [options[:width], options[:height]]
  }

  if options[:browser]
    kwargs[:browser_path] = options[:browser]
  end

  return kwargs
end