Class: Scruber::CLI::Root

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.exit_on_failure?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/scruber/cli.rb', line 11

def self.exit_on_failure?
  true
end

Instance Method Details

#start(name) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/scruber/cli.rb', line 20

def start(name)
  if defined?(APP_PATH)
    scraper_path = Scruber::AppSearcher.find_scraper(name, APP_PATH)
    raise ::Thor::Error, "ERROR: Scraper not found." if scraper_path.nil?
    say "booting..."
    require APP_PATH
    Dir[File.expand_path('../initializers/*.rb', APP_PATH)].sort.each do |i|
      require i
    end
    ENV['SCRUBER_SCRAPER_NAME'] = File.basename(scraper_path).gsub(/\.rb\Z/, '').underscore
    say "starting #{ENV['SCRUBER_SCRAPER_NAME']}"
    
    Scruber.configuration.silent = options[:silent]
    require scraper_path
  else
    raise ::Thor::Error, "ERROR: Scruber project not found."
  end
end

#versionObject



41
42
43
# File 'lib/scruber/cli.rb', line 41

def version
  say "Scruber #{VERSION}"
end