From 6f89fd5f3fb27ff13230c67d40b8d8cb4f1dd2c9 Mon Sep 17 00:00:00 2001 From: TheLucasMoore Date: Thu, 12 May 2016 16:58:17 -0500 Subject: [PATCH 1/6] clean.rb passing rubocop --- .rubocop.yml | 1 - lib/jekyll/commands/clean.rb | 17 +++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 7bf38d38..b6fe2cc3 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -8,7 +8,6 @@ AllCops: - lib/jekyll/collection.rb - lib/jekyll/command.rb - lib/jekyll/commands/build.rb - - lib/jekyll/commands/clean.rb - lib/jekyll/commands/doctor.rb - lib/jekyll/commands/help.rb - lib/jekyll/commands/new.rb diff --git a/lib/jekyll/commands/clean.rb b/lib/jekyll/commands/clean.rb index ca19d9b5..addf11a2 100644 --- a/lib/jekyll/commands/clean.rb +++ b/lib/jekyll/commands/clean.rb @@ -4,8 +4,9 @@ module Jekyll class << self def init_with_program(prog) prog.command(:clean) do |c| - c.syntax 'clean [subcommand]' - c.description 'Clean the site (removes site output and metadata file) without building.' + c.syntax "clean [subcommand]" + c.description "Clean the site + (removes site output and metadata file) without building." add_build_options(c) @@ -17,13 +18,13 @@ module Jekyll def process(options) options = configuration_from_options(options) - destination = options['destination'] - metadata_file = File.join(options['source'], '.jekyll-metadata') - sass_cache = File.join(options['source'], '.sass-cache') + destination = options["destination"] + metadata_file = File.join(options["source"], ".jekyll-metadata") + sass_cache = File.join(options["source"], ".sass-cache") - remove(destination, checker_func: :directory?) - remove(metadata_file, checker_func: :file?) - remove(sass_cache, checker_func: :directory?) + remove(destination, :checker_func => :directory?) + remove(metadata_file, :checker_func => :file?) + remove(sass_cache, :checker_func => :directory?) end def remove(filename, checker_func: :file?) From 26d0a8db77086f69d3ae279a785844ee8ca098fa Mon Sep 17 00:00:00 2001 From: TheLucasMoore Date: Thu, 12 May 2016 19:11:58 -0500 Subject: [PATCH 2/6] Passing RuboCop for commands --- .rubocop.yml | 7 ---- lib/jekyll/commands/build.rb | 27 ++++++++------- lib/jekyll/commands/clean.rb | 4 +-- lib/jekyll/commands/doctor.rb | 13 ++++---- lib/jekyll/commands/help.rb | 7 ++-- lib/jekyll/commands/new.rb | 49 +++++++++++++++------------- lib/jekyll/commands/serve.rb | 26 +++++++-------- lib/jekyll/commands/serve/servlet.rb | 4 +-- 8 files changed, 70 insertions(+), 67 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index b6fe2cc3..dc57b94d 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -7,13 +7,6 @@ AllCops: - lib/jekyll/cleaner.rb - lib/jekyll/collection.rb - lib/jekyll/command.rb - - lib/jekyll/commands/build.rb - - lib/jekyll/commands/doctor.rb - - lib/jekyll/commands/help.rb - - lib/jekyll/commands/new.rb - - lib/jekyll/commands/serve - - lib/jekyll/commands/serve/servlet.rb - - lib/jekyll/commands/serve.rb - lib/jekyll/configuration.rb - lib/jekyll/converter.rb - lib/jekyll/converters/identity.rb diff --git a/lib/jekyll/commands/build.rb b/lib/jekyll/commands/build.rb index baa4e88a..cef13c91 100644 --- a/lib/jekyll/commands/build.rb +++ b/lib/jekyll/commands/build.rb @@ -5,8 +5,8 @@ module Jekyll # Create the Mercenary command for the Jekyll CLI for this Command def init_with_program(prog) prog.command(:build) do |c| - c.syntax 'build [options]' - c.description 'Build your site' + c.syntax "build [options]" + c.description "Build your site" c.alias :b add_build_options(c) @@ -27,15 +27,17 @@ module Jekyll options = configuration_from_options(options) site = Jekyll::Site.new(options) - if options.fetch('skip_initial_build', false) - Jekyll.logger.warn "Build Warning:", "Skipping the initial build. This may result in an out-of-date site." + if options.fetch("skip_initial_build", false) + Jekyll.logger.warn "Build Warning:", "Skipping the initial build." \ + " This may result in an out-of-date site." else build(site, options) end - if options.fetch('detach', false) - Jekyll.logger.info "Auto-regeneration:", "disabled when running server detached." - elsif options.fetch('watch', false) + if options.fetch("detach", false) + Jekyll.logger.info "Auto-regeneration:", + "disabled when running server detached." + elsif options.fetch("watch", false) watch(site, options) else Jekyll.logger.info "Auto-regeneration:", "disabled. Use --watch to enable." @@ -50,12 +52,13 @@ module Jekyll # Returns nothing. def build(site, options) t = Time.now - source = options['source'] - destination = options['destination'] - incremental = options['incremental'] + source = options["source"] + destination = options["destination"] + incremental = options["incremental"] Jekyll.logger.info "Source:", source Jekyll.logger.info "Destination:", destination - Jekyll.logger.info "Incremental build:", (incremental ? "enabled" : "disabled. Enable with --incremental") + Jekyll.logger.info "Incremental build:", + (incremental ? "enabled" : "disabled. Enable with --incremental") Jekyll.logger.info "Generating..." process_site(site) Jekyll.logger.info "", "done in #{(Time.now - t).round(3)} seconds." @@ -68,7 +71,7 @@ module Jekyll # # Returns nothing. def watch(_site, options) - External.require_with_graceful_fail 'jekyll-watch' + External.require_with_graceful_fail "jekyll-watch" Jekyll::Watcher.watch(options) end end # end of class << self diff --git a/lib/jekyll/commands/clean.rb b/lib/jekyll/commands/clean.rb index addf11a2..3a44d596 100644 --- a/lib/jekyll/commands/clean.rb +++ b/lib/jekyll/commands/clean.rb @@ -5,8 +5,8 @@ module Jekyll def init_with_program(prog) prog.command(:clean) do |c| c.syntax "clean [subcommand]" - c.description "Clean the site - (removes site output and metadata file) without building." + c.description "Clean the site " \ + "(removes site output and metadata file) without building." add_build_options(c) diff --git a/lib/jekyll/commands/doctor.rb b/lib/jekyll/commands/doctor.rb index 5c48d5be..68caa2e0 100644 --- a/lib/jekyll/commands/doctor.rb +++ b/lib/jekyll/commands/doctor.rb @@ -4,11 +4,12 @@ module Jekyll class << self def init_with_program(prog) prog.command(:doctor) do |c| - c.syntax 'doctor' - c.description 'Search site and print specific deprecation warnings' + c.syntax "doctor" + c.description "Search site and print specific deprecation warnings" c.alias(:hyde) - c.option 'config', '--config CONFIG_FILE[,CONFIG_FILE2,...]', Array, 'Custom configuration file' + c.option "config", "--config CONFIG_FILE[,CONFIG_FILE2,...]", Array, + "Custom configuration file" c.action do |_, options| Jekyll::Commands::Doctor.process(options) @@ -37,7 +38,7 @@ module Jekyll end def deprecated_relative_permalinks(site) - if site.config['relative_permalinks'] + if site.config["relative_permalinks"] Jekyll::Deprecator.deprecation_message "Your site still uses relative" \ " permalinks, which was removed in" \ " Jekyll v3.0.0." @@ -78,7 +79,7 @@ module Jekyll def urls_only_differ_by_case(site) urls_only_differ_by_case = false urls = case_insensitive_urls(site.pages + site.docs_to_write, site.dest) - urls.each do |case_insensitive_url, real_urls| + urls.each do |_case_insensitive_url, real_urls| next unless real_urls.uniq.size > 1 urls_only_differ_by_case = true Jekyll.logger.warn "Warning:", "The following URLs only differ" \ @@ -102,7 +103,7 @@ module Jekyll end def case_insensitive_urls(things, destination) - things.inject({}) do |memo, thing| + things.each_with_object({}) do |memo, thing| dest = thing.destination(destination) (memo[dest.downcase] ||= []) << dest memo diff --git a/lib/jekyll/commands/help.rb b/lib/jekyll/commands/help.rb index 01bf3280..b4f136bf 100644 --- a/lib/jekyll/commands/help.rb +++ b/lib/jekyll/commands/help.rb @@ -4,8 +4,8 @@ module Jekyll class << self def init_with_program(prog) prog.command(:help) do |c| - c.syntax 'help [subcommand]' - c.description 'Show the help message, optionally for a given subcommand.' + c.syntax "help [subcommand]" + c.description "Show the help message, optionally for a given subcommand." c.action do |args, _| cmd = (args.first || "").to_sym @@ -22,7 +22,8 @@ module Jekyll end def invalid_command(prog, cmd) - Jekyll.logger.error "Error:", "Hmm... we don't know what the '#{cmd}' command is." + Jekyll.logger.error "Error:", + "Hmm... we don't know what the '#{cmd}' command is." Jekyll.logger.info "Valid commands:", prog.commands.keys.join(", ") end end diff --git a/lib/jekyll/commands/new.rb b/lib/jekyll/commands/new.rb index 50838f41..c44379eb 100644 --- a/lib/jekyll/commands/new.rb +++ b/lib/jekyll/commands/new.rb @@ -1,4 +1,4 @@ -require 'erb' +require "erb" module Jekyll module Commands @@ -6,11 +6,11 @@ module Jekyll class << self def init_with_program(prog) prog.command(:new) do |c| - c.syntax 'new PATH' - c.description 'Creates a new Jekyll site scaffold in PATH' + c.syntax "new PATH" + c.description "Creates a new Jekyll site scaffold in PATH" - c.option 'force', '--force', 'Force creation even if PATH already exists' - c.option 'blank', '--blank', 'Creates scaffolding but with empty files' + c.option "force", "--force", "Force creation even if PATH already exists" + c.option "blank", "--blank", "Creates scaffolding but with empty files" c.action do |args, options| Jekyll::Commands::New.process(args, options) @@ -19,27 +19,16 @@ module Jekyll end def process(args, options = {}) - raise ArgumentError.new('You must specify a path.') if args.empty? + raise ArgumentError, "You must specify a path." if args.empty? new_blog_path = File.expand_path(args.join(" "), Dir.pwd) FileUtils.mkdir_p new_blog_path if preserve_source_location?(new_blog_path, options) - Jekyll.logger.abort_with "Conflict:", "#{new_blog_path} exists and is not empty." + Jekyll.logger.abort_with "Conflict:", + "#{new_blog_path} exists and is not empty." end - if options["blank"] - create_blank_site new_blog_path - else - create_sample_files new_blog_path - - 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 + if_blank_options Jekyll.logger.info "New jekyll site installed in #{new_blog_path}." end @@ -59,7 +48,7 @@ module Jekyll # # Returns the filename of the sample post, as a String def initialized_post_name - "_posts/#{Time.now.strftime('%Y-%m-%d')}-welcome-to-jekyll.markdown" + "_posts/#{Time.now.strftime("%Y-%m-%d")}-welcome-to-jekyll.markdown" end private @@ -95,7 +84,7 @@ RUBY end def create_sample_files(path) - FileUtils.cp_r site_template + '/.', path + FileUtils.cp_r site_template + "/.", path FileUtils.rm File.expand_path(scaffold_path, path) end @@ -106,6 +95,22 @@ RUBY def scaffold_path "_posts/0000-00-00-welcome-to-jekyll.markdown.erb" end + + def if_blank_options + if options["blank"] + create_blank_site new_blog_path + else + create_sample_files new_blog_path + + 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 + end end end end diff --git a/lib/jekyll/commands/serve.rb b/lib/jekyll/commands/serve.rb index 1482dbed..7f0d0f84 100644 --- a/lib/jekyll/commands/serve.rb +++ b/lib/jekyll/commands/serve.rb @@ -14,7 +14,7 @@ module Jekyll "Show a directory listing instead of loading your index file."], "skip_initial_build" => ["skip_initial_build", "--skip-initial-build", "Skips the initial site build which occurs before the server is started."] - } + }.freeze # @@ -93,7 +93,7 @@ module Jekyll ) } - opts[:DirectoryIndex] = [] if opts[:JekyllOptions]['show_dir_listing'] + opts[:DirectoryIndex] = [] if opts[:JekyllOptions]["show_dir_listing"] enable_ssl(opts) enable_logging(opts) @@ -107,7 +107,7 @@ module Jekyll WEBrick::Config::FileHandler.merge({ :FancyIndexing => true, :NondisclosureName => [ - '.ht*', '~*' + ".ht*", "~*" ] }) end @@ -116,12 +116,12 @@ module Jekyll private def server_address(server, opts) - "%{prefix}://%{address}:%{port}%{baseurl}" % { + format("%{prefix}://%{address}:%{port}%{baseurl}", { :prefix => server.config[:SSLEnable] ? "https" : "http", :baseurl => opts["baseurl"] ? "#{opts["baseurl"]}/" : "", :address => server.config[:BindAddress], :port => server.config[:Port] - } + }) end # @@ -173,20 +173,20 @@ module Jekyll private def enable_ssl(opts) return if !opts[:JekyllOptions]["ssl_cert"] && !opts[:JekyllOptions]["ssl_key"] - if !opts[:JekyllOptions]["ssl_cert"] || !opts[:JekyllOptions]["ssl_key"] - raise RuntimeError, "--ssl-cert or --ssl-key missing." - end - require "openssl" require "webrick/https" - source_key = Jekyll.sanitized_path(opts[:JekyllOptions]["source"], opts[:JekyllOptions]["ssl_key" ]) - source_certificate = Jekyll.sanitized_path(opts[:JekyllOptions]["source"], opts[:JekyllOptions]["ssl_cert"]) - opts[:SSLCertificate] = OpenSSL::X509::Certificate.new(File.read(source_certificate)) + source_key = Jekyll.sanitized_path(opts[:JekyllOptions]["source"], \ + opts[:JekyllOptions]["ssl_key" ]) + source_certificate = Jekyll.sanitized_path(opts[:JekyllOptions]["source"], \ + opts[:JekyllOptions]["ssl_cert"]) + opts[:SSLCertificate] = + OpenSSL::X509::Certificate.new(File.read(source_certificate)) opts[:SSLPrivateKey ] = OpenSSL::PKey::RSA.new(File.read(source_key)) opts[:SSLEnable] = true end private + def start_callback(detached) unless detached proc do @@ -197,7 +197,7 @@ module Jekyll private def mime_types - file = File.expand_path('../mime.types', File.dirname(__FILE__)) + file = File.expand_path("../mime.types", File.dirname(__FILE__)) WEBrick::HTTPUtils.load_mime_types(file) end end diff --git a/lib/jekyll/commands/serve/servlet.rb b/lib/jekyll/commands/serve/servlet.rb index bb4afe5a..d7c52af9 100644 --- a/lib/jekyll/commands/serve/servlet.rb +++ b/lib/jekyll/commands/serve/servlet.rb @@ -7,7 +7,7 @@ module Jekyll DEFAULTS = { "Cache-Control" => "private, max-age=0, proxy-revalidate, " \ "no-store, no-cache, must-revalidate" - } + }.freeze def initialize(server, root, callbacks) # So we can access them easily. @@ -27,7 +27,7 @@ module Jekyll # - def do_GET(req, res) + def do_get(req, res) rtn = super validate_and_ensure_charset(req, res) res.header.merge!(@headers) From 894d1fe21e32aae70b5f1a63850cc9cb8ffb7fb5 Mon Sep 17 00:00:00 2001 From: TheLucasMoore Date: Thu, 12 May 2016 19:42:04 -0500 Subject: [PATCH 3/6] Tests Passing. Three RuboCop revisions remain --- lib/jekyll/commands/doctor.rb | 3 +-- lib/jekyll/commands/new.rb | 30 +++++++++++++----------------- lib/jekyll/commands/serve.rb | 3 +++ 3 files changed, 17 insertions(+), 19 deletions(-) diff --git a/lib/jekyll/commands/doctor.rb b/lib/jekyll/commands/doctor.rb index 68caa2e0..0c4f52f8 100644 --- a/lib/jekyll/commands/doctor.rb +++ b/lib/jekyll/commands/doctor.rb @@ -103,10 +103,9 @@ module Jekyll end def case_insensitive_urls(things, destination) - things.each_with_object({}) do |memo, thing| + things.each_with_object({}) do |thing, memo| dest = thing.destination(destination) (memo[dest.downcase] ||= []) << dest - memo end end end diff --git a/lib/jekyll/commands/new.rb b/lib/jekyll/commands/new.rb index c44379eb..4bfcca0f 100644 --- a/lib/jekyll/commands/new.rb +++ b/lib/jekyll/commands/new.rb @@ -28,7 +28,19 @@ module Jekyll "#{new_blog_path} exists and is not empty." end - if_blank_options + if options["blank"] + create_blank_site new_blog_path + else + create_sample_files new_blog_path + + 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}." end @@ -95,22 +107,6 @@ RUBY def scaffold_path "_posts/0000-00-00-welcome-to-jekyll.markdown.erb" end - - def if_blank_options - if options["blank"] - create_blank_site new_blog_path - else - create_sample_files new_blog_path - - 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 - end end end end diff --git a/lib/jekyll/commands/serve.rb b/lib/jekyll/commands/serve.rb index 7f0d0f84..3f630065 100644 --- a/lib/jekyll/commands/serve.rb +++ b/lib/jekyll/commands/serve.rb @@ -173,6 +173,9 @@ module Jekyll private def enable_ssl(opts) return if !opts[:JekyllOptions]["ssl_cert"] && !opts[:JekyllOptions]["ssl_key"] + if !opts[:JekyllOptions]["ssl_cert"] || !opts[:JekyllOptions]["ssl_key"] + raise RuntimeError, "--ssl-cert or --ssl-key missing." + end require "openssl" require "webrick/https" source_key = Jekyll.sanitized_path(opts[:JekyllOptions]["source"], \ From 451881efcf969b379af068a4f0d6b93c47d12bee Mon Sep 17 00:00:00 2001 From: TheLucasMoore Date: Thu, 12 May 2016 20:21:19 -0500 Subject: [PATCH 4/6] ABC Condition Size too high --- lib/jekyll/commands/serve.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/jekyll/commands/serve.rb b/lib/jekyll/commands/serve.rb index 3f630065..8813ac04 100644 --- a/lib/jekyll/commands/serve.rb +++ b/lib/jekyll/commands/serve.rb @@ -174,7 +174,7 @@ module Jekyll def enable_ssl(opts) return if !opts[:JekyllOptions]["ssl_cert"] && !opts[:JekyllOptions]["ssl_key"] if !opts[:JekyllOptions]["ssl_cert"] || !opts[:JekyllOptions]["ssl_key"] - raise RuntimeError, "--ssl-cert or --ssl-key missing." + raise RuntimeError end require "openssl" require "webrick/https" From 465e7dd8b0c0ebf38a15ef1c6e4eb388439395ba Mon Sep 17 00:00:00 2001 From: TheLucasMoore Date: Fri, 13 May 2016 13:46:42 -0500 Subject: [PATCH 5/6] Added Exceptions and Passing ABC Metric --- lib/jekyll/commands/new.rb | 30 ++++++++++++++++------------ lib/jekyll/commands/serve.rb | 4 +++- lib/jekyll/commands/serve/servlet.rb | 5 ++--- 3 files changed, 22 insertions(+), 17 deletions(-) diff --git a/lib/jekyll/commands/new.rb b/lib/jekyll/commands/new.rb index 4bfcca0f..af336e9c 100644 --- a/lib/jekyll/commands/new.rb +++ b/lib/jekyll/commands/new.rb @@ -28,19 +28,7 @@ module Jekyll "#{new_blog_path} exists and is not empty." end - if options["blank"] - create_blank_site new_blog_path - else - create_sample_files new_blog_path - - 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 + if_options_blank(new_blog_path, options) Jekyll.logger.info "New jekyll site installed in #{new_blog_path}." end @@ -91,6 +79,22 @@ gem "jekyll", "#{Jekyll::VERSION}" RUBY end + def if_options_blank(new_blog_path, options) + if options["blank"] + create_blank_site new_blog_path + else + create_sample_files new_blog_path + + 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 + end + def preserve_source_location?(path, options) !options["force"] && !Dir["#{path}/**/*"].empty? end diff --git a/lib/jekyll/commands/serve.rb b/lib/jekyll/commands/serve.rb index 8813ac04..8c633397 100644 --- a/lib/jekyll/commands/serve.rb +++ b/lib/jekyll/commands/serve.rb @@ -171,10 +171,12 @@ module Jekyll # forget to add one of the certificates. private + # rubocop:disable Metrics/AbcSize def enable_ssl(opts) return if !opts[:JekyllOptions]["ssl_cert"] && !opts[:JekyllOptions]["ssl_key"] if !opts[:JekyllOptions]["ssl_cert"] || !opts[:JekyllOptions]["ssl_key"] - raise RuntimeError + # rubocop:disable Style/RedundantException + raise RuntimeError, "--ssl-cert or --ssl-key missing." end require "openssl" require "webrick/https" diff --git a/lib/jekyll/commands/serve/servlet.rb b/lib/jekyll/commands/serve/servlet.rb index d7c52af9..5f258e6e 100644 --- a/lib/jekyll/commands/serve/servlet.rb +++ b/lib/jekyll/commands/serve/servlet.rb @@ -25,9 +25,8 @@ module Jekyll super || super(req, res, "#{basename}.html") end - # - - def do_get(req, res) + # rubocop:disable Style/MethodName + def do_GET(req, res) rtn = super validate_and_ensure_charset(req, res) res.header.merge!(@headers) From b64b6aa52601025e5fddf4b8c68588f120536612 Mon Sep 17 00:00:00 2001 From: TheLucasMoore Date: Fri, 13 May 2016 15:10:59 -0500 Subject: [PATCH 6/6] Refactor if/else for new.rb process method --- lib/jekyll/commands/new.rb | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/jekyll/commands/new.rb b/lib/jekyll/commands/new.rb index af336e9c..2658383c 100644 --- a/lib/jekyll/commands/new.rb +++ b/lib/jekyll/commands/new.rb @@ -28,7 +28,11 @@ module Jekyll "#{new_blog_path} exists and is not empty." end - if_options_blank(new_blog_path, options) + if options["blank"] + create_blank_site new_blog_path + else + create_site new_blog_path + end Jekyll.logger.info "New jekyll site installed in #{new_blog_path}." end @@ -79,19 +83,15 @@ gem "jekyll", "#{Jekyll::VERSION}" RUBY end - def if_options_blank(new_blog_path, options) - if options["blank"] - create_blank_site new_blog_path - else - create_sample_files new_blog_path + def create_site(new_blog_path) + create_sample_files new_blog_path - 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(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 + File.open(File.expand_path("Gemfile", new_blog_path), "w") do |f| + f.write(gemfile_contents) end end