Sha256: e0f4bfbfb0cf1733b9e8698ed4c7fb11256d66a546137a97df8ae591247e6b4a

Contents?: true

Size: 742 Bytes

Versions: 3

Compression:

Stored size: 742 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 ) )

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

      full_path
    end

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
jog-0.0.6 lib/jog.rb
jog-0.0.5 lib/jog.rb
jog-0.0.4 lib/jog.rb