visual-environments 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -4,9 +4,9 @@ Automatic visual, in-browser cues about your current environment in Rails 3 appl
4
4
 
5
5
  If you're a developer accustomed to working across multiple development and staging environments, you have certainly been in the position where you have multiple browser windows/tabs open with the same site but pointing at different environments. This gem aims to help you keep your contexts straight!
6
6
 
7
- This is a configurable means for showing, via an updated <title> tag or CSS corner banner, what the current runtime environment is (development, staging, test, etc.) This functionality is never enabled for production, and fully configurable to exclude other environments as well.
7
+ This is a configurable means for showing, via an updated <title> tag or CSS corner banner overlay, what the current runtime environment is (development, staging, test, etc.) This functionality is never enabled for production, and fully configurable to exclude other environments as well.
8
8
 
9
- == Install & Configuration
9
+ = Install & Configuration
10
10
 
11
11
  Add the following to your Rails app Gemfile
12
12
 
@@ -20,11 +20,8 @@ There should now be a new file <tt>config/initializers/visual-environments.rb</t
20
20
 
21
21
  ActionController::Base::VisualEnvironments.enable_env_in_title = true
22
22
 
23
- # By default, the corner banner is disabled
24
- ActionController::Base::VisualEnvironments.enable_env_in_corner_banner = false
25
- # By default, if the corner banner is enabled it is shown on the right side of the page. For
26
- # those pages where it would be better for it to reside in the upper-left corner, uncomment
27
- # the line below and change the argument to :left. Current possible values are (:right, :left)
23
+ # Uncomment he line below and select which side to display the banner on. Current possible
24
+ # values are (:right, :left) corresponding to upper-right and upper-left corners, respectively
28
25
  # ActionController::Base::VisualEnvironments.corner_banner_side = :right
29
26
 
30
27
  # By default, the full environment name is used in the visual cues (development, test, etc.) You
@@ -38,7 +35,7 @@ There should now be a new file <tt>config/initializers/visual-environments.rb</t
38
35
 
39
36
  By default, visual environments are enabled in the page title but disabled for corner banner display. Also, by default only production environments are excluded from the gem functionality.
40
37
 
41
- === Excluding Environments
38
+ == Excluding Environments
42
39
 
43
40
  You can add additional environments to be excluded by adding their names to the <tt>excluded_environments</tt> collection. For example, let's say you have an app with a test-oriented staging environment as well as a 'almost-ready-for-prime-time' preproduction environment. In this case you may want the visual cues on the staging but not on preproduction. In that case you can edit the initializer to:
44
41
 
@@ -50,13 +47,15 @@ Another way to configure is by using Gemfile groups to only conditionally load t
50
47
 
51
48
  gem 'visual-evironments', :groups => [:development, :staging]
52
49
 
53
- === Changing the Side of the Banner
50
+ == Corner Banner & Changing the Side of the Banner
54
51
 
55
- The corner banner is displayed in the upper-right corner of the screen by default. Some sites, however, may be designed such that a banner in that area would hamper functionality (by covering links, for example). In that case you can switch the banner to the left side by uncommenting and setting the following line in <tt>config/initializers/visual-environments.rb</tt>:
52
+ The corner banner is not included by default. To enable it, choose which side it should be displayed on via the <tt>corner_banner_side</tt> option in <tt>config/initializers/visual-environments.rb</tt>:
56
53
 
57
54
  ActionController::Base::VisualEnvironments.corner_banner_side = :right
55
+
56
+ Valid options are currently <tt>:left</tt> and <tt>:right</tt>, corresponding to the upper-left and upper-right corners, respectively.
58
57
 
59
- === Aliasing Environment Names
58
+ == Aliasing Environment Names
60
59
 
61
60
  Having the string "[development]" prepended to your title may make things a bit unwieldy for some people. In that case, you may use the aliasing option to change such an identifier to something shorter (but still identifiable with the environment in question). For example, you can alias 'development' to 'dev' or 'D', which would result in "[dev]" or "[D]" being prepended to the page title.
62
61
 
@@ -78,8 +77,7 @@ The above example would show use 'dev' in a development environment and 'preprod
78
77
 
79
78
  == Copyright
80
79
 
81
- Copyright (c) 2011 Zachery Moneypenny, David van Leeuwen. See LICENSE.txt for
82
- further details.
80
+ Copyright (c) 2011 Zachery Moneypenny, David van Leeuwen. See LICENSE.txt for further details.
83
81
 
84
82
  Big Ups to the Mad-Railers for their idea for this gem! If you're coding Ruby/Rails in the Madison, Wisconsin area search for MadRailers on meetup.com or check out the Google Group at http://groups.google.com/group/Mad-Railers
85
83
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.2
1
+ 0.2.0
@@ -1,11 +1,8 @@
1
1
  ActionController::Base::VisualEnvironments.enable_env_in_title = true
2
2
 
3
- # By default, the corner banner is disabled
4
- ActionController::Base::VisualEnvironments.enable_env_in_corner_banner = false
5
- # By default, if the corner banner is enabled it is shown on the right side of the page. For
6
- # those pages where it would be better for it to reside in the upper-left corner, uncomment
7
- # the line below and change the argument to :left. Current possible values are (:right, :left)
8
- # ActionController::Base::VisualEnvironments.corner_banner_side = :right
3
+ # Uncomment he line below and select which side to display the banner on. Current possible
4
+ # values are (:right, :left) corresponding to upper-right and upper-left corners, respectively
5
+ ActionController::Base::VisualEnvironments.corner_banner_side = :right
9
6
 
10
7
  # By default, the full environment name is used in the visual cues (development, test, etc.) You
11
8
  # can map environment names by using the below setting to alias one environment name to another
@@ -12,14 +12,17 @@ class ActionController::Base
12
12
  response.body = response.body.gsub /\<\/body\>/, shim
13
13
  end
14
14
 
15
- if VisualEnvironments.enable_env_in_corner_banner
16
- shim = ""
17
- # By default the banner will be on the right side
18
- if VisualEnvironments.corner_banner_side.nil? || VisualEnvironments.corner_banner_side == :right
19
- shim = "<script type='text/javascript'>var con=document.createElement('div');con.id='VisualEnvironment_container';document.body.appendChild(con);var ce=document.createElement('div');ce.id='VisualEnvironment_corner';ce.innerHTML='"+current_env+"';con.appendChild(ce);</script><style>#VisualEnvironment_corner{position:absolute;top:20px;right:-35px;font-family:Verdana;font-size:10px;color:#fff;padding:9px;width:120px;text-align:center;background:#000;border:#fff 1px solid;filter:alpha(opacity=70);-moz-opacity:0.7;-khtml-opacity:0.7;opacity:0.7;-webkit-transform:rotate(45deg);-moz-transform:rotate(45deg);}#VisualEnvironment_container{position:absolute;top:0;right:0;width:120px;height:93px;overflow:hidden;}</style></body>"
15
+ unless VisualEnvironments.corner_banner_side.nil?
16
+ # Exit if we detect invalid options in the corner_banner_side option
17
+ return unless [:left,:right].include?(VisualEnvironments.corner_banner_side)
18
+ shim = "<script type='text/javascript'>var con=document.createElement('div');con.id='VisualEnvironment_container';document.body.appendChild(con);var ce=document.createElement('div');ce.id='VisualEnvironment_corner';ce.innerHTML='"+current_env+"';con.appendChild(ce);</script>"
19
+
20
+ if VisualEnvironments.corner_banner_side == :right
21
+ shim += "<style>#VisualEnvironment_corner{position:absolute;top:20px;right:-35px;font-family:Verdana;font-size:10px;color:#fff;padding:9px;width:120px;text-align:center;background:#000;border:#fff 1px solid;filter:alpha(opacity=70);-moz-opacity:0.7;-khtml-opacity:0.7;opacity:0.7;-webkit-transform:rotate(45deg);-moz-transform:rotate(45deg);}#VisualEnvironment_container{position:absolute;top:0;right:0;width:120px;height:93px;overflow:hidden;}</style>"
20
22
  elsif VisualEnvironments.corner_banner_side == :left
21
- shim = "<script type='text/javascript'>var con=document.createElement('div');con.id='VisualEnvironment_container';document.body.appendChild(con);var ce=document.createElement('div');ce.id='VisualEnvironment_corner';ce.innerHTML='"+current_env+"';con.appendChild(ce);</script><style>#VisualEnvironment_corner{position:absolute;top:20px;left:-35px;font-family:Verdana;font-size:10px;color:#fff;padding:9px;width:120px;text-align:center;background:#000;border:#fff 1px solid;filter:alpha(opacity=70);-moz-opacity:0.7;-khtml-opacity:0.7;opacity:0.7;-webkit-transform:rotate(-45deg);-moz-transform:rotate(-45deg);}#VisualEnvironment_container{position:absolute;top:0;left:0;width:120px;height:93px;overflow:hidden;}</style></body>"
23
+ shim += "<style>#VisualEnvironment_corner{position:absolute;top:20px;left:-35px;font-family:Verdana;font-size:10px;color:#fff;padding:9px;width:120px;text-align:center;background:#000;border:#fff 1px solid;filter:alpha(opacity=70);-moz-opacity:0.7;-khtml-opacity:0.7;opacity:0.7;-webkit-transform:rotate(-45deg);-moz-transform:rotate(-45deg);}#VisualEnvironment_container{position:absolute;top:0;left:0;width:120px;height:93px;overflow:hidden;}</style>"
22
24
  end
25
+ shim += "</body>"
23
26
  response.body = response.body.gsub /\<\/body\>/, shim
24
27
  end
25
28
 
@@ -29,7 +32,7 @@ class ActionController::Base
29
32
 
30
33
  module VisualEnvironments
31
34
  class << self
32
- attr_accessor :enable_env_in_title, :enable_env_in_corner_banner
35
+ attr_accessor :enable_env_in_title
33
36
  attr_accessor :corner_banner_side
34
37
  attr_accessor :aliases
35
38
  attr_accessor :excluded_environments
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{visual-environments}
8
- s.version = "0.1.2"
8
+ s.version = "0.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Zachery Moneypenny, David van Leeuwen"]
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: visual-environments
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.2
5
+ version: 0.2.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Zachery Moneypenny, David van Leeuwen
@@ -94,7 +94,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
94
94
  requirements:
95
95
  - - ">="
96
96
  - !ruby/object:Gem::Version
97
- hash: 2993803228632703134
97
+ hash: -2044812391905676061
98
98
  segments:
99
99
  - 0
100
100
  version: "0"