Class: Sibling
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Sibling
show all
- Defined in:
- app/models/sibling.rb
Defined Under Namespace
Classes: Deploy, Instruction
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.async_consume ⇒ Object
27
28
29
|
# File 'app/models/sibling.rb', line 27
def async_consume
Resque.enqueue(SiblingConsumer)
end
|
.consume_main_app_hcard ⇒ Object
20
21
22
23
24
25
|
# File 'app/models/sibling.rb', line 20
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, "304 Not Modified"
end
|
.deploy_all(manual = true, instruction_id = nil) ⇒ Object
40
41
42
|
# File 'app/models/sibling.rb', line 40
def deploy_all(manual=true, instruction_id=nil)
all.each { |sibling| sibling.deploy(instruction_id) }
end
|
.find_or_create_from_hcard(hcard) ⇒ Object
31
32
33
34
35
36
37
38
|
# File 'app/models/sibling.rb', line 31
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
|
.main_app_hcard ⇒ Object
16
17
18
|
# File 'app/models/sibling.rb', line 16
def main_app_hcard
Microformats2.parse(main_app_uid).card
end
|
.main_app_uid ⇒ Object
12
13
14
|
# File 'app/models/sibling.rb', line 12
def main_app_uid
ENV["MAIN_APP_UID"]
end
|
Instance Method Details
#deploy(instruction_id = nil) ⇒ Object
45
46
47
48
49
50
51
52
53
|
# File 'app/models/sibling.rb', line 45
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
|