Sha256: 802a5f249877705698e9cc4c2fdc38f532b1d2e041b7671d41567bde90cfade6

Contents?: true

Size: 754 Bytes

Versions: 1

Compression:

Stored size: 754 Bytes

Contents

require 'jog/version'
require 'jog/config'
require 'fileutils'
require 'erb'

module Jog
  include Config

  class << self
    def get_or_create_file( time )
      subpath = time.strftime( Jog.config[:path_format] )
      full_path = File.expand_path( File.join( Jog.config[:root], subpath ) )
      path, _ = File.split( full_path )

      unless File.exists?( full_path )
        FileUtils.mkdir_p( path )
        if Jog.template
          File.open( full_path, 'w' ) do |file|
            text = ERB.new( Jog.template ).result
            file.write( text )
          end
        else
          FileUtils.touch( path )
        end
      end
      full_path
    end

    def edit( path )
      system "#{Jog.config[:editor]} #{path}"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jog-0.0.2 lib/jog.rb