Sha256: c9078ae987127946c1756b20c0a319ede02a07fa74ab75badf4438c18b968f16

Contents?: true

Size: 827 Bytes

Versions: 2

Compression:

Stored size: 827 Bytes

Contents

require 'fileutils'

module Eye::Settings
  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.3.2 lib/eye/settings.rb
eye-0.3.2 lib/eye/settings.rb