Skip to content

Instantly share code, notes, and snippets.

@jedi4ever
Created November 30, 2012 18:20
Show Gist options
  • Save jedi4ever/4177532 to your computer and use it in GitHub Desktop.
Save jedi4ever/4177532 to your computer and use it in GitHub Desktop.
Trello for devopsdays setup
require 'trello'
include Trello
include Trello::Authorization
public_key= "your public_key"
secret = "your secret"
# https://trello.com/1/authorize?key=your_public_key&name=yourappname&response_type=token&scope=read,write,account&expiration=never
key='your key'
board_id = "your board id"
todo_name = "To Do"
@dday = '2013-11-30'
Trello::Authorization.const_set :AuthPolicy, OAuthPolicy
OAuthPolicy.consumer_credential = OAuthCredential.new public_key,secret
OAuthPolicy.token = OAuthCredential.new key, nil
def ago(days=0)
d = @dday.split('-')
t = Time.local(d[0],d[1],d[2])+(3600*24)*days
return t
end
require 'time'
tasks = [
{ :name => "Select Coordinator" , :description => "we really need to find a venue"},
{ :name => "Local Invoicing" , :description => "we really need to find a venue", :due => ago(-30), :checklist => [ 'find one', 'do more']},
{ :name => "Catering" , :description => "we really need to find a venue"},
{ :name => "Venue" , :description => "we really need to find a venue"},
{ :name => "Site visit" , :description => "we really need to find a venue"},
{ :name => "Speaker presents" , :description => "we really need to find a venue"},
{ :name => "Event Date Selection" , :description => "we really need to find a venue"},
{ :name => "Registration" , :description => "we really need to find a venue"},
{ :name => "Sponsor Packages" , :description => "we really need to find a venue"},
{ :name => "Hotel Packages" , :description => "we really need to find a venue"},
{ :name => "Design logo" , :description => "we really need to find a venue"},
{ :name => "T-shirts" ,:description => "we really need to find a venue"},
{ :name => "Call for proposals" ,:description => "we really need to find a venue"},
{ :name => "Notify attendees of final program" ,:description => "we really need to find a venue"},
{ :name => "Notify speakers" ,:description => "we really need to find a venue"},
{ :name => "Notify ignites" ,:description => "we really need to find a venue"},
{ :name => "Invoices" ,:description => "we really need to find a venue"},
{ :name => "Schedule weekly sync call" ,:description => "we really need to find a venue"},
{ :name => "Sponsoring" ,:description => "we really need to find a venue"},
{ :name => "Social Event" ,:description => "we really need to find a venue"},
{ :name => "Publish program" ,:description => "we really need to find a venue"},
{ :name => "Retrospective" ,:description => "we really need to find a venue"},
{ :name => "Pre-event meetup" ,:description => "we really need to find a venue"},
{ :name => "Publish videos" ,:description => "we really need to find a venue"},
{ :name => "Collect presentations" ,:description => "we really need to find a venue"},
{ :name => "Streaming" ,:description => "we really need to find a venue"},
{ :name => "Publish videos" ,:description => "we really need to find a venue"},
]
card_details = {
"closed" => false,
"idBoard" => board_id,
}
my_cards = []
tasks.each do |t|
puts t
my_cards << t.merge(card_details)
end
# Find my board
remote_board = Trello::Board.find(board_id)
# Find the todo list
remote_list_todo = nil
remote_board.lists.each do |b|
if b.name == todo_name
remote_list_todo = b.id
end
end
if remote_list_todo.nil?
exit
end
# Load all cards from remote_board
remote_cards = Hash.new
remote_board.cards.each do |c|
remote_cards[c.name] = c
end
my_cards.each do |c|
name = c[:name]
remote_card = remote_cards[name]
if remote_card.nil?
puts "Creating the task #{name}"
card = Trello::Card.create(c.merge( { :list_id => remote_list_todo } ))
card.due = c[:due]
card.update!
puts "Adding checklist"
checklist = Trello::Checklist.create({:name => "bla"+c[:name], :description => 'bla', :board_id => board_id })
unless c[:checklist].nil?
c[:checklist].each do |i|
checklist.add_item(i)
end
checklist.update!
require 'pp'
pp checklist
card.add_checklist(checklist)
end
else
puts "Card #{name} already created"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment