Class: Greenhouse::Resources::Procfile
- Inherits:
-
Object
- Object
- Greenhouse::Resources::Procfile
show all
- Includes:
- FileResource
- Defined in:
- lib/greenhouse/resources/procfile.rb
Defined Under Namespace
Classes: Process, Processes
Instance Method Summary
collapse
included
Constructor Details
#initialize(path) ⇒ Procfile
Returns a new instance of Procfile.
139
140
141
|
# File 'lib/greenhouse/resources/procfile.rb', line 139
def initialize(path)
super
end
|
Instance Method Details
#disabled(refresh = false) ⇒ Object
84
85
86
87
|
# File 'lib/greenhouse/resources/procfile.rb', line 84
def disabled(refresh=false)
return @processes.select { |key,process| process.disabled? } unless refresh || @processes.nil? || @processes.empty?
reload.select { |key,process| process.disabled? }
end
|
#enabled(refresh = false) ⇒ Object
89
90
91
92
|
# File 'lib/greenhouse/resources/procfile.rb', line 89
def enabled(refresh=false)
return @processes.select { |key,process| process.enabled? } unless refresh || @processes.nil? || @processes.empty?
reload.select { |key,process| process.enabled? }
end
|
#process(key) ⇒ Object
103
104
105
|
# File 'lib/greenhouse/resources/procfile.rb', line 103
def process(key)
processes.values.select { |p| p.key.to_s == key.to_s }.first
end
|
#process_exists?(key) ⇒ Boolean
99
100
101
|
# File 'lib/greenhouse/resources/procfile.rb', line 99
def process_exists?(key)
processes.keys.include?(key.to_s)
end
|
#processes(refresh = false) ⇒ Object
94
95
96
97
|
# File 'lib/greenhouse/resources/procfile.rb', line 94
def processes(refresh=false)
return @processes unless refresh || @processes.nil? || @processes.empty?
reload
end
|
#reload ⇒ Object
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
# File 'lib/greenhouse/resources/procfile.rb', line 118
def reload
@processes = Processes.new(self)
return @processes unless exists?
read do |line,l|
if line.match(/\A[#]*[a-z0-9_]+:\s*.*\Z/)
parr = line.strip.split(":")
key = parr.slice!(0)
command = parr.join(":").strip
process = Process.new(key, command, l)
@processes[process.key] = process
end
end
@processes
end
|
#unlink ⇒ Object
134
135
136
137
|
# File 'lib/greenhouse/resources/procfile.rb', line 134
def unlink
super
reload
end
|
#write ⇒ Object
Also known as:
save
107
108
109
110
111
112
113
114
115
|
# File 'lib/greenhouse/resources/procfile.rb', line 107
def write
processes.values.each { |process| lines[process.line] = process.to_s}
open('w') do |pfile|
lines.each do |line|
pfile.write "#{line}\n"
end
end
reload
end
|