雀巽の日記帳

雀巽が綴る日常の記録

CLIからGitHubコミットメッセージの英語の書き方の文例が検索できるサービスを叩きたかった

会社の情報共有チャットでこんなメッセージが流れてきました。

f:id:necojackarc:20151106195331p:plain

ほほう。

d.hatena.ne.jp

おお!これは便利かも!でももっと手軽に使いたい! CLI から叩くとか Chrome に組み込むとか……。

というわけで、とりあえず雑に CLI から叩けるようにしてみました。

#!/usr/bin/env ruby

require "net/http"
require "uri"
require "nokogiri"

params = { keyword: ARGV.join("\s") }

uri = URI.parse("http://commit-m.minamijoyo.com/commits/search")
uri.query = URI.encode_www_form(params)

response = Net::HTTP.get(uri)
html = Nokogiri::HTML.parse(response)

puts html.css("tbody > tr").map { |e| e.css("td").first.inner_text }

Nokogiri ギコギコ業は隣にスクレイピングマスターの id:Yasaichi くんが居たおかげで瞬殺でした。

それでは実行してみます。

$ ./search_commit_msg Remove redundant
Remove redundant, duplicate comment
Remove redundant comments
Remove redundant 'window.'
remove redundant docs section
Remove redundant `<code>` styling
Remove redundant _config.yml quotes
Remove redundant parens
Remove redundant jshint comment
Remove redundant parentheses.
Remove redundant Sizzle.uniqueSort call
Remove redundant code.
remove redundant color rule
remove redundant color rule
remove redundant var
remove redundant variable
Remove redundant method
remove redundant variable
Remove redundant instance_variables (@colorize_logging)
Remove redundant #to_sym
Remove redundant code.
Remove redundant code.
Remove redundant tests method.
Remove redundant 'the'.
Remove redundant NullSerializer
Remove redundant test.
remove redundant condition
Remove redundant conditional.
Remove redundant windows checks
Remove redundant variable
Remove redundant uniq

おお!なんだか思ったより使えそう!メッチャ機能削減されてるけど!

以上、お粗末さまでした。