Sha256: 4a5df00fc05cedbf275e66142cd98be11dbd2dce76b03b36b548374edee6cd0a

Contents?: true

Size: 1.02 KB

Versions: 5

Compression:

Stored size: 1.02 KB

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
    h = ENV['EYE_HOME'] || ENV['HOME']
    raise "HOME undefined, should be HOME or EYE_HOME environment" unless h
    h
  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

  def host
    @host ||= begin
      require 'socket'
      Socket.gethostname
    end
  end

  def host=(hostname)
    @host = hostname
  end

end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
reel-eye-0.5.2.1 lib/eye/local.rb
reel-eye-0.5.2 lib/eye/local.rb
eye-0.5.2 lib/eye/local.rb
reel-eye-0.5.1 lib/eye/local.rb
eye-0.5.1 lib/eye/local.rb