#!/usr/bin/env ruby require 'thor' # require 'scrapers' require "active_support/core_ext/string/inflections" # require 'pry' class NewScraper < Thor::Group include Thor::Actions argument :name class_option :make_bin, :aliases => "-B", :default => true def self.source_root File.expand_path("../../", __FILE__) end def create_bin_file return unless options["make_bin"] template("templates/bin/new_scraper_bin.erb", "bin/#{file_name}") template("templates/lib/new_scraper_thor.rb.erb", "lib/#{file_name}_thor.rb") template("templates/spec/new_scraper_thor_spec.rb.erb", "spec/#{file_name}_thor_spec.rb") end def create_scraper_lib_file template("templates/lib/scrapers/new_scraper_lib.rb.erb", "lib/scrapers/#{file_name}.rb") template("templates/spec/lib/new_scraper_lib_spec.rb.erb", "spec/lib/scrapers/#{file_name}_spec.rb") end private def file_name name.underscore end end NewScraper.start