diff --git a/README.md b/README.md index aa96289..9a2c906 100644 --- a/README.md +++ b/README.md @@ -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): diff --git a/Rakefile b/Rakefile index 620c76d..c3db11a 100644 --- a/Rakefile +++ b/Rakefile @@ -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}/,'') } diff --git a/lib/whereuat/action_controller_ext.rb b/lib/whereuat/action_controller_ext.rb new file mode 100644 index 0000000..59bf2f8 --- /dev/null +++ b/lib/whereuat/action_controller_ext.rb @@ -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 \ No newline at end of file diff --git a/lib/whereuat/configuration.rb b/lib/whereuat/configuration.rb index 2ef724c..ca4042b 100644 --- a/lib/whereuat/configuration.rb +++ b/lib/whereuat/configuration.rb @@ -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 diff --git a/lib/whereuat/rack_app.rb b/lib/whereuat/rack_app.rb index e6df2ad..c1a44c8 100644 --- a/lib/whereuat/rack_app.rb +++ b/lib/whereuat/rack_app.rb @@ -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) diff --git a/lib/whereuat/widget.rb b/lib/whereuat/widget.rb new file mode 100644 index 0000000..ba5e1ad --- /dev/null +++ b/lib/whereuat/widget.rb @@ -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.insert(position, whereuat) + end + end + end +end \ No newline at end of file