rehearsal 1.2.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,10 @@
1
1
  Rehearsal.configure do |config|
2
- # Set the environment you want to rehearse in
3
- # config.env = :staging
2
+ # Set the environments you want http basic auth in
3
+ # config.auth_envs = [:staging]
4
+ #
5
+ # Set the environments you want the banner in
6
+ # config.banner_envs = [:staging]
4
7
  #
5
8
  # Enable/disable the rehearsal
6
- # config.enabled = true
9
+ # config.enabled = true
7
10
  end
data/lib/rehearsal.rb CHANGED
@@ -4,7 +4,9 @@ require "rehearsal/engine"
4
4
  module Rehearsal
5
5
  def self.included(base)
6
6
  base.extend ClassMethods
7
- base.helper_method :rehearsing?
7
+ base.helper_method :rehearsing?,
8
+ :rehearsing_with_auth?,
9
+ :rehearsing_with_banner?
8
10
  base.before_filter :require_http_basic_auth
9
11
  end
10
12
 
@@ -42,11 +44,18 @@ module Rehearsal
42
44
  def require_http_basic_auth
43
45
  authenticate_or_request_with_http_basic do |username, password|
44
46
  username == self.username && password == self.password
45
- end if rehearsing?
47
+ end if rehearsing_with_auth?
46
48
  end
47
49
 
48
50
  def rehearsing?
49
- return unless Rehearsal.config.enabled
50
- Rails.env.to_sym == Rehearsal.config.env
51
+ Rehearsal.config.enabled
52
+ end
53
+
54
+ def rehearsing_with_auth?
55
+ rehearsing? && Rehearsal.config.auth_envs.include?(Rails.env.to_sym)
56
+ end
57
+
58
+ def rehearsing_with_banner?
59
+ rehearsing? && Rehearsal.config.banner_envs.include?(Rails.env.to_sym)
51
60
  end
52
61
  end
@@ -1,10 +1,11 @@
1
1
  module Rehearsal
2
2
  class Configuration
3
- attr_accessor :env, :enabled
3
+ attr_accessor :auth_envs, :banner_envs, :enabled
4
4
 
5
5
  def initialize
6
- @env ||= :staging
7
- @enabled = false if @enabled.nil?
6
+ @auth_envs ||= [:staging]
7
+ @banner_envs ||= [:staging]
8
+ @enabled = !@enabled.nil?
8
9
  end
9
10
  end
10
11
  end
@@ -1,3 +1,3 @@
1
1
  module Rehearsal
2
- VERSION = "1.2.0"
2
+ VERSION = "1.3.0"
3
3
  end
@@ -1,7 +1,7 @@
1
1
  module Rehearsal
2
2
  module ViewHelpers
3
3
  def rehearsal_banner(message = nil)
4
- return unless rehearsing?
4
+ return unless rehearsing_with_banner?
5
5
 
6
6
  content_tag :div, :id => 'rehearsal-banner' do
7
7
  if block_given?
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rehearsal
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-17 00:00:00.000000000 Z
12
+ date: 2013-02-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails