Class: Erector::Widgets::EnvironmentBadge

Inherits:
Erector::Widget show all
Defined in:
lib/erector/widgets/environment_badge.rb

Overview

Displays a colored badge in the upper-left corner signifying the environment the app is running in. Inspired by Assaf Arkin

<http://blog.labnotes.org/2009/10/08/using-a-badge-to-distinguish-development-and-production-environments/>

Erectorized by Alex Chaffee

Instance Method Summary collapse

Methods included from Sass

#sass

Methods included from AfterInitialize

included, #initialize

Methods included from JQuery

#jquery, #jquery_load, #jquery_ready

Methods included from Convenience

#css, #dom_id, #join, #to_pretty, #to_text, #url

Methods included from Externals

included, #render_externals, #render_with_externals

Methods included from Needs

included, #initialize

Methods included from HTML

#character, #close_tag, #comment, #element, #element!, #empty_element, #h, included, #instruct, #javascript, #nbsp, #open_tag, #raw, #text, #text!

Methods inherited from AbstractWidget

#call_block, #capture, #initialize, inline, prettyprint_default, #prettyprint_default, prettyprint_default=, #to_a, #to_html, #to_s, #widget

Instance Method Details

#contentObject



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/erector/widgets/environment_badge.rb', line 10

def content
  style <<-STYLE
#environment_badge { position: fixed; left: 1em; font-weight: bold; padding: .2em 0.9em; text-transform: uppercase; display: none }
#environment_badge.staging { color: #000; background: #ffff00; border: 2px solid #cccc20; }
#environment_badge.development { color: #fff; background: #ff0000; border: 2px solid #cc2020; }
#environment_badge.staging, #environment_badge.development { border-top: none; display: block; opacity: 0.6 }    
  STYLE
  unless environment =~ /production/
    p environment, :class => environment, :id => "environment_badge"
  end
end

#environmentObject



22
23
24
25
26
# File 'lib/erector/widgets/environment_badge.rb', line 22

def environment
  RAILS_ENV
rescue NameError
  ENV['RAILS_ENV'] || ENV['RACK_ENV']
end