Class: Paradeiser::ParadeiserController

Inherits:
Controller
  • Object
show all
Defined in:
lib/paradeiser/controllers/paradeiser_controller.rb

Instance Attribute Summary

Attributes inherited from Controller

#exitstatus, #has_output

Instance Method Summary collapse

Methods inherited from Controller

#call, #get_binding, #initialize, #model, #render

Constructor Details

This class inherits a constructor from Paradeiser::Controller

Instance Method Details

#exportObject



37
38
39
40
# File 'lib/paradeiser/controllers/paradeiser_controller.rb', line 37

def export
  self.has_output = true
  render(:text => Repository.all.to_json)
end

#initObject



8
9
10
11
# File 'lib/paradeiser/controllers/paradeiser_controller.rb', line 8

def init
  FileUtils.mkdir_p(Paradeiser.par_dir)
  FileUtils.cp_r(File.join(Paradeiser.templates_dir, Paradeiser.os.to_s, 'hooks'), Paradeiser.par_dir)
end

#reportObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/paradeiser/controllers/paradeiser_controller.rb', line 13

def report
  pomodori = Repository.all_pomodori

  @finished = pomodori.select{|p| p.finished?}.size
  @canceled = pomodori.select{|p| p.canceled?}.size
  @external_interrupts = pomodori.map{|p| p.interrupts}.flatten.select{|i| :external == i.type}.size
  @internal_interrupts = pomodori.map{|p| p.interrupts}.flatten.select{|i| :internal == i.type}.size

  breaks = Repository.all_breaks
  @breaks = breaks.size
  @break_minutes = breaks.sum{|b| b.duration}.to_i.minutes

  @annotations = pomodori.collect{|p| p.annotations}.flatten

  self.has_output = true
end

#statusObject



30
31
32
33
34
35
# File 'lib/paradeiser/controllers/paradeiser_controller.rb', line 30

def status
  @pom = Repository.active || Repository.all.last
  self.exitstatus = Status.of(@pom).to_i
  self.has_output = true
  render(:text => 'There are no pomodori or breaks.') unless @pom
end