bard-staging_banner 0.1.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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3cea06ef3032012d955c2564856635c3cf1b9bcb
4
+ data.tar.gz: 58c35d7019a04c6dce4831453f17e84454c4c5a7
5
+ SHA512:
6
+ metadata.gz: cf858ac4b951ef3dee086ee0c45499dc0124fb3d7a93dfb2656b49f95c3ba190f91ef231b755521e7bd6a2273f4694e423802b0f78eeb096cffd353b3da0c169
7
+ data.tar.gz: 2b0f4195bf65b92868a7c76e38684e8e98f0309fb71f89700b57a52f33a29a5f71f1367d8aae55ce29441eae62c75e38b9a3757a531283a2e5c7a04c23984408
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in bard_staging_banner.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Micah Geisel
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # Bard::StagingBanner
2
+
3
+ Middleware to inject an annoying banner on every page in the staging environment.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'bard-staging_banner'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install bard-staging_banner
18
+
19
+ ## Usage
20
+
21
+ Comes with a Railtie, so zero-conf, if you have a Rails environment named "staging."
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,19 @@
1
+ lib = File.expand_path('../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'bard/staging_banner/version'
4
+
5
+ Gem::Specification.new do |gem|
6
+ gem.name = "bard-staging_banner"
7
+ gem.version = Bard::StagingBanner::VERSION
8
+ gem.authors = ["Micah Geisel"]
9
+ gem.email = ["micah@botandrose.com"]
10
+ gem.description = %q{Middleware to inject an annoying banner on every page in the staging environment}
11
+ gem.summary = %q{Middleware to inject an annoying banner on every page in the staging environment}
12
+ gem.homepage = "https://github.com/botandrose/bard-staging_banner"
13
+
14
+ gem.files = `git ls-files`.split($/)
15
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
16
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
17
+ gem.require_paths = ["lib"]
18
+ end
19
+
@@ -0,0 +1,34 @@
1
+ module Bard
2
+ module StagingBanner
3
+ class Middleware
4
+ def initialize app
5
+ @app = app
6
+ end
7
+
8
+ def call env
9
+ @status, @headers, @body = @app.call(env)
10
+ return [@status, @headers, @body] unless html?
11
+
12
+ response = Rack::Response.new([], @status, @headers)
13
+ @body.each do |fragment|
14
+ response.write inject(fragment)
15
+ end
16
+ @body.close if @body.respond_to?(:close)
17
+
18
+ response.finish
19
+ end
20
+
21
+ private
22
+
23
+ def html?
24
+ @headers["Content-Type"] =~ /html/
25
+ end
26
+
27
+ def inject response
28
+ markup = %(<div id="staging-banner" style="background: yellow; color: black; position: fixed; bottom: 0; left: 0; width: 100%; font: bold 16pt Arial; line-height: 1.5em; text-align: center; z-index: 999;">You are on the Staging Site</div>)
29
+ response.gsub(%r{</body>}, "#{markup}</body>")
30
+ end
31
+ end
32
+ end
33
+ end
34
+
@@ -0,0 +1,5 @@
1
+ module Bard
2
+ module StagingBanner
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,10 @@
1
+ require "bard/staging_banner/version"
2
+ require "bard/staging_banner/middleware"
3
+
4
+ module Bard
5
+ module StagingBanner
6
+ class Engine < ::Rails::Engine
7
+ config.app_middleware.use Middleware if Rails.env.staging?
8
+ end
9
+ end
10
+ end
@@ -0,0 +1 @@
1
+ require "bard/staging_banner"
metadata ADDED
@@ -0,0 +1,54 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bard-staging_banner
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Micah Geisel
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-12-12 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Middleware to inject an annoying banner on every page in the staging
14
+ environment
15
+ email:
16
+ - micah@botandrose.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - .gitignore
22
+ - Gemfile
23
+ - LICENSE.txt
24
+ - README.md
25
+ - Rakefile
26
+ - bard-staging_banner.gemspec
27
+ - lib/bard-staging_banner.rb
28
+ - lib/bard/staging_banner.rb
29
+ - lib/bard/staging_banner/middleware.rb
30
+ - lib/bard/staging_banner/version.rb
31
+ homepage: https://github.com/botandrose/bard-staging_banner
32
+ licenses: []
33
+ metadata: {}
34
+ post_install_message:
35
+ rdoc_options: []
36
+ require_paths:
37
+ - lib
38
+ required_ruby_version: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - '>='
41
+ - !ruby/object:Gem::Version
42
+ version: '0'
43
+ required_rubygems_version: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ requirements: []
49
+ rubyforge_project:
50
+ rubygems_version: 2.1.10
51
+ signing_key:
52
+ specification_version: 4
53
+ summary: Middleware to inject an annoying banner on every page in the staging environment
54
+ test_files: []