Class: UatDirector::RackApp

Inherits:
Object
  • Object
show all
Defined in:
lib/uat_director/rack_app.rb

Constant Summary collapse

PT =
PivotalTracker

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ RackApp

Returns a new instance of RackApp.



9
10
11
12
# File 'lib/uat_director/rack_app.rb', line 9

def initialize(app)
  @app             = app
  PT::Client.token = config.pivotal_tracker_token 
end

Instance Method Details

#accept(pivotal_story_id) ⇒ Object



30
31
32
33
34
# File 'lib/uat_director/rack_app.rb', line 30

def accept(pivotal_story_id)
  story = project.stories.find(pivotal_story_id.to_i)  
  story.update(:current_state => 'accepted')
  render "Accepted" 
end

#call(env) ⇒ Object



14
15
16
17
18
19
20
21
22
23
# File 'lib/uat_director/rack_app.rb', line 14

def call(env)
  case env["PATH_INFO"]
  when /^\/uat_director$/
    index
  when /^\/uat_director\/(.*)\/accept/
    accept $1
  else
    @app.call(env)
  end
end

#configObject



53
54
55
# File 'lib/uat_director/rack_app.rb', line 53

def config
  UatDirector.configuration
end

#haml(file_name, options = {}) ⇒ Object



40
41
42
43
# File 'lib/uat_director/rack_app.rb', line 40

def haml(file_name, options={})
  template = (template_root + "#{file_name}.haml").read
  render Haml::Engine.new(template).render(self)
end

#indexObject



25
26
27
28
# File 'lib/uat_director/rack_app.rb', line 25

def index
  @stories = project.stories.all(:current_state => "delivered")
  haml "index"
end

#projectObject



36
37
38
# File 'lib/uat_director/rack_app.rb', line 36

def project
  @project ||= PT::Project.find(config.pivotal_tracker_project)
end

#render(html) ⇒ Object



45
46
47
# File 'lib/uat_director/rack_app.rb', line 45

def render(html)
  [200, {"Content-Type" => "text/html"}, [html]]
end

#template_rootObject



49
50
51
# File 'lib/uat_director/rack_app.rb', line 49

def template_root
  Pathname.new(__FILE__).parent + "templates"
end