lib/mr_poole/commands.rb
def publish(draftpath, opts={})
      opts = @helper.ensure_open_struct(opts)
      tail = File.basename(draftpath)

      begin
        infile = File.open(draftpath, "r")
      rescue Errno::ENOENT
        @helper.bad_path(draftpath)
      end

      date = @helper.get_date_stamp
      time = @helper.get_time_stamp

      outpath = File.join(POSTS_FOLDER, "#{date}-#{tail}")
      outfile = File.open(outpath, "w")

      infile.each_line do |line|
        line.sub!(/^date:.*$/, "date: #{date} #{time}\n") unless opts.keep_timestamp
        outfile.write(line)
      end

      infile.close
      outfile.close
      FileUtils.rm(draftpath) unless opts.keep_draft

      outpath
    end
def publish(draftpath, opts={})
      opts = @helper.ensure_open_struct(opts)
      tail = File.basename(draftpath)

      begin
        infile = File.open(draftpath, "r")
      rescue Errno::ENOENT
        @helper.bad_path(draftpath)
      end

      date = @helper.get_date_stamp
      time = @helper.get_time_stamp

      outpath = File.join(POSTS_FOLDER, "#{date}-#{tail}")
      outfile = File.open(outpath, "w")

      infile.each_line do |line|
        line.sub!(/^date:.*$/, "date: #{date} #{time}\n") unless opts.keep_timestamp
        outfile.write(line)
      end

      infile.close
      outfile.close
      FileUtils.rm(draftpath) unless opts.keep_draft

      outpath
    end
Todo make this take a path instead?

 @param draftpath [String] path to the draft, relative to source directory
 @option options :keep_draft [Boolean] if true, keep the draft file
 @option options :keep_timestamp [Boolean] if true, don't change the timestamp