Testing: add missing file
[GitX.git] / Site / lib / release_notes.rb
blob8ff598bba510af4826c32dbbdfd6966ae6b963b1
1 #!/usr/bin/ruby
3 RELEASE_NOTES_PATH = File.join(File.dirname(__FILE__), "..", "..", "Documentation", "ReleaseNotes")
5 module ReleaseNotes
7     VERSION_MATCH = /v([0-9.]*).txt$/
9     # Find all release not files
10     def self.release_files
11         notes = Dir.glob(File.join(RELEASE_NOTES_PATH, "v*.txt"))
12     
13         # Sort files by version number
14         notes.sort do |x,y|
15             x = x.match VERSION_MATCH
16             y = y.match VERSION_MATCH
17             # Puts nonmatching files at the bottom
18             if !x && y
19                 1
20             elsif !y && x
21                 -1
22             else
23                 # compare version strings, newest at the top
24                 y[1].split(".").map { |a| a.to_i } <=> x[1].split(".").map { |a| a.to_i }
25             end
26         end
27     end
29     # Aggregate all release notes in a string
30     def self.aggregate_notes
31         file = ""
32         release_files.each do |x|
33             file << File.read(x)
34             file << "\n"
35         end
36         file
37     end
39     def self.last_version
40         last_file = release_files.first
41         if last_file =~ VERSION_MATCH
42             return $1
43         end
44         nil
45     end
47     def self.last_notes
48         File.read(release_files.first)
49     end
50 end