Module: Trellohub::Synchronal

Included in:
Trellohub
Defined in:
lib/trellohub/synchronal.rb

Instance Method Summary collapse

Instance Method Details

#synchronizeObject Also known as: sync



3
4
5
6
7
8
# File 'lib/trellohub/synchronal.rb', line 3

def synchronize
  synchronize_to_cards_from_issues
  synchronize_to_issues_from_cards
  Trellohub::Mocking.print_request_summary if Trellohub.dry_run
  true
end

#synchronize_to_cards_from_issuesObject



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/trellohub/synchronal.rb', line 11

def synchronize_to_cards_from_issues
  Form.with_issues.each do |issue_form|
    card_form = Form.with_cards.find_by_key(issue_form.key)

    case
    when card_form.nil?
      issue_form.save_as_card
    when Form.compare(issue_form, card_form)
      card_form.save_as_issue
    end
  end
end

#synchronize_to_issues_from_cardsObject



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/trellohub/synchronal.rb', line 24

def synchronize_to_issues_from_cards
  Form.with_cards.each do |card_form|
    issue_form = Form.with_issues.find_by_key(card_form.key)

    case
    when issue_form.nil?
      card_form.save_as_issue
    when Form.compare(card_form, issue_form)
      issue_form.save_as_card
    end
  end
end