class Neverprint::Commands::New
Public Class Methods
process(args, options = {})
click to toggle source
# File lib/neverprint/commands/new.rb, line 4 def self.process(args, options = {}) raise ArgumentError.new('You must specify a path.') if args.empty? new_site_path = File.expand_path(args.join(" "), Dir.pwd) puts "\n- Checking if Jekyll site exists in" puts " #{new_site_path}" if !provided_path_is_a_jekyll_site?(new_site_path) Jekyll.logger.error('Jekyll site', '[ Not present ]') if options[:generate] puts "\n- Calling Jekyll to generate it for you" Jekyll::Commands::New.process(args) Jekyll.logger.warn('Jekyll site', '[ Created ]') puts "\n" else Jekyll.logger.warn('', 'Use --generate to have Jekyll generate it') Jekyll.logger.warn('', 'Or use Jekyll directly and create it yourself') puts "\n" exit(1) end else Jekyll.logger.warn('Jekyll site', '[ Present ]') end puts "\n- Adding Neverprint files to site" add_neverprint_files new_site_path Jekyll.logger.warn('Neverprint files', '[ Added ]') puts "\n" end
Private Class Methods
add_neverprint_files(path)
click to toggle source
# File lib/neverprint/commands/new.rb, line 41 def self.add_neverprint_files(path) FileUtils.cp_r neverprint_template + '/.', path #FileUtils.rm File.expand_path(scaffold_path, path) end
neverprint_template()
click to toggle source
# File lib/neverprint/commands/new.rb, line 46 def self.neverprint_template File.expand_path("../../neverprint_template", File.dirname(__FILE__)) end
provided_path_is_a_jekyll_site?(path)
click to toggle source
# File lib/neverprint/commands/new.rb, line 50 def self.provided_path_is_a_jekyll_site?(path) !Dir["#{path}/_posts"].empty? end