lib/commands/new_command.rb in ignoramos-1.0.1 vs lib/commands/new_command.rb in ignoramos-1.1.0

- old
+ new

@@ -1,12 +1,14 @@ require 'fileutils' +require 'file_helper' class NewCommand attr_accessor :dir def initialize(dir) @dir = dir.to_s + @file_helper = FileHelper.new(dir) end def execute FileUtils.mkdir_p([ "#{ @dir }/_drafts", @@ -19,16 +21,9 @@ blog_name = 'My First Blog' tagline = 'A short description of my blog' desc = 'Site description' - new_file("_config.yml", - "---\nsite:\n name: #{ blog_name }\n tagline: #{ tagline }\n description: #{ desc }") - end - - private - def new_file(filename, contents) - new_post_file = File.new("#{ @dir }/#{ filename }", 'w') - new_post_file.write(contents) - new_post_file.close + @file_helper.new_file("_config.yml", + "---\nsite:\n name: #{ blog_name }\n tagline: #{ tagline }\n description: #{ desc }") end end