ruby trello-counts.rb
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ruby trello-counts.rb相关的知识,希望对你有一定的参考价值。
# trello-counts.rb
require 'trello'
require 'benchmark'
key = TRELLO_KEY
token = TRELLO_TOKEN
Trello.configure do |config|
config.developer_public_key = key
config.member_token = token
end
# get list id by pasting (card id url).json into browser and
# getting the idList property value
lists = []
lists << {name: "api_backlog", id: "54be96080153a9ef65dbdbe0"}
lists << {name: "engr_backlog", id: "57d17e98571171342778dfaf"}
lists << {name: "ops_backlog", id: "56b2302eba562bbc3b5035ae"}
puts "-- Fetching data from trello..."
t = Benchmark.realtime do
lists.each do |hash|
list = Trello::List.find(hash[:id])
count = list.cards.select{|c| c.labels.map(&:color).include? "blue"}.count
hash[:blue_count] = count
end
end
puts " -> #{t.round(2)} sec"
puts
headers = ["Date"]
headers += lists.map{|h| h[:name] }
cols = [Time.now.strftime("%m/%d/%Y")]
cols += lists.map{|h| h[:blue_count] }
data = cols.join("\t")
puts "Engineering Backlog:"
puts
puts headers.join("\t")
puts data
puts
IO.popen('pbcopy', 'w') { |f| f << data }
puts "'#{data}' copied to clipbaord"
以上是关于ruby trello-counts.rb的主要内容,如果未能解决你的问题,请参考以下文章
ruby [Ruby Cheat] Cheatsheet #ruby
Ruby运算符
Ruby 25 岁了!Ruby 之父说 Ruby 3 有望 3 倍提速
如何学习ruby?Ruby学习技巧分享
ruby Ruby脚本,看看是否用openssl编译了ruby
什么是ruby?