Skip to content

Instantly share code, notes, and snippets.

@hennevogel

hennevogel/omg.rb

Last active Nov 25, 2015
Embed
What would you like to do?
def get_build_flags
build_flags = Hash.new
build_flags['all'] = Array.new
flag = main_object.flags.with_repositories(nil).with_architectures(nil).first
if flag
build_flags['all'] << flag
else
build_flags['all'] << main_object.flags.new( flag: 'build', status: Flag.default_state('build') )
end
main_object.architectures.each do |architecture|
flag = main_object.flags.with_repositories(nil).with_architectures(architecture.id).first
if flag
build_flags['all'] << flag
else
build_flags['all'] << main_object.flags.new( flag: 'build', architecture: architecture, status: build_flags['all'][0].status )
end
end
main_object.repositories.each do |repository|
build_flags[repository.name] = Array.new
flag = main_object.flags.with_repositories(repository.name).with_architectures(nil).first
if flag
build_flags[repository.name] << flag
else
build_flags[repository.name] << main_object.flags.new( flag: 'build', repo: repository.name, status: build_flags['all'][0].status )
end
main_object.architectures.each do |architecture|
flag = main_object.flags.with_repositories(repository.name).with_architectures(architecture.id).first
if flag
build_flags[repository.name] << flag
else
build_flags[repository.name] << main_object.flags.new( flag: 'build',
repo: repository.name,
architecture: architecture,
status: build_flags[repository.name][0].status )
end
end
end
return build_flags
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment