Class: Testbot::Server::Build
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from MemoryModel
all, attribute, #attributes, count, create, delete_all, find, first, #id, #type, #update
Constructor Details
#initialize(hash) ⇒ Build
Returns a new instance of Build.
5
6
7
|
# File 'lib/server/build.rb', line 5
def initialize(hash)
super({ :success => true, :done => false, :results => '' }.merge(hash))
end
|
Class Method Details
.create_and_build_jobs(hash) ⇒ Object
9
10
11
12
13
14
|
# File 'lib/server/build.rb', line 9
def self.create_and_build_jobs(hash)
hash["jruby"] = (hash["jruby"] == "true") ? 1 : 0
build = create(hash.reject { |k, v| k == 'available_runner_usage' })
build.create_jobs!(hash['available_runner_usage'])
build
end
|
Instance Method Details
#create_jobs!(available_runner_usage) ⇒ Object
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/server/build.rb', line 16
def create_jobs!(available_runner_usage)
groups = Group.build(self.files.split, self.sizes.split.map { |size| size.to_i },
Runner.total_instances.to_f * (available_runner_usage.to_i / 100.0), self.type)
groups.each do |group|
Job.create(:files => group.join(' '),
:root => self.root,
:project => self.project,
:type => self.type,
:build => self,
:jruby => self.jruby)
end
end
|
#destroy ⇒ Object
29
30
31
32
|
# File 'lib/server/build.rb', line 29
def destroy
Job.all.find_all { |j| j.build == self }.each { |job| job.destroy }
super
end
|