rehearsal 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +16 -0
- data/.rvmrc +1 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +32 -0
- data/Rakefile +2 -0
- data/lib/rehearsal/engine.rb +13 -0
- data/lib/rehearsal/version.rb +3 -0
- data/lib/rehearsal/view_helpers.rb +14 -0
- data/lib/rehearsal.rb +35 -0
- data/rehearsal.gemspec +17 -0
- data/vendor/assets/stylesheets/rehearsal.css.scss +10 -0
- metadata +58 -0
data/.gitignore
ADDED
data/.rvmrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rvm use --create 1.9.3@neoteric-protection
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Joe Sak
|
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,32 @@
|
|
1
|
+
# Protection
|
2
|
+
|
3
|
+
This gem gives drop-in staging environment HTTP basic auth for rails apps, maybe any Ruby web app.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
**Must be using Neoteric's GemFury source, as this is private**
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
gem 'protection'
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install protection
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
In the controller you want to protect, or in application_controller to protect the entire app:
|
24
|
+
|
25
|
+
class ApplicationController < ActionController::Base
|
26
|
+
include Neoteric::Protection
|
27
|
+
end
|
28
|
+
|
29
|
+
And you must set these two ENV variables:
|
30
|
+
|
31
|
+
export STAGING_USERNAME=*your_username*
|
32
|
+
export STAGING_PASSWORD=*your_secret*
|
data/Rakefile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'rehearsal/view_helpers'
|
2
|
+
|
3
|
+
module Rehearsal
|
4
|
+
class Engine < ::Rails::Engine
|
5
|
+
initializer "rehearsal.view_helpers" do
|
6
|
+
ActionView::Base.send :include, ViewHelpers
|
7
|
+
end
|
8
|
+
|
9
|
+
initializer "rehearsal.action_controller" do
|
10
|
+
ActionController::Base.send :include, Rehearsal
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Rehearsal
|
2
|
+
module ViewHelpers
|
3
|
+
def staging_banner(options = {})
|
4
|
+
content_tag :div, :id => 'rehearsal-staging-banner' do
|
5
|
+
options[:message] || default_message
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
private
|
10
|
+
def default_message
|
11
|
+
'This is your staging banner. Override this text with the :message option.'
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/lib/rehearsal.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
require "rehearsal/version"
|
2
|
+
require "rehearsal/engine"
|
3
|
+
|
4
|
+
module Rehearsal
|
5
|
+
def self.included(base)
|
6
|
+
base.extend ClassMethods
|
7
|
+
base.helper_method :staging?
|
8
|
+
base.before_filter :require_http_basic_auth
|
9
|
+
end
|
10
|
+
|
11
|
+
module ClassMethods
|
12
|
+
def rehearse_with(options = {})
|
13
|
+
class_eval do
|
14
|
+
define_method(:username) do
|
15
|
+
options[:username]
|
16
|
+
end
|
17
|
+
|
18
|
+
define_method(:password) do
|
19
|
+
options[:password]
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
def require_http_basic_auth
|
27
|
+
authenticate_or_request_with_http_basic do |username, password|
|
28
|
+
username == self.username && password == self.password
|
29
|
+
end# if staging?
|
30
|
+
end
|
31
|
+
|
32
|
+
def staging?
|
33
|
+
Rails.env.staging?
|
34
|
+
end
|
35
|
+
end
|
data/rehearsal.gemspec
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/rehearsal/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Joe Sak"]
|
6
|
+
gem.email = ["joe@neotericdesign.com"]
|
7
|
+
gem.description = %q{Quickly add Staging Env. HTTP basic auth to your project}
|
8
|
+
gem.summary = %q{Easy HTTP Basic Auth for Staging Rails Apps}
|
9
|
+
gem.homepage = ""
|
10
|
+
|
11
|
+
gem.files = `git ls-files`.split($\)
|
12
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
|
+
gem.name = "rehearsal"
|
15
|
+
gem.require_paths = ["lib", "vendor"]
|
16
|
+
gem.version = Rehearsal::VERSION
|
17
|
+
end
|
metadata
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rehearsal
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.9.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Joe Sak
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-12-20 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: Quickly add Staging Env. HTTP basic auth to your project
|
15
|
+
email:
|
16
|
+
- joe@neotericdesign.com
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- .gitignore
|
22
|
+
- .rvmrc
|
23
|
+
- Gemfile
|
24
|
+
- LICENSE
|
25
|
+
- README.md
|
26
|
+
- Rakefile
|
27
|
+
- lib/rehearsal.rb
|
28
|
+
- lib/rehearsal/engine.rb
|
29
|
+
- lib/rehearsal/version.rb
|
30
|
+
- lib/rehearsal/view_helpers.rb
|
31
|
+
- rehearsal.gemspec
|
32
|
+
- vendor/assets/stylesheets/rehearsal.css.scss
|
33
|
+
homepage: ''
|
34
|
+
licenses: []
|
35
|
+
post_install_message:
|
36
|
+
rdoc_options: []
|
37
|
+
require_paths:
|
38
|
+
- lib
|
39
|
+
- vendor
|
40
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
47
|
+
none: false
|
48
|
+
requirements:
|
49
|
+
- - ! '>='
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: '0'
|
52
|
+
requirements: []
|
53
|
+
rubyforge_project:
|
54
|
+
rubygems_version: 1.8.24
|
55
|
+
signing_key:
|
56
|
+
specification_version: 3
|
57
|
+
summary: Easy HTTP Basic Auth for Staging Rails Apps
|
58
|
+
test_files: []
|