Class: Daemons::Rails::Controller
- Inherits:
-
Object
- Object
- Daemons::Rails::Controller
- Defined in:
- lib/daemons/rails/controller.rb
Instance Attribute Summary collapse
-
#app_name ⇒ Object
readonly
Returns the value of attribute app_name.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
-
#initialize(controller_path) ⇒ Controller
constructor
A new instance of Controller.
- #run(command) ⇒ Object
- #start ⇒ Object
- #status ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(controller_path) ⇒ Controller
Returns a new instance of Controller.
6 7 8 9 |
# File 'lib/daemons/rails/controller.rb', line 6 def initialize(controller_path) @path = controller_path @app_name = "#{controller_path.basename.to_s[0...-'_ctl'.length]}.rb" end |
Instance Attribute Details
#app_name ⇒ Object (readonly)
Returns the value of attribute app_name.
4 5 6 |
# File 'lib/daemons/rails/controller.rb', line 4 def app_name @app_name end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
4 5 6 |
# File 'lib/daemons/rails/controller.rb', line 4 def path @path end |
Instance Method Details
#run(command) ⇒ Object
11 12 13 |
# File 'lib/daemons/rails/controller.rb', line 11 def run(command) `cd #{Daemons::Rails.configuration.root} && #{path} #{command}` end |
#start ⇒ Object
15 16 17 |
# File 'lib/daemons/rails/controller.rb', line 15 def start run('start') end |
#status ⇒ Object
23 24 25 |
# File 'lib/daemons/rails/controller.rb', line 23 def status run('status').to_s.split("\n").last =~ /: running \[pid \d+\]$/ ? :running : :not_exists end |
#stop ⇒ Object
19 20 21 |
# File 'lib/daemons/rails/controller.rb', line 19 def stop run('stop') end |