Class: Scruber::CLI::Generators::ScraperGenerator

Inherits:
Thor::Group
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/scruber/cli/generators.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.source_rootObject



13
14
15
# File 'lib/scruber/cli/generators.rb', line 13

def self.source_root
  File.dirname(__FILE__) + '/templates'
end

Instance Method Details

#create_filesObject



17
18
19
20
21
22
23
24
25
26
27
# 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