Sha256: 4e7834d7a8ce5df96eae1acf48303162b9eb5a4f24330074333a71b5b1d022d1

Contents?: true

Size: 816 Bytes

Versions: 2

Compression:

Stored size: 816 Bytes

Contents

require 'fileutils'

module Eye::Local
  module_function

  def dir
    if root?
      '/var/run/eye'
    else
      File.expand_path(File.join(home, '.eye'))
    end
  end

  def eyeconfig
    if root?
      '/etc/eye.conf'
    else
      File.expand_path(File.join(home, '.eyeconfig'))
    end
  end

  def root?
    Process::UID.eid == 0
  end

  def home
    ENV['EYE_HOME'] || ENV['HOME']
  end

  def path(path)
    File.join(dir, path)
  end

  def ensure_eye_dir
    FileUtils.mkdir_p( dir )
  end

  def socket_path
    path(ENV['EYE_SOCK'] || "sock#{ENV['EYE_V']}")
  end

  def pid_path
    path(ENV['EYE_PID'] || "pid#{ENV['EYE_V']}")
  end

  def cache_path
    path("processes#{ENV['EYE_V']}.cache")
  end

  def client_timeout
    5
  end

  def supported_setsid?
    RUBY_VERSION >= '2.0'
  end

end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
reel-eye-0.5 lib/eye/local.rb
eye-0.5 lib/eye/local.rb