will (owner)

Revisions

gist: 130946 Download_button fork
public
Public Clone URL: git://gist.github.com/130946.git
metric_fu.rake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
require 'metric_fu'
 
task "metrics:all" do
  require 'yaml'
  require 'couchrest'
  require 'grit'
  
  report = File.open( File.join( RAILS_ROOT, "tmp", "metric_fu", "report.yml") ) { |f| YAML::load f }
  repo = Grit::Repo.new(Dir.pwd)
  commit = repo.commits.first
  
  record = {
    "_id" => commit.id,
    :message => commit.message,
    :date => commit.date,
    :committer => { :name => commit.committer.name, :email => commit.committer.email },
    :report => report
    }
    
  db = CouchRest.database!("http://localhost:5984/metric_fu")
  
  begin
    db.save_doc record
  rescue RestClient::RequestFailed
    record["_rev"] = db.get(record["_id"])["_rev"]
    db.save_doc record
  end
end