From 551f8b751fbe1da8c920ecfd81cf747ce3c1ed74 Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Thu, 18 Feb 2016 16:56:39 -0800 Subject: [PATCH 1/4] `jekyll new` should create a Gemfile which is educational --- lib/jekyll/commands/new.rb | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/lib/jekyll/commands/new.rb b/lib/jekyll/commands/new.rb index 433d33b7..0af8553b 100644 --- a/lib/jekyll/commands/new.rb +++ b/lib/jekyll/commands/new.rb @@ -35,6 +35,10 @@ module Jekyll File.open(File.expand_path(initialized_post_name, new_blog_path), "w") do |f| f.write(scaffold_post_content) end + + File.open(File.expand_path("Gemfile", new_blog_path), "w") do |f| + f.write(gemfile_contents) + end end Jekyll.logger.info "New jekyll site installed in #{new_blog_path}." @@ -59,6 +63,27 @@ module Jekyll end private + + def gemfile_contents + <<-RUBY +source 'https://rubygems.org' + +# Hello! This is where you manage which Jekyll version is used to run. +# When you wwant to use a different version, change it below, save the +# file and run `bundle install`. Run Jekyll with `bundle exec`, like so: +# +# bundle exec jekyll serve +# +# This will help ensure the proper Jekyll version is running. +# Happy Jekylling! +gem 'jekyll', '#{Jekyll::VERSION}' + +# If you have any plugins, put them here! +# group :jekyll_plugins do +# gem 'jekyll-github-metadata', '~> 1.0' +# end +RUBY + end def preserve_source_location?(path, options) !options["force"] && !Dir["#{path}/**/*"].empty? From 09f9f193d8e5fb714a6852c9276be1c6e55efbe8 Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Wed, 23 Mar 2016 17:15:35 -0700 Subject: [PATCH 2/4] Add comment about github-pages --- lib/jekyll/commands/new.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/jekyll/commands/new.rb b/lib/jekyll/commands/new.rb index 0af8553b..b4ecf808 100644 --- a/lib/jekyll/commands/new.rb +++ b/lib/jekyll/commands/new.rb @@ -69,14 +69,18 @@ module Jekyll source 'https://rubygems.org' # Hello! This is where you manage which Jekyll version is used to run. -# When you wwant to use a different version, change it below, save the +# When you want to use a different version, change it below, save the # file and run `bundle install`. Run Jekyll with `bundle exec`, like so: # # bundle exec jekyll serve # # This will help ensure the proper Jekyll version is running. # Happy Jekylling! -gem 'jekyll', '#{Jekyll::VERSION}' +gem "jekyll", "#{Jekyll::VERSION}" + +# If you want to use GitHub Pages, remove the "gem "jekyll"" above and +# uncomment the line below. To upgrade, run `bundle update github-pages`. +# gem "github-pages", group: :jekyll_plugins # If you have any plugins, put them here! # group :jekyll_plugins do From da35e134f12243ff8a96c714c3e4e12adf437ca5 Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Wed, 23 Mar 2016 17:24:33 -0700 Subject: [PATCH 3/4] Add test for creation of Gemfile by 'jekyll new' --- test/test_new_command.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/test_new_command.rb b/test/test_new_command.rb index f0d2a389..7ba84781 100644 --- a/test/test_new_command.rb +++ b/test/test_new_command.rb @@ -29,6 +29,15 @@ class TestNewCommand < JekyllUnitTest assert_exist @full_path end + should "create a Gemfile" do + gemfile = File.join(@full_path, "Gemfile") + refute_exist @full_path + capture_stdout { Jekyll::Commands::New.process(@args) } + assert_exist gemfile + assert_match /gem "jekyll", "#{Jekyll::VERSION}"/, File.read(gemfile) + assert_match /gem "github-pages"/, File.read(gemfile) + end + should 'display a success message' do Jekyll::Commands::New.process(@args) output = Jekyll.logger.messages.last @@ -40,6 +49,7 @@ class TestNewCommand < JekyllUnitTest static_template_files = dir_contents(site_template).reject do |f| File.extname(f) == '.erb' end + static_template_files << "/Gemfile" capture_stdout { Jekyll::Commands::New.process(@args) } From 22d9312eafed6e14e844ecf6ad7e3f70d59bbb37 Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Wed, 23 Mar 2016 17:25:19 -0700 Subject: [PATCH 4/4] Use double quotes in the gemfile --- lib/jekyll/commands/new.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/jekyll/commands/new.rb b/lib/jekyll/commands/new.rb index b4ecf808..689895be 100644 --- a/lib/jekyll/commands/new.rb +++ b/lib/jekyll/commands/new.rb @@ -66,7 +66,7 @@ module Jekyll def gemfile_contents <<-RUBY -source 'https://rubygems.org' +source "https://rubygems.org" # Hello! This is where you manage which Jekyll version is used to run. # When you want to use a different version, change it below, save the @@ -84,7 +84,7 @@ gem "jekyll", "#{Jekyll::VERSION}" # If you have any plugins, put them here! # group :jekyll_plugins do -# gem 'jekyll-github-metadata', '~> 1.0' +# gem "jekyll-github-metadata", "~> 1.0" # end RUBY end