Class: Daemons::Rails::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/daemons/rails/configuration.rb

Instance Method Summary collapse

Instance Method Details

#daemons_directoryObject



37
38
39
# File 'lib/daemons/rails/configuration.rb', line 37

def daemons_directory
  daemons_path.relative_path_from(root)
end

#daemons_pathObject



33
34
35
# File 'lib/daemons/rails/configuration.rb', line 33

def daemons_path
  @daemons_path || root.join('lib', 'daemons')
end

#daemons_path=(path) ⇒ Object



21
22
23
# File 'lib/daemons/rails/configuration.rb', line 21

def daemons_path=(path)
  @daemons_path = path && (path.is_a?(Pathname) ? path : Pathname.new(File.expand_path(path)))
end

#detect_rootObject



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/daemons/rails/configuration.rb', line 7

def detect_root
  if ENV["DAEMONS_ROOT"]
    Pathname.new(ENV["DAEMONS_ROOT"])
  elsif defined?(::Rails)
    ::Rails.root
  else
    root = Pathname.new(FileUtils.pwd)
    root = root.parent unless root.directory?
    root = root.parent until File.exist?(root.join('config.ru')) || root.root?
    raise "Can't detect Rails application root" if root.root?
    root
  end
end

#rootObject



29
30
31
# File 'lib/daemons/rails/configuration.rb', line 29

def root
  @root ||= detect_root
end

#root=(path) ⇒ Object



25
26
27
# File 'lib/daemons/rails/configuration.rb', line 25

def root=(path)
  @root = path && (path.is_a?(Pathname) ? path : Pathname.new(File.expand_path(path)))
end