Class: Barkeeper
- Inherits:
-
Object
- Object
- Barkeeper
- Defined in:
- lib/barkeep.rb
Instance Attribute Summary collapse
-
#renderer ⇒ Object
Returns the value of attribute renderer.
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
- #rpm_enabled? ⇒ Boolean
- #rpm_request_info ⇒ Object
- #rpm_sample_id ⇒ Object
- #rpm_url ⇒ Object
- #styles ⇒ Object
Instance Attribute Details
#renderer ⇒ Object
Returns the value of attribute renderer.
15 16 17 |
# File 'lib/barkeep.rb', line 15 def renderer @renderer end |
Instance Method Details
#branch_info ⇒ Object
64 65 66 |
# File 'lib/barkeep.rb', line 64 def branch_info %(<dt>Branch:</dt><dd><a href="#{branch_link_attributes[:href]}">#{grit_info[:branch]}</a></dd>) end |
#branch_link_attributes ⇒ Object
95 96 97 98 99 100 |
# File 'lib/barkeep.rb', line 95 def branch_link_attributes { :href => "#{github_url}/tree/#{grit_info[:branch]}", :title => grit_info[:message] } end |
#commit_author_info ⇒ Object
72 73 74 |
# File 'lib/barkeep.rb', line 72 def %(<dt>Who:</dt><dd>#{grit_info[:last_author]}</dd>) end |
#commit_date_info ⇒ Object
76 77 78 79 |
# File 'lib/barkeep.rb', line 76 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
102 103 104 105 106 107 |
# File 'lib/barkeep.rb', line 102 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
68 69 70 |
# File 'lib/barkeep.rb', line 68 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
17 18 19 |
# File 'lib/barkeep.rb', line 17 def config @config ||= JSON.parse(File.read("config/barkeep.json")) end |
#github_url ⇒ Object
87 88 89 |
# File 'lib/barkeep.rb', line 87 def github_url config['github_url'] end |
#grit_info ⇒ Object
91 92 93 |
# File 'lib/barkeep.rb', line 91 def grit_info GitWrapper.instance end |
#load? ⇒ Boolean
21 22 23 24 25 26 27 28 |
# File 'lib/barkeep.rb', line 21 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
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/barkeep.rb', line 35 def return unless load? && grit_info.repository? %( <dl id="barkeep"> #{ config['panes'].map do |name| if name =~ /^(p|partial) (.*)/ if renderer.respond_to?(:render_to_string) renderer.send(:render_to_string, {:partial => $2}) else renderer.send(:render, {:partial => $2}) end 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 |
#rpm_enabled? ⇒ Boolean
109 110 111 112 113 114 115 116 117 |
# File 'lib/barkeep.rb', line 109 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
81 82 83 84 85 |
# File 'lib/barkeep.rb', line 81 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
119 120 121 |
# File 'lib/barkeep.rb', line 119 def rpm_sample_id NewRelic::Agent.instance.transaction_sampler.current_sample_id end |
#rpm_url ⇒ Object
123 124 125 |
# File 'lib/barkeep.rb', line 123 def rpm_url "/newrelic/show_sample_detail/#{rpm_sample_id}" end |
#styles ⇒ Object
30 31 32 33 |
# File 'lib/barkeep.rb', line 30 def styles return unless load? %(<style>#{File.read(File.expand_path(File.dirname(__FILE__) + "/default.css"))}</style>).html_safe end |