Class: Robro::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/robro/cli.rb

Instance Method Summary collapse

Instance Method Details

#browse(url) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/robro/cli.rb', line 13

def browse(url)
  uri = validate_url(url)

  Robro.browser = Browser.new options[:browser]
  Robro.browser.visit uri

  quit = false
  until quit
    UserScripts.all.each do |us_class|
      us = us_class.new
      next unless uri.host.start_with? *(us.supported_urls)

      unless us.nil?
        puts "Commands for this URL: #{us.supported_url_commands}"

        us.supported_url_commands.each do |command|
          define_singleton_method command do |*args|
            us.send(command, *args)
          end
        end
      end
    end

    byebug
  end
end