michaelbarton / cost_in_evolution

cost_in_evolution / model / stage.rb
45709e40 » michaelbarton 2008-05-29 Renamed Milestone to Stage.... 1 class Stage < DataMapper::Base
0afe0163 » michaelbarton 2008-05-17 Set up milestones in website 2 include Comparable
3
35c31ffc » michaelbarton 2008-05-09 Created Milestone model, an... 4 property :number, :integer
5 property :title, :text
6 property :description, :text
7
8 belongs_to :project
0afe0163 » michaelbarton 2008-05-17 Set up milestones in website 9
10 def <=> other
11 self.number <=> other.number
12 end
13
14 def html_description
15 BlueCloth.new(self.description).to_html
16 end
17
18 def html_summary
19 self.html_description.split(/\n/).first.strip
20 end
21
22 def self.create_from_markdown_erb(number,file)
23 self.all(:number => number).each {|r| r.destroy!}
24 File.open(file) do |f|
25 return self.create({
26 :number => number,
27 :title => f.readline.gsub(/#+\s/,'').strip,
28 :description => ERB.new(f.read.strip).result
29 })
30 end
31 end
32
35c31ffc » michaelbarton 2008-05-09 Created Milestone model, an... 33 end