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 +11 -13
- data/VERSION +1 -1
- data/lib/generators/visual_environments/templates/initializer.rb +3 -6
- data/lib/visual-environments.rb +10 -7
- data/visual-environments.gemspec +1 -1
- metadata +2 -2
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
|
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
|
-
|
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
|
-
#
|
24
|
-
|
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
|
-
|
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
|
-
|
50
|
+
== Corner Banner & Changing the Side of the Banner
|
54
51
|
|
55
|
-
The corner banner is
|
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
|
-
|
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
|
+
0.2.0
|
@@ -1,11 +1,8 @@
|
|
1
1
|
ActionController::Base::VisualEnvironments.enable_env_in_title = true
|
2
2
|
|
3
|
-
#
|
4
|
-
|
5
|
-
|
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
|
data/lib/visual-environments.rb
CHANGED
@@ -12,14 +12,17 @@ class ActionController::Base
|
|
12
12
|
response.body = response.body.gsub /\<\/body\>/, shim
|
13
13
|
end
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
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
|
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
|
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
|
data/visual-environments.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{visual-environments}
|
8
|
-
s.version = "0.
|
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.
|
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:
|
97
|
+
hash: -2044812391905676061
|
98
98
|
segments:
|
99
99
|
- 0
|
100
100
|
version: "0"
|