Class: Initd::Script
- Inherits:
-
Object
- Object
- Initd::Script
- Defined in:
- lib/initd/script.rb
Instance Attribute Summary collapse
-
#daemon ⇒ Object
readonly
Returns the value of attribute daemon.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #content ⇒ Object
-
#initialize(path, script, args, user) ⇒ Script
constructor
A new instance of Script.
- #name ⇒ Object
- #pidfile ⇒ Object
- #templates_dir ⇒ Object
Constructor Details
#initialize(path, script, args, user) ⇒ Script
Returns a new instance of Script.
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/initd/script.rb', line 9 def initialize(path, script, args, user) @path = path @daemon = { :name => name, :script => script, :args => args, :user => user, } @description = name end |
Instance Attribute Details
#daemon ⇒ Object (readonly)
Returns the value of attribute daemon.
3 4 5 |
# File 'lib/initd/script.rb', line 3 def daemon @daemon end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
3 4 5 |
# File 'lib/initd/script.rb', line 3 def description @description end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
3 4 5 |
# File 'lib/initd/script.rb', line 3 def path @path end |
Instance Method Details
#content ⇒ Object
28 29 30 31 |
# File 'lib/initd/script.rb', line 28 def content template = templates_dir.join('script.erb') ERB.new(template.read, nil, '<>').result(binding) end |
#name ⇒ Object
20 21 22 |
# File 'lib/initd/script.rb', line 20 def name @path.basename.to_s end |
#pidfile ⇒ Object
24 25 26 |
# File 'lib/initd/script.rb', line 24 def pidfile Pathname.new('/var/run').join(@daemon[:name]).join("#{@daemon[:name]}.pid") end |
#templates_dir ⇒ Object
5 6 7 |
# File 'lib/initd/script.rb', line 5 def templates_dir Pathname.new(__FILE__).dirname.dirname.dirname.join('templates') end |