Class: Ditz::BaetleView

Inherits:
View show all
Defined in:
lib/ditz/views.rb

Instance Method Summary collapse

Methods inherited from View

add_to_view, view_additions_for

Constructor Details

#initialize(project, config, dir) ⇒ BaetleView

Returns a new instance of BaetleView.



141
142
143
144
145
# File 'lib/ditz/views.rb', line 141

def initialize project, config, dir
  @project = project
  @config = config
  @dir = dir
end

Instance Method Details

#render_allObject



147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
# File 'lib/ditz/views.rb', line 147

def render_all
  Dir.mkdir @dir unless File.exists? @dir
  fn = File.join @dir, "baetle.rdf"
  File.open(fn, "w") { |f| 
      f.puts <<EOS
@prefix baetle: <http://xmlns.com/baetle/#> .
@prefix wf: <http://www.w3.org/2005/01/wf/flow#> .
@prefix sioc: <http://rdfs.org/sioc/ns#> .
@prefix dc: <http://purl.org/dc/elements/1.1/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#>.
@prefix : <#> .

EOS
      @project.issues.each do |issue|
        # id
        f.print ":#{issue.id} a "
        f.print case issue.type 
              when :bugfix, :bug; "baetle:Bug"
              when :feature; "baetle:Enhancement"
              when :task; "wf:Task"
              end
        f.puts " ;"
        # title
        f.puts "    baetle:title #{issue.title.dump} ;"
        # summary
        f.puts "    baetle:description #{issue.desc.dump} ; "
        # state
        f.print "    wf:state baetle:" 
        f.print case issue.status
                when :unstarted; "New"
                when :in_progress; "Started"
                when :closed; "Closed"
                when :paused; "Later"
                end
        f.puts " ;"
        # created
        f.puts "    baetle:created #{issue.creation_time.xmlschema.dump}^^xsd:dateTime ."
        f.puts
      end
    }
  puts "Local generated URL: file://#{File.expand_path(fn)}"
end