Sha256: 8d3e19aec4f62eb73cc18f68ee0689f200108272c53364054373e2099707c993
Contents?: true
Size: 1.64 KB
Versions: 1
Compression:
Stored size: 1.64 KB
Contents
class Sibling < ActiveRecord::Base has_many :deploys has_many :instructions, through: :deploys validates :uid, presence: true, uniqueness: true validates :name, presence: true validates :git_repo, presence: true validates :heroku_repo, presence: true validates :heroku_app_name, presence: true class << self def main_app_uid ENV["MAIN_APP_UID"] end def main_app_hcard Microformats2.parse(main_app_uid).card end def consume_main_app_hcard main_app_hcard.g5_siblings.map do |sibling| find_or_create_from_hcard(sibling.format) end.compact if main_app_hcard rescue OpenURI::HTTPError => e raise e unless /304 Not Modified/ =~ e.message end def async_consume Resque.enqueue(SiblingConsumer) end def find_or_create_from_hcard(hcard) find_or_create_by(uid: hcard.uid.to_s) do |sibling| sibling.name = hcard.name.to_s sibling.git_repo = hcard.g5_git_repo.to_s sibling.heroku_repo = hcard.g5_heroku_repo.to_s sibling.heroku_app_name = hcard.g5_heroku_app_name.to_s end end def deploy_all(manual=true, instruction_id=nil) all.each { |sibling| sibling.deploy(instruction_id) } end def deploy_some(kinds=[], instruction_id=nil) apps = kinds.flat_map { |k| Sibling.where('name LIKE ?', "%-#{k}-%") } apps.each { |sibling| sibling.deploy(instruction_id) } end end def deploy(instruction_id=nil) self.deploys.create!( instruction_id: instruction_id, manual: !instruction_id, git_repo: git_repo, heroku_repo: heroku_repo, heroku_app_name: heroku_app_name ) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
g5_sibling_deployer_engine-0.7.0 | app/models/sibling.rb |