environmental 0.0.1 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (5) hide show
  1. data/CHANGELOG +3 -0
  2. data/README +1 -44
  3. data/Rakefile +16 -19
  4. metadata +12 -12
  5. data/lib/environmental.rb +0 -99
data/CHANGELOG CHANGED
@@ -1,2 +1,5 @@
1
+ 1.0.0 (December 3, 2009)
2
+ * Added deprecation message.
3
+
1
4
  0.0.1 (November 14, 2009)
2
5
  * Initial release.
data/README CHANGED
@@ -1,44 +1 @@
1
- = Rack::Environmental
2
-
3
- == Description
4
-
5
- Never again will you accidentally delete production data! Rack::Environmental adds
6
- an indicator badge to your web application so that you can tell whether you're
7
- working with the staging, test, development or production version of your web app.
8
-
9
- == Usage
10
-
11
- This Rack middleware can be used with any Rack application, but here's how you would
12
- use it in Rails. Put the following in config/environment.rb:
13
-
14
- config.middleware.use Rack::Environmental,
15
- :staging => { :url => /^staging.+$/ },
16
- :test => { :url => /^test.+$/ },
17
- :development => { :url => /^localhost.+$/ }
18
-
19
- When a request comes to your web app, Rack::Environmental compares the URL to the supplied
20
- regular expressions. If the URL matches, the name of the environment is displayed at the
21
- top of the web page.
22
-
23
- Each environment can be further configured:
24
-
25
- config.middleware.use Rack::Environmental,
26
- :staging => { :url => /^staging.+$/,
27
- :color => "yellow",
28
- :size => :large },
29
- :test => { :url => /^test.+$/,
30
- :color => "purple",
31
- :style => :badge },
32
- :development => { :url => /^localhost.+$/,
33
- :color => "orange" }
34
-
35
- Here's the full list of configuration options:
36
-
37
- :url => a regular expression
38
- :style => either :badge (a transparent, floating badge) or :banner (default)
39
- :color => a string that represents a CSS color, such as "red", "rgb(6,70,14)", or "#8e6630"
40
- :size => :small, :medium, or :large; defaults to :medium
41
- :opacity => a number from 0 (completely transparent) to 1; only works with the badge style
42
- :top => distance in pixels from the top; only works with the badge style
43
- :left => distance in pixels from the left; only works with the badge style
44
-
1
+ This gem is deprecated. It has been renamed rack-environmental.
data/Rakefile CHANGED
@@ -1,24 +1,21 @@
1
1
  require 'rake'
2
2
  require 'rake/gempackagetask'
3
3
  require 'rubygems'
4
-
5
- gem_spec = Gem::Specification.new do |s|
6
- s.name = "environmental"
7
- s.version = "0.0.1"
8
- s.author = "Wyatt Greene"
9
- s.email = "techiferous@gmail.com"
10
- s.summary = "Rack middleware that adds an indicator of your application environment"
11
- s.description = %Q{
12
- Rack::Environmental indicates which environment your web application is running
13
- in (staging, test, etc.).
14
- }
15
- s.require_path = "lib"
16
- s.files = ["lib/environmental.rb", "LICENSE", "Rakefile", "README",
17
- "CHANGELOG"]
18
- s.homepage = "http://github.com/techiferous/environmental"
19
- s.requirements << "none"
20
- s.has_rdoc = false
21
- end
22
4
 
23
- Rake::GemPackageTask.new(gem_spec) do |pkg|
5
+ begin
6
+ require 'jeweler'
7
+ Jeweler::Tasks.new do |s|
8
+ s.name = "environmental"
9
+ s.version = "1.0.0"
10
+ s.author = "Wyatt Greene"
11
+ s.email = "techiferous@gmail.com"
12
+ s.summary = "Deprecated. Use rack-environmental instead."
13
+ s.description = "Deprecated. Use rack-environmental instead."
14
+ s.files = ["LICENSE", "Rakefile", "README", "CHANGELOG"]
15
+ s.requirements << "none"
16
+ s.has_rdoc = false
17
+ end
18
+ Jeweler::GemcutterTasks.new
19
+ rescue LoadError
20
+ puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
24
21
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: environmental
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wyatt Greene
@@ -9,31 +9,31 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-11-14 00:00:00 -05:00
12
+ date: 2009-12-03 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
16
- description: "\n Rack::Environmental indicates which environment your web application is running\n in (staging, test, etc.).\n "
16
+ description: Deprecated. Use rack-environmental instead.
17
17
  email: techiferous@gmail.com
18
18
  executables: []
19
19
 
20
20
  extensions: []
21
21
 
22
- extra_rdoc_files: []
23
-
24
- files:
25
- - lib/environmental.rb
22
+ extra_rdoc_files:
26
23
  - LICENSE
27
- - Rakefile
28
24
  - README
25
+ files:
29
26
  - CHANGELOG
27
+ - LICENSE
28
+ - README
29
+ - Rakefile
30
30
  has_rdoc: true
31
- homepage: http://github.com/techiferous/environmental
31
+ homepage:
32
32
  licenses: []
33
33
 
34
34
  post_install_message:
35
- rdoc_options: []
36
-
35
+ rdoc_options:
36
+ - --charset=UTF-8
37
37
  require_paths:
38
38
  - lib
39
39
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -54,6 +54,6 @@ rubyforge_project:
54
54
  rubygems_version: 1.3.5
55
55
  signing_key:
56
56
  specification_version: 3
57
- summary: Rack middleware that adds an indicator of your application environment
57
+ summary: Deprecated. Use rack-environmental instead.
58
58
  test_files: []
59
59
 
@@ -1,99 +0,0 @@
1
- require 'nokogiri'
2
-
3
- module Rack
4
- class Environmental
5
-
6
- def initialize(app, options = {})
7
- @app = app
8
- @options = options
9
- end
10
-
11
- def call(env)
12
- @request = Rack::Request.new(env)
13
- status, @headers, @body = @app.call(env)
14
- if html?
15
- @body = add_to_top_of_web_page(create_sticker)
16
- update_content_length
17
- end
18
- [status, @headers, @body]
19
- end
20
-
21
- private
22
-
23
- def html?
24
- @headers["Content-Type"] && @headers["Content-Type"].include?("text/html")
25
- end
26
-
27
- def add_to_top_of_web_page(node)
28
- if node
29
- doc.at_css("body").children.first.add_previous_sibling(node)
30
- end
31
- doc.to_html
32
- end
33
-
34
- def create_sticker
35
- environment_name = environment(@request.url)
36
- return nil if environment_name.nil?
37
- div = Nokogiri::XML::Node.new("div", doc)
38
- div['style'] = style(@options[environment_name])
39
- div.content = environment_name.to_s
40
- div
41
- end
42
-
43
- def environment(url)
44
- url = url.split('//').last # remove http://
45
- @options.each do |environment_name, options|
46
- if options[:url] && options[:url] =~ url
47
- return environment_name
48
- end
49
- end
50
- return nil
51
- end
52
-
53
- def doc
54
- @doc ||= Nokogiri::HTML(body_to_string)
55
- end
56
-
57
- def body_to_string
58
- s = ""
59
- @body.each { |x| s << x }
60
- s
61
- end
62
-
63
- def style(options)
64
- style = ""
65
- style << "font-family: Verdana, Arial, sans-serif;"
66
- style << "font-weight: bold;"
67
- style << "text-transform: uppercase;"
68
- style << "text-align: center;"
69
- style << "color: black;"
70
- style << "padding: 3px;"
71
- style << "background-color: #{options[:color] || "blue"};"
72
- case options[:size]
73
- when :large
74
- style << "font-size: 20px;"
75
- when :medium
76
- style << "font-size: 14px;"
77
- when :small
78
- style << "font-size: 10px;"
79
- else
80
- style << "font-size: 14px;"
81
- end
82
- if options[:style] == :badge
83
- style << "margin: 5px;"
84
- style << "position: fixed;"
85
- style << "top: #{options[:top] || 5}px;"
86
- style << "left: #{options[:left] || 5}px;"
87
- style << "opacity: #{options[:opacity] || 0.7};"
88
- style << "-moz-border-radius: 5px; -khtml-border-radius: 5px; -webkit-border-radius: 5px; border-radius: 5px;"
89
- else
90
- style << "margin: 0px;"
91
- end
92
- end
93
-
94
- def update_content_length
95
- @headers['Content-Length'] = Rack::Utils.bytesize(@body).to_s
96
- end
97
-
98
- end
99
- end