Sha256: 3aac9e9893695a673230b75173b29a89b717b82b6cb7b91f036842dd14a2f689

Contents?: true

Size: 953 Bytes

Versions: 1

Compression:

Stored size: 953 Bytes

Contents

require 'tmp'
require 'configer'
module DaemonOgre

  module OPTS

    extend self

    def tmp_folder_path(obj= nil)
      @path ||= nil
      @path = obj unless obj.nil?
      @path || __temp__.tmpdir
    end


    def pid
      pid_number = nil
      __temp__.open('pid','r+'){|f| pid_number = f.read.chomp }
      return pid_number
    end

    def pidfile=(pid_number)
      __temp__.open('pid','w'){|f| f.write(pid_number.to_s) }
    end


    def out__path__
      __temp__.path_for('out')
    end

    def err__path__
      __temp__.path_for('err')
    end

    private

    def __temp__
      @__temp__ ||= __get_temp_dir
    end

    def __get_temp_dir
      require 'tmpdir'
      temp_folder = File.join(::Dir.tmpdir.to_s, "#{__project_name__}_daemon")
      Dir.mkdir(temp_folder) unless File.exist?(temp_folder)
      TMP.new(temp_folder)
    end

    def __project_name__
      ::Configer.pwd.split(File::Separator)[-1]
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
daemon-ogre-2.2.0 lib/daemon-ogre/opts.rb