class Scruber::CLI::Generators::ScraperGenerator

Public Class Methods

source_root() click to toggle source
# File lib/scruber/cli/generators.rb, line 13
def self.source_root
  File.dirname(__FILE__) + '/templates'
end

Public Instance Methods

create_files() click to toggle source
# File lib/scruber/cli/generators.rb, line 17
def create_files
  if defined?(APP_PATH)
    scraper_path = Scruber::AppSearcher.find_scraper(name, APP_PATH)
    if scraper_path.present?
      raise ::Thor::Error, "ERROR: Scraper already exists" 
    end
    template 'scrapers/sample.tt', File.expand_path('../../scrapers/'+name+'.rb', APP_PATH)
  else
    raise ::Thor::Error, "ERROR: Scruber project not found."
  end
end