Class: TrebuchetRails::FeaturesController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/trebuchet_rails/features_controller.rb

Instance Method Summary collapse

Instance Method Details

#indexObject



14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/controllers/trebuchet_rails/features_controller.rb', line 14

def index
  @features = Trebuchet::Feature.all
  @features.sort! {|x,y| x.name.downcase <=> y.name.downcase }
  
  @dismantled_features = Trebuchet::Feature.dismantled
  @dismantled_features.sort! {|x,y| x.name.downcase <=> y.name.downcase }
  
  respond_to do |wants|
    wants.html # index.html.erb
    wants.json { render :json => @features.map(&:export) }
  end
end

#timelineObject



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'app/controllers/trebuchet_rails/features_controller.rb', line 27

def timeline
  @history = []
  Trebuchet::Feature.all.each do |f|
    f.history.each do |timestamp, strategy|
      @history << { 
        :feature_name => f.name, 
        :timestamp => timestamp, 
        :strategy => strategy
      }
    end
  end
  @history = @history.sort_by { |h| h[:timestamp] }
  @history.reverse!
  respond_to do |wants|
    wants.html # index.html.erb
    wants.json do
       json_history = @history.map do |history|
        history.tap { |h| h[:strategy] = h[:strategy].export }
      end
      render :json => json_history
    end
  end
end