activeconfig 0.6.1 → 0.6.2

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  ---
2
2
  :major: 0
3
3
  :minor: 6
4
- :patch: 1
4
+ :patch: 2
5
5
  :build:
data/activeconfig.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "activeconfig"
8
- s.version = "0.6.1"
8
+ s.version = "0.6.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Jeremy Lawler"]
12
- s.date = "2012-08-07"
12
+ s.date = "2012-08-27"
13
13
  s.description = "An extremely flexible configuration system.\ns the ability for certain values to be \"overridden\" when conditions are met.\nr example, you could have your production API keys only get read when the Rails.env == \"production\""
14
14
  s.email = "jeremylawler@gmail.com"
15
15
  s.executables = ["active_config"]
@@ -31,7 +31,17 @@ class ActiveConfig
31
31
  Socket.gethostname
32
32
  }
33
33
  @symbols[:hostname_short]=proc {|sym_table| sym_table[:hostname].call(sym_table).sub(/\..*$/, '').freeze}
34
- @symbols[:rails_env]=proc { |sym_table| (RAILS_ENV if defined?(RAILS_ENV))||ENV['RAILS_ENV']}
34
+ @symbols[:rails_env]=proc { |sym_table|
35
+ if defined?(RAILS_ENV)
36
+ RAILS_ENV
37
+ elsif defined?(Rails) and Rails.respond_to?(:env)
38
+ Rails.env
39
+ elsif ENV['ACTIVE_CONFIG_FORCE_RAILS_ENV']
40
+ ENV['ACTIVE_CONFIG_FORCE_RAILS_ENV']
41
+ else
42
+ ENV['RAILS_ENV']
43
+ end
44
+ }
35
45
  @symbols[:overlay]=proc { |sym_table| ENV['ACTIVE_CONFIG_OVERLAY']}
36
46
  @symbols.add_write_hook do
37
47
  ac_instance.flush_cache
@@ -1,6 +1,30 @@
1
1
 
2
2
  module ActiveConfigRails
3
3
  module Generators
4
+ class ForceUpgradeGenerator < ::Rails::Generators::Base
5
+ namespace 'active_config:upgrade'
6
+ source_root File.expand_path('../active_config_rails/templates', __FILE__)
7
+
8
+ def generate_config
9
+ template 'active_config_initializer.rb', 'config/initializers/active_config.rb'
10
+ end
11
+
12
+ def insert_to_application
13
+ ln = "require File.expand_path('../initializers/active_config', __FILE__)\n"
14
+ append_to_file 'config/boot.rb', ln
15
+ end
16
+ def convert_database_yaml
17
+ copy_file 'database.yml', 'config/database.yml'
18
+ copy_file 'rails.yml', 'etc/rails.yml'
19
+
20
+
21
+ #comment = "\n # Set the logging destination(s)\n %s\n"
22
+ #insert_into_file 'config/environments/development.rb', comment % 'config.log_to = %w[stdout file]', :before => %r/^end\s*$/
23
+ #insert_into_file 'config/environments/production.rb', comment % 'config.log_to = %w[file]', :before => %r/^end\s*$/
24
+ end
25
+
26
+ end
27
+
4
28
  class InstallGenerator < ::Rails::Generators::Base
5
29
  namespace 'active_config:install'
6
30
  source_root File.expand_path('../active_config_rails/templates', __FILE__)
@@ -12,6 +36,7 @@ module ActiveConfigRails
12
36
  def insert_to_application
13
37
  ln = "require File.expand_path('../initializers/active_config', __FILE__)\n"
14
38
  prepend_to_file 'config/application.rb', ln
39
+ append_to_file 'config/boot.rb', ln
15
40
  end
16
41
  def convert_database_yaml
17
42
  empty_directory('etc')
@@ -1,14 +1,29 @@
1
1
  require 'active_config'
2
-
3
- if Object.const_defined? :CONF
4
- Object.send(:remove_const, :CONF)
2
+ module ActiveConfigRails
3
+ def init_conf
4
+ if Object.const_defined? :CONF
5
+ Object.send(:remove_const, :CONF)
6
+ end
7
+
8
+ etc_dir = File.dirname(File.expand_path(__FILE__)) + '/../../etc'
9
+ Object.const_set(:CONF,ActiveConfig.new(:path => etc_dir))
10
+ end
11
+ module_function :init_conf
5
12
  end
13
+ ActiveConfigRails.init_conf
6
14
 
7
- etc_dir = File.dirname(File.expand_path(__FILE__)) + '/../../etc'
8
- Object.const_set(:CONF,ActiveConfig.new(:path => etc_dir))
15
+ if CONF.rails && CONF.rails.env and not ENV['ACTIVE_CONFIG_FORCE_RAILS_ENV']
16
+ ENV['ACTIVE_CONFIG_FORCE_RAILS_ENV']=CONF.rails.env
17
+ ENV['RAILS_ENV']||=CONF.rails.env
18
+ ActiveConfigRails.init_conf
19
+ end
9
20
 
10
- if CONF.rails.force_env and not ENV['ACTIVE_CONFIG_FORCE_RAILS_ENV']
21
+ if CONF.rails && CONF.rails.force_env and not ENV['ACTIVE_CONFIG_FORCE_RAILS_ENV']
11
22
  ENV['ACTIVE_CONFIG_FORCE_RAILS_ENV']=CONF.rails.force_env
23
+ if ENV['RAILS_ENV']
24
+ STDERR.puts "WARNING: ACTIVE CONFIG IS OVERRIDING YOUR ENVIRONMENT VARIABLE RAILS_ENV!\nPLEASE FIX YOUR rails.yml!"
25
+ end
12
26
  ENV['RAILS_ENV']=CONF.rails.force_env
27
+ ActiveConfigRails.init_conf
13
28
  end
14
29
 
@@ -1,8 +1,12 @@
1
- # If you need to force a rails env for a host
1
+ # If you need to set a rails env for a host
2
2
  # make a host override of this file and
3
- # set the force_env key.
3
+ # set the env key. This will not override
4
+ # the RAILS_ENV environment variable.
4
5
  #
5
- # Setting force_env in a non-host override is
6
- # crazy dangerous.
6
+ # On the other hand, force_env WILL override the
7
+ # RAILS_ENV environment variable. In short,
8
+ # both of thse are crazy dangerous if they
9
+ # aren't in a host override. In fact, force_env
10
+ # is probably pretty close to bat-shit-crazy.
7
11
 
8
- force_env: ~
12
+ env: ~
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activeconfig
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.6.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-07 00:00:00.000000000 Z
12
+ date: 2012-08-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rdoc
16
- requirement: &9724980 !ruby/object:Gem::Requirement
16
+ requirement: &16056160 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '3.12'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *9724980
24
+ version_requirements: *16056160
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: bundler
27
- requirement: &9723520 !ruby/object:Gem::Requirement
27
+ requirement: &16070380 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>'
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 1.0.0
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *9723520
35
+ version_requirements: *16070380
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: jeweler
38
- requirement: &9739780 !ruby/object:Gem::Requirement
38
+ requirement: &16068780 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: 1.8.3
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *9739780
46
+ version_requirements: *16068780
47
47
  description: ! 'An extremely flexible configuration system.
48
48
 
49
49
  s the ability for certain values to be "overridden" when conditions are met.
@@ -100,7 +100,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
100
100
  version: '0'
101
101
  segments:
102
102
  - 0
103
- hash: 1505972558787035087
103
+ hash: 3156518043701645317
104
104
  required_rubygems_version: !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements: