diff --git a/jekyll.gemspec b/jekyll.gemspec index 8291d9ae..a6efcd62 100644 --- a/jekyll.gemspec +++ b/jekyll.gemspec @@ -30,7 +30,7 @@ Gem::Specification.new do |s| s.add_runtime_dependency('kramdown', "~> 0.13.4") s.add_runtime_dependency('pygments.rb', "~> 0.3.2") s.add_runtime_dependency('commander', "~> 4.1.3") - s.add_runtime_dependency('safe_yaml', "~> 0.4") + s.add_runtime_dependency('safe_yaml', "~> 0.7.0") s.add_development_dependency('rake', "~> 0.9") s.add_development_dependency('rdoc', "~> 3.11") @@ -113,7 +113,7 @@ Gem::Specification.new do |s| lib/site_template/_config.yml lib/site_template/_layouts/default.html lib/site_template/_layouts/post.html - lib/site_template/_posts/0000-00-00-sample_post.markdown.erb + lib/site_template/_posts/0000-00-00-welcome-to-jekyll.markdown.erb lib/site_template/css/screen.css lib/site_template/css/syntax.css lib/site_template/images/.gitkeep diff --git a/lib/jekyll/commands/new.rb b/lib/jekyll/commands/new.rb index dc71545f..e650dc52 100644 --- a/lib/jekyll/commands/new.rb +++ b/lib/jekyll/commands/new.rb @@ -3,21 +3,22 @@ require 'erb' module Jekyll module Commands class New < Command - def self.process(args) + raise ArgumentError.new('You must specify a path.') if args.empty? + new_blog_path = File.expand_path(args.join(" "), Dir.pwd) FileUtils.mkdir_p new_blog_path - create_sample_files! new_blog_path + create_sample_files new_blog_path File.open(File.expand_path(self.initialized_post_name, new_blog_path), "w") do |f| - f.write(self.scaffold_post_content(template_site)) + f.write(self.scaffold_post_content(site_template)) end puts "New jekyll site installed in #{new_blog_path}." end def self.scaffold_post_content(template_site) - ERB.new(File.read(File.expand_path(scaffold_path, template_site))).result + ERB.new(File.read(File.expand_path(scaffold_path, site_template))).result end # Internal: Gets the filename of the sample post to be created @@ -28,23 +29,18 @@ module Jekyll end private + def self.create_sample_files(path) + FileUtils.cp_r site_template + '/.', path + FileUtils.rm File.expand_path(scaffold_path, path) + end - def self.create_sample_files!(path) - FileUtils.cp_r sample_files, path - FileUtils.rm File.expand_path(scaffold_path, path) - end + def self.site_template + File.expand_path("../../site_template", File.dirname(__FILE__)) + end - def self.sample_files - Dir.glob("#{template_site}/**/*") - end - - def self.template_site - File.expand_path("../../site_template", File.dirname(__FILE__)) - end - - def self.scaffold_path - "_posts/0000-00-00-sample_post.markdown.erb" - end + def self.scaffold_path + "_posts/0000-00-00-welcome-to-jekyll.markdown.erb" + end end end end diff --git a/lib/site_template/_posts/0000-00-00-sample_post.markdown.erb b/lib/site_template/_posts/0000-00-00-welcome-to-jekyll.markdown.erb similarity index 100% rename from lib/site_template/_posts/0000-00-00-sample_post.markdown.erb rename to lib/site_template/_posts/0000-00-00-welcome-to-jekyll.markdown.erb diff --git a/test/test_new_command.rb b/test/test_new_command.rb index 2532bea8..bc9e6585 100644 --- a/test/test_new_command.rb +++ b/test/test_new_command.rb @@ -42,8 +42,8 @@ class TestNewCommand < Test::Unit::TestCase capture_stdout { Jekyll::Commands::New.process(@args) } - new_site_files = dir_contents(@full_path).select do |f| - static_template_files.include? f + new_site_files = dir_contents(@full_path).reject do |f| + File.extname(f) == '.markdown' end assert_same_elements static_template_files, new_site_files