Class: Slackdo::Card

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.configure_trelloObject



130
131
132
133
134
135
136
137
# File 'lib/slackdo.rb', line 130

def self.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

Instance Method Details

#add_card(card_category, card_name, card_desc) ⇒ Object



138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# File 'lib/slackdo.rb', line 138

def add_card(card_category, card_name, card_desc)
  file = File.read("#{ENV['HOME']}/.slackdo/config.json")
     hash = JSON.parse(file)
  Card.configure_trello
  card_name_full = ''
  card_name_full << "[#{card_category}]"
  card_name_full << " #{card_name}"
  label_id = ''
  hash['trello_label_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