rehearsal 1.3.3 → 2.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.
@@ -0,0 +1,30 @@
1
+ module Rehearsal
2
+ class InstallGenerator < ::Rails::Generators::Base
3
+ source_root File.expand_path('../templates', __FILE__)
4
+ argument :type, :as => :string, :default => 'global'
5
+
6
+ def remove_other_config
7
+ case type
8
+ when 'global'
9
+ remove_file ".rehearsal"
10
+ when 'user'
11
+ remove_file "config/initializers/rehearsal.rb"
12
+ end
13
+ end
14
+
15
+ def copy_initializer_file
16
+ case type
17
+ when 'global'
18
+ copy_file "initializer.rb", "config/initializers/rehearsal.rb"
19
+ when 'user'
20
+ copy_file "rehearsal.yml", ".rehearsal"
21
+ end
22
+ end
23
+
24
+ def add_config_to_gitignore
25
+ if type == 'user'
26
+ append_file(".gitignore", ".rehearsal")
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,3 @@
1
+ auth_envs: staging
2
+ banner_envs: staging
3
+ enabled: true
data/lib/rehearsal.rb CHANGED
@@ -21,8 +21,6 @@ module Rehearsal
21
21
  password
22
22
  end
23
23
  end
24
-
25
- Rehearsal.config.enabled = true
26
24
  end
27
25
  end
28
26
 
@@ -3,9 +3,31 @@ module Rehearsal
3
3
  attr_accessor :auth_envs, :banner_envs, :enabled
4
4
 
5
5
  def initialize
6
+ initialize_from_hidden_file!
7
+
6
8
  @auth_envs ||= [:staging]
7
9
  @banner_envs ||= [:staging]
8
- @enabled = !@enabled.nil?
10
+ @enabled = true if enabled.nil?
11
+ end
12
+
13
+ private
14
+ def initialize_from_hidden_file!
15
+ return unless File.exist?(hidden_file_path)
16
+
17
+ file = File.open(hidden_file_path)
18
+ config = YAML.load(file)
19
+
20
+ config.each do |attr, value|
21
+ if value.respond_to?(:split)
22
+ value = value.split(',').map(&:strip).map(&:to_sym)
23
+ end
24
+
25
+ self.send("#{attr}=", value)
26
+ end
27
+ end
28
+
29
+ def hidden_file_path
30
+ "#{Rails.root}/.rehearsal"
9
31
  end
10
32
  end
11
33
  end
@@ -1,3 +1,3 @@
1
1
  module Rehearsal
2
- VERSION = "1.3.3"
2
+ VERSION = "2.0.0"
3
3
  end
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.3.3
4
+ version: 2.0.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-05-03 00:00:00.000000000 Z
12
+ date: 2013-05-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -40,8 +40,9 @@ executables: []
40
40
  extensions: []
41
41
  extra_rdoc_files: []
42
42
  files:
43
- - lib/generators/rehearsal/initializer/initializer_generator.rb
44
- - lib/generators/rehearsal/initializer/templates/initializer.rb
43
+ - lib/generators/rehearsal/install/install_generator.rb
44
+ - lib/generators/rehearsal/install/templates/initializer.rb
45
+ - lib/generators/rehearsal/install/templates/rehearsal.yml
45
46
  - lib/rehearsal.rb
46
47
  - lib/rehearsal/configuration.rb
47
48
  - lib/rehearsal/engine.rb
@@ -1,9 +0,0 @@
1
- module Rehearsal
2
- class InitializerGenerator < Rails::Generators::Base
3
- source_root File.expand_path('../templates', __FILE__)
4
-
5
- def copy_initializer_file
6
- copy_file "initializer.rb", "config/initializers/rehearsal.rb"
7
- end
8
- end
9
- end