public
Description: Gitorious aims to provide a great way of doing distributed opensource code collaboration.
Homepage: http://gitorious.org/projects/gitorious
Clone URL: git://github.com/dysinger/gitorious.git
David A. Cuadrado (author)
Sun Apr 13 14:06:07 -0700 2008
gitorious / lib / gitorious / graphs / builder.rb
100644 52 lines (44 sloc) 1.334 kb
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
require "gruff"
 
silence_warnings do
  Gruff::Base::TITLE_MARGIN = 2.0
end
 
module Gitorious
  module Graphs
    class Builder
      def self.generate_all_for(repository)
        generators = [CommitsBuilder, CommitsByAuthorBuilder]
        generators.each do |generator|
          generator.generate_for(repository)
        end
      end
      
      def self.graph_dir
        File.join(RAILS_ROOT, "public/images/graphs/")
      end
      
      def self.construct_filename(repository, branch, name)
        "#{repository.project.slug}_#{repository.name}_#{branch}_#{name}.png"
      end
      
      def self.status_file(repository, branch = "master")
        File.join(RAILS_ROOT, "tmp", "graph_generator",
             "#{repository.project.slug}_#{repository.name}_#{repository.git.commit_count(branch)}_#{self.name}.status")
      end
 
      def self.default_theme
        {
          :colors => [
              '#acd64f',
              '#bcde71',
              '#cce692',
              '#dceeb4',
              '#ecf6d6',
            ],
          :marker_color => '#aea9a9', # Grey
          :font_color => 'black',
          :background_colors => 'white'
        }
      end
      
      def write
        dest = File.join(self.class.graph_dir, construct_filename)
        @graph.write(dest)
      end
    end
  end
end