Class: Slackdo::Card

Inherits:
Object
  • Object
show all
Defined in:
lib/slackdo.rb

Instance Method Summary collapse

Instance Method Details

#add_card(card_category, card_name, card_desc) ⇒ Object



93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/slackdo.rb', line 93

def add_card(card_category, card_name, card_desc)
  file = File.read("#{ENV['HOME']}/.slackdo/config.json")
     hash = JSON.parse(file)
  configure_trello
  card_name_full = ''
  card_name_full << "[#{card_category}]"
  card_name_full << " #{card_name}"
  label_id = ''
  hash['trello_label_list_ids'].each do |id|
  label = Trello::Label.find(id)
  label_id = id if label.name == card_category
  end
  card = Trello::Card.create(
       name: card_name_full,
       desc: card_desc,
    list_id: hash['trello_list_id'],
       pos: 'top',
    card_labels: label_id
     )
  card.save
  puts 'Card was created on Trello...'
end

#configure_trelloObject



85
86
87
88
89
90
91
92
# File 'lib/slackdo.rb', line 85

def configure_trello
  file = File.read("#{ENV['HOME']}/.slackdo/config.json")
     hash = JSON.parse(file)
  Trello.configure do |config|
       config.developer_public_key = hash['trello_public_key']
       config.member_token = hash['trello_member_token']
     end
end