Class: Daemons::Rails::Configuration
- Inherits:
-
Object
- Object
- Daemons::Rails::Configuration
- Defined in:
- lib/daemons/rails/configuration.rb
Instance Method Summary collapse
- #daemons_directory ⇒ Object
- #daemons_path ⇒ Object
- #daemons_path=(path) ⇒ Object
- #detect_root ⇒ Object
- #root ⇒ Object
- #root=(path) ⇒ Object
Instance Method Details
#daemons_directory ⇒ Object
37 38 39 |
# File 'lib/daemons/rails/configuration.rb', line 37 def daemons_directory daemons_path.relative_path_from(root) end |
#daemons_path ⇒ Object
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.(path))) end |
#detect_root ⇒ Object
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 |
#root ⇒ Object
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.(path))) end |