require 'octokit' #Get infomation by user def user_languages(userName) repositories = Octokit.repositories(userName) langarray = repositories.collect {|repo| repo.fetch("language")} return langarray end def repo_watchers(repoName) watchers = Octokit.watchers(repoName) return watchers.collect {|repo| repo.fetch("login")} end def collect_user_languages(repoName) lang = [] repo_watchers(repoName).each {|watcher| lang.concat(user_languages(watcher)) } return lang end def static_watchers_language(repoName) result_hash = collect_user_languages(repoName).inject(Hash.new(0)){ |hash, a| hash[a] += 1; hash } #まずデータの合計をする lsum = 0 result_hash.each_value {|value | lsum += value} sortedArray = result_hash.to_a.sort{|a, b| (b[1] <=> a[1]) } sortedArray.each {|entry| lang = entry[0] != nil ? entry[0] : "Unknown" parcent = (entry[1].to_f / lsum.to_f) * 100.0; parcent = (parcent * 100).round / 100.0 puts lang+" : "+parcent.to_s+"%\n" } end
GithubのAPIをwrapしているライブラリを利用して、あるリポジトリをwatchしている
人のreppositoryの仕様言語をあつめてきて、傾向をみるスクリプトです。
vital.vimでためしてみると...
VimL : 32.6% Ruby : 21.28% Unknown : 10.3% JavaScript : 7.09% Perl : 6.76% Clojure : 3.89% C : 3.55% Haskell : 2.03% Python : 2.03% Java : 1.86% Shell : 1.69% PHP : 1.35% Emacs Lisp : 1.18% C++ : 1.01% Objective-C : 0.84% Common Lisp : 0.68% C# : 0.68% Scala : 0.34% Scheme : 0.34% Erlang : 0.17% Go : 0.17% Objective-J : 0.17%
と、まぁやはりトップはVimLですね :-)