Permalink
Browse files

Added rake task for publishing coderwall badges

  • Loading branch information...
1 parent e8ea8c7 commit 1c6226ff93935df49a9909f193bb7b2653b74226 @andrew andrew committed Dec 29, 2012
Showing with 19 additions and 0 deletions.
  1. +19 −0 lib/tasks/coderwall.rake
View
@@ -0,0 +1,19 @@
+namespace :coderwall do
+ desc 'Register coderwall awards'
+ task :awards => :environment do
+ conn = Faraday.new(:url => 'https://coderwall.com')
+ api_key = ENV['CODERWALL_API_KEY']
+ if api_key.present?
+ User.all.each do |user|
+ if user.pull_requests.any?
+ payload = {github:user.nickname, badge:"TwentyFourPullRequestsParticipant", date:"12/25/2012", api_key:api_key}
+ resp = conn.post '/award', payload.to_json, 'Content-Type' => 'application/json', :accept => 'application/json'
+ end
+ if user.pull_requests.length > 23
+ payload = {github:user.nickname, badge:"TwentyFourPullRequestsContinuous", date:"12/25/2012", api_key:api_key}
+ resp = conn.post '/award', payload.to_json, 'Content-Type' => 'application/json', :accept => 'application/json'
+ end
+ end
+ end
+ end
+end

0 comments on commit 1c6226f

Please sign in to comment.