Class: Konstant::Project
- Inherits:
-
Object
- Object
- Konstant::Project
- Defined in:
- lib/konstant/project.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Class Method Summary collapse
Instance Method Summary collapse
- #as_json ⇒ Object
- #build! ⇒ Object
- #build_timestamps ⇒ Object
- #building? ⇒ Boolean
- #builds ⇒ Object
-
#initialize(id) ⇒ Project
constructor
A new instance of Project.
- #last_build ⇒ Object
- #ok?(task = 'build') ⇒ Boolean
- #path ⇒ Object
- #status(task = 'build') ⇒ Object
- #stderr(task = 'build') ⇒ Object
- #stdout(task = 'build') ⇒ Object
- #to_json(*args) ⇒ Object
Constructor Details
#initialize(id) ⇒ Project
Returns a new instance of Project.
3 4 5 |
# File 'lib/konstant/project.rb', line 3 def initialize(id) @id = id end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
7 8 9 |
# File 'lib/konstant/project.rb', line 7 def id @id end |
Class Method Details
.all ⇒ Object
9 10 11 12 13 |
# File 'lib/konstant/project.rb', line 9 def self.all Dir["#{Konstant.config['data_dir']}/projects/*"].map do |path| new path.split('/').last end end |
Instance Method Details
#as_json ⇒ Object
61 62 63 64 65 66 67 68 69 |
# File 'lib/konstant/project.rb', line 61 def as_json(*) return { "id" => id, "ok" => ok?, "deploy_ok" => ok?('deploy'), "cleanup_ok" => ok?('cleanup'), "building" => building? } end |
#build! ⇒ Object
15 16 17 |
# File 'lib/konstant/project.rb', line 15 def build! system "touch #{path}/run.txt" end |
#build_timestamps ⇒ Object
27 28 29 30 31 |
# File 'lib/konstant/project.rb', line 27 def Dir["#{path}/builds/*"].map do |path| path.split('/').last end.sort.reverse end |
#building? ⇒ Boolean
19 20 21 |
# File 'lib/konstant/project.rb', line 19 def building? File.exists? "#{path}/running.txt" end |
#builds ⇒ Object
33 34 35 36 37 |
# File 'lib/konstant/project.rb', line 33 def builds .map do |ts| Konstant::Build.new self, ts end end |
#last_build ⇒ Object
39 40 41 42 43 |
# File 'lib/konstant/project.rb', line 39 def last_build if ts = .first Konstant::Build.new self, ts end end |
#ok?(task = 'build') ⇒ Boolean
45 46 47 |
# File 'lib/konstant/project.rb', line 45 def ok?(task = 'build') last_build && last_build.ok?(task) end |
#path ⇒ Object
23 24 25 |
# File 'lib/konstant/project.rb', line 23 def path "#{Konstant.config['data_dir']}/projects/#{id}" end |
#status(task = 'build') ⇒ Object
49 50 51 |
# File 'lib/konstant/project.rb', line 49 def status(task = 'build') last_build ? last_build.status(task) : nil end |
#stderr(task = 'build') ⇒ Object
57 58 59 |
# File 'lib/konstant/project.rb', line 57 def stderr(task = 'build') last_build ? last_build.stderr(task) : nil end |
#stdout(task = 'build') ⇒ Object
53 54 55 |
# File 'lib/konstant/project.rb', line 53 def stdout(task = 'build') last_build ? last_build.stdout(task) : nil end |
#to_json(*args) ⇒ Object
71 72 73 |
# File 'lib/konstant/project.rb', line 71 def to_json(*args) as_json.to_json(*args) end |