Created
October 27, 2014 09:27
-
-
Save koichiro/d6cb0dede54de6f9c9c5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'nokogiri' | |
require 'trello' | |
Trello.configure do |config| | |
config.developer_public_key = "PUBLIC_KEY" | |
config.member_token = "TOKEN" | |
end | |
def issue_tracking doc | |
r = [] | |
doc.xpath('//ul[@class="XXXXXXXXXXXXXXX"]/li').each do |node| | |
n = { | |
title: node.css('h2').inner_text, | |
source: node.css('code').first.inner_text, | |
desc: node.css('div[@class="top"]').inner_text, | |
source_link: node.css("a[href*='https://github.com/[org]/[project]/']").first.attr(:href), | |
link: node.css("a[href*='/XXXXXXXXXXXX/']").first.attr(:href), | |
} | |
r << n | |
end | |
r | |
end | |
def post_trello issues, list | |
me = Trello::Member.find("koichiro") | |
board = me.boards.find {|b| b.name == "開発合宿@2014"} | |
list = board.lists.find {|l| l.name == list } | |
issues.each do |issue| | |
name = "#{issue[:title]}- #{issue[:source]}" | |
desc = <<-EOS | |
#{issue[:desc].gsub(/View on GitHub »/, '')} | |
source: #{issue[:source_link]} | |
codeclimate: #{issue[:link]} | |
EOS | |
p name | |
puts desc | |
Trello::Card.create(name: name, desc: desc, list_id: list.id) | |
end | |
end | |
Dir["./data/*.html"].each do |file| | |
puts file | |
html = open(file) do |f| | |
f.read | |
end | |
doc = Nokogiri::HTML.parse(html, nil, 'UTF-8') | |
issues = issue_tracking(doc) | |
post_trello issues, "To Do" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment