Class: Barkeeper
- Inherits:
-
Object
- Object
- Barkeeper
- Defined in:
- lib/barkeep.rb
Instance Method Summary collapse
- #branch_info ⇒ Object
- #branch_link_attributes ⇒ Object
- #commit_author_info ⇒ Object
- #commit_date_info ⇒ Object
- #commit_link_attributes ⇒ Object
- #commit_sha_info ⇒ Object
- #config ⇒ Object
- #github_url ⇒ Object
- #grit_info ⇒ Object
- #load? ⇒ Boolean
- #render_toolbar ⇒ Object
- #renderer ⇒ Object
- #rpm_enabled? ⇒ Boolean
- #rpm_request_info ⇒ Object
- #rpm_sample_id ⇒ Object
- #rpm_url ⇒ Object
- #styles ⇒ Object
Instance Method Details
#branch_info ⇒ Object
57 58 59 |
# File 'lib/barkeep.rb', line 57 def branch_info %(<dt>Branch:</dt><dd><a href="#{branch_link_attributes[:href]}">#{grit_info[:branch]}</a></dd>) end |
#branch_link_attributes ⇒ Object
88 89 90 91 92 93 |
# File 'lib/barkeep.rb', line 88 def branch_link_attributes { :href => "#{github_url}/tree/#{grit_info[:branch]}", :title => grit_info[:message] } end |
#commit_author_info ⇒ Object
65 66 67 |
# File 'lib/barkeep.rb', line 65 def %(<dt>Who:</dt><dd>#{grit_info[:last_author]}</dd>) end |
#commit_date_info ⇒ Object
69 70 71 72 |
# File 'lib/barkeep.rb', line 69 def commit_date_info short_date = (grit_info[:date].respond_to?(:strftime) ? grit_info[:date].strftime("%d %B, %H:%M") : short_date.to_s) %(<dt>When:</dt><dd title="#{grit_info[:date].to_s}">#{short_date}</dd>) end |
#commit_link_attributes ⇒ Object
95 96 97 98 99 100 |
# File 'lib/barkeep.rb', line 95 def commit_link_attributes { :href => "#{github_url}/commit/#{grit_info[:commit]}", :title => "committed #{grit_info[:date]} by #{grit_info[:last_author]}" } end |
#commit_sha_info ⇒ Object
61 62 63 |
# File 'lib/barkeep.rb', line 61 def commit_sha_info %(<dt>Commit:</dt><dd><a href="#{commit_link_attributes[:href]}" title="#{commit_link_attributes[:title]}">#{(grit_info[:commit] || "").slice(0,8)}</a></dd>) end |
#config ⇒ Object
14 15 16 |
# File 'lib/barkeep.rb', line 14 def config @config ||= JSON.parse(File.read("config/barkeep.json")) end |
#github_url ⇒ Object
80 81 82 |
# File 'lib/barkeep.rb', line 80 def github_url config['github_url'] end |
#grit_info ⇒ Object
84 85 86 |
# File 'lib/barkeep.rb', line 84 def grit_info GritWrapper.instance end |
#load? ⇒ Boolean
18 19 20 21 22 23 24 25 |
# File 'lib/barkeep.rb', line 18 def load? if defined?(Rails) this_env = Rails.env elsif defined?(Sinatra) this_env = Sinatra::Application.settings.environment end config['environments'].include?(this_env.to_s) end |
#render_toolbar ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/barkeep.rb', line 32 def return unless load? && grit_info.repository? %( <dl id="barkeep"> #{ config['panes'].map do |name| if name =~ /^(p|partial) (.*)/ renderer.send(:render_to_string, {:partial => $2}) else send(name) end end.join('') } <dd class="close"> <a href="#" onclick="c = document.getElementById('barkeep'); c.parentNode.removeChild(c); return false" title="Close me!">×</a> </dd> </dl> ).html_safe end |
#renderer ⇒ Object
53 54 55 |
# File 'lib/barkeep.rb', line 53 def renderer @@renderer ||= ApplicationController.new end |
#rpm_enabled? ⇒ Boolean
102 103 104 105 106 107 108 109 110 |
# File 'lib/barkeep.rb', line 102 def rpm_enabled? if defined?(NewRelic) if defined?(NewRelic::Control) !NewRelic::Control.instance['skip_developer_route'] else !NewRelic::Config.instance['skip_developer_route'] end end end |
#rpm_request_info ⇒ Object
74 75 76 77 78 |
# File 'lib/barkeep.rb', line 74 def rpm_request_info if rpm_enabled? %(<dt><a href="/newrelic">RPM:</a></dt><dd><a href="#{rpm_url}">request</a></dd>) end end |
#rpm_sample_id ⇒ Object
112 113 114 |
# File 'lib/barkeep.rb', line 112 def rpm_sample_id NewRelic::Agent.instance.transaction_sampler.current_sample_id end |
#rpm_url ⇒ Object
116 117 118 |
# File 'lib/barkeep.rb', line 116 def rpm_url "/newrelic/show_sample_detail/#{rpm_sample_id}" end |
#styles ⇒ Object
27 28 29 30 |
# File 'lib/barkeep.rb', line 27 def styles return unless load? %(<style>#{File.read(File.(File.dirname(__FILE__) + "/default.css"))}</style>).html_safe end |