Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Create an initializer to add the Whereuat::RackApp to your middleware stack and
Whereuat.configure do |config|
config.pivotal_tracker_token = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
config.pivotal_tracker_project = 123456
config.pivotal_tracker_use_ssl = false
end

Use the following helper somewhere in your application layout (we recommend at the end of the body):
Expand Down
4 changes: 4 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,16 @@ if rake_app.top_level_tasks.include?('dev')
puts "What pivotal tracker project do you want to test against? (e.g. The digits at the end of http://www.pivotaltracker.com/projects/12345)."
project_id = $stdin.gets.chomp

puts "Does your pivotal tracker project use ssl?"
use_ssl = $stdin.gets.chomp.downcase.start_with?('y')

puts "Creating config using your details."

pivotal_config.open('w') {|f|
f << %{Whereuat.configure do |config|
config.pivotal_tracker_token = "#{token}"
config.pivotal_tracker_project = #{project_id}
config.pivotal_tracker_use_ssl = #{use_ssl}
end
}.gsub(/^\s{3,16}/,'')
}
Expand Down
16 changes: 16 additions & 0 deletions lib/whereuat/action_controller_ext.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
if Whereuat.configuration.enable_widget

already_inherited = defined?(ApplicationController)

[ActionController::Base, already_inherited ? ApplicationController : nil].compact.each do |base|
base.class_eval do
after_filter :render_whereuat

private
def render_whereuat
Whereuat::Widget.render(response)
end
end
end

end
2 changes: 2 additions & 0 deletions lib/whereuat/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@ module Whereuat
class Configuration
attr_accessor :pivotal_tracker_token
attr_accessor :pivotal_tracker_project
attr_accessor :pivotal_tracker_use_ssl
attr_accessor :enable_widget
end
end
1 change: 1 addition & 0 deletions lib/whereuat/rack_app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class RackApp
def initialize(app)
@app = app
PT::Client.token = config.pivotal_tracker_token
PT::Client.use_ssl = config.pivotal_tracker_use_ssl
end

def call(env)
Expand Down
12 changes: 12 additions & 0 deletions lib/whereuat/widget.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module Whereuat
class Widget
extend Whereuat::Helpers

def self.render(response)
body = response.body
if response.content_type == "text/html" && position = body.index('</body>')
body.insert(position, whereuat)
end
end
end
end