enviro 0.0.4 → 0.0.5
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.
- data/features/enviro/version.feature +1 -1
- data/lib/core_ext/hash.rb +11 -0
- data/lib/enviro.rb +2 -0
- data/lib/enviro/configuration.rb +3 -3
- data/lib/enviro/environment.rb +2 -2
- data/lib/enviro/logger.rb +1 -1
- data/lib/enviro/version.rb +1 -1
- data/spec/enviro/configuration_spec.rb +6 -6
- data/spec/enviro/environment_spec.rb +12 -12
- data/spec/enviro/logger_spec.rb +12 -12
- data/spec/enviro/version_spec.rb +2 -2
- metadata +89 -72
data/lib/enviro.rb
CHANGED
data/lib/enviro/configuration.rb
CHANGED
@@ -11,7 +11,7 @@ module Enviro
|
|
11
11
|
module ClassMethods
|
12
12
|
|
13
13
|
def configuration_path_env(value=nil)
|
14
|
-
@_configuration_path_env ||= '
|
14
|
+
@_configuration_path_env ||= 'ENVIRO_CONF_PATH'
|
15
15
|
@_configuration_path_env = value.to_s.upcase unless value.nil?
|
16
16
|
@_configuration_path_env
|
17
17
|
end
|
@@ -38,12 +38,12 @@ module Enviro
|
|
38
38
|
raise FileNotFound.new(self.configuration_path) unless
|
39
39
|
File.exists?(self.configuration_path)
|
40
40
|
|
41
|
-
@raw_configuration = YAML.load_file(self.configuration_path)
|
41
|
+
@raw_configuration = YAML.load_file(self.configuration_path).deep_symbolize_keys
|
42
42
|
|
43
43
|
raise UnknownEnvironment.new(self.environment) unless
|
44
44
|
@raw_configuration.key?(self.environment)
|
45
45
|
|
46
|
-
OpenStruct.new(@raw_configuration[self.environment].merge(:environment => self.environment))
|
46
|
+
::OpenStruct.new(@raw_configuration[self.environment].merge(:environment => self.environment))
|
47
47
|
end
|
48
48
|
|
49
49
|
end
|
data/lib/enviro/environment.rb
CHANGED
@@ -23,9 +23,9 @@ module Enviro
|
|
23
23
|
|
24
24
|
def _setup_environment
|
25
25
|
if defined?(Rails)
|
26
|
-
Rails.env
|
26
|
+
Rails.env.to_sym
|
27
27
|
else
|
28
|
-
ENV['
|
28
|
+
ENV['ENVIRO_ENV'].nil? ? :development : ENV['ENVIRO_ENV'].to_sym
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
data/lib/enviro/logger.rb
CHANGED
data/lib/enviro/version.rb
CHANGED
@@ -4,7 +4,7 @@ describe Enviro::Configuration do
|
|
4
4
|
context "with standard environment variable" do
|
5
5
|
before(:each) do
|
6
6
|
Object.send(:remove_const, :TestEnviroConfiguration) if defined?(TestEnviroConfiguration)
|
7
|
-
ENV['
|
7
|
+
ENV['ENVIRO_CONF_PATH'] = '/tmp/enviro.yml'
|
8
8
|
class TestEnviroConfiguration
|
9
9
|
include Enviro::Environment
|
10
10
|
include Enviro::Configuration
|
@@ -17,7 +17,7 @@ describe Enviro::Configuration do
|
|
17
17
|
:production => {
|
18
18
|
},
|
19
19
|
}
|
20
|
-
File.open(ENV['
|
20
|
+
File.open(ENV['ENVIRO_CONF_PATH'], 'w') do |f|
|
21
21
|
f.write(YAML.dump(config))
|
22
22
|
end
|
23
23
|
end
|
@@ -31,14 +31,14 @@ describe Enviro::Configuration do
|
|
31
31
|
end
|
32
32
|
|
33
33
|
it "should raise when configuration file is not found" do
|
34
|
-
ENV['
|
34
|
+
ENV['ENVIRO_CONF_PATH'] = 'who_the_heck_knows'
|
35
35
|
expect {
|
36
36
|
TestEnviroConfiguration.configuration
|
37
37
|
}.should raise_error(Enviro::Configuration::FileNotFound)
|
38
38
|
end
|
39
39
|
|
40
40
|
it "should raise when configuration for current environment is not found" do
|
41
|
-
ENV['
|
41
|
+
ENV['ENVIRO_ENV'] = 'who_the_heck_knows'
|
42
42
|
expect {
|
43
43
|
TestEnviroConfiguration.configuration.environment
|
44
44
|
}.should raise_error(Enviro::Configuration::UnknownEnvironment)
|
@@ -82,7 +82,7 @@ describe Enviro::Configuration do
|
|
82
82
|
before(:each) do
|
83
83
|
Object.send(:remove_const, :TestEnviroConfiguration) if defined?(TestEnviroConfiguration)
|
84
84
|
ENV['CUSTOM_PATH'] = '/tmp/enviro_custom.yml'
|
85
|
-
ENV['
|
85
|
+
ENV['ENVIRO_ENV'] = nil
|
86
86
|
|
87
87
|
$custom_str_path = '/tmp/enviro_custom_str.yml'
|
88
88
|
|
@@ -114,7 +114,7 @@ describe Enviro::Configuration do
|
|
114
114
|
end
|
115
115
|
|
116
116
|
it "should raise when configuration for current environment is not found" do
|
117
|
-
ENV['
|
117
|
+
ENV['ENVIRO_ENV'] = 'who_the_heck_knows'
|
118
118
|
expect {
|
119
119
|
TestEnviroConfiguration.configuration.environment
|
120
120
|
}.should raise_error(Enviro::Configuration::UnknownEnvironment)
|
@@ -9,32 +9,32 @@ describe Enviro::Environment do
|
|
9
9
|
end
|
10
10
|
|
11
11
|
it "should have the environment attribute set the default when no session ENV setting is set" do
|
12
|
-
ENV['
|
13
|
-
ENV['
|
12
|
+
ENV['ENVIRO_ENV'] = nil
|
13
|
+
ENV['ENVIRO_ENV'].should be_nil
|
14
14
|
TestEnviroEnvironment.environment.should == :development
|
15
15
|
end
|
16
16
|
|
17
17
|
it "should have the environment attribute set the same as the session ENV setting" do
|
18
|
-
ENV['
|
19
|
-
ENV['
|
18
|
+
ENV['ENVIRO_ENV'] = 'production'
|
19
|
+
ENV['ENVIRO_ENV'].should == "production"
|
20
20
|
TestEnviroEnvironment.environment.should == :production
|
21
21
|
end
|
22
22
|
|
23
23
|
it "should alias env to environment" do
|
24
|
-
ENV['
|
25
|
-
ENV['
|
24
|
+
ENV['ENVIRO_ENV'] = nil
|
25
|
+
ENV['ENVIRO_ENV'].should be_nil
|
26
26
|
TestEnviroEnvironment.env.should == :development
|
27
27
|
end
|
28
28
|
|
29
29
|
it "should return true on env?(value) when value is environment" do
|
30
|
-
ENV['
|
31
|
-
ENV['
|
30
|
+
ENV['ENVIRO_ENV'] = nil
|
31
|
+
ENV['ENVIRO_ENV'].should be_nil
|
32
32
|
TestEnviroEnvironment.env?('development').should be_true
|
33
33
|
end
|
34
34
|
|
35
35
|
it "should return false on env?(value) when value is not environment" do
|
36
|
-
ENV['
|
37
|
-
ENV['
|
36
|
+
ENV['ENVIRO_ENV'] = nil
|
37
|
+
ENV['ENVIRO_ENV'].should be_nil
|
38
38
|
TestEnviroEnvironment.env?('production').should be_false
|
39
39
|
end
|
40
40
|
|
@@ -52,8 +52,8 @@ describe Enviro::Environment do
|
|
52
52
|
end
|
53
53
|
|
54
54
|
it "should inherit the environment from Rails should it be loaded" do
|
55
|
-
ENV['
|
56
|
-
ENV['
|
55
|
+
ENV['ENVIRO_ENV'] = nil
|
56
|
+
ENV['ENVIRO_ENV'].should be_nil
|
57
57
|
TestEnviroEnvironment.environment.should == :production
|
58
58
|
end
|
59
59
|
end
|
data/spec/enviro/logger_spec.rb
CHANGED
@@ -8,21 +8,21 @@ describe Enviro::Logger do
|
|
8
8
|
include Enviro::Environment
|
9
9
|
include Enviro::Logger
|
10
10
|
end
|
11
|
-
ENV['
|
12
|
-
ENV['
|
13
|
-
ENV['
|
11
|
+
ENV['ENVIRO_LOG_DIR'] = nil
|
12
|
+
ENV['ENVIRO_CONF_PATH'] = nil
|
13
|
+
ENV['ENVIRO_ENV'] = nil
|
14
14
|
end
|
15
15
|
|
16
16
|
it "should have logger like object available" do
|
17
17
|
TestEnviroLogger.logger.should respond_to(:debug)
|
18
18
|
end
|
19
19
|
|
20
|
-
it "should log to STDOUT if
|
20
|
+
it "should log to STDOUT if ENVIRO_LOG_DIR is nil" do
|
21
21
|
TestEnviroLogger.logger.instance_variable_get(:@logdev).dev.should be(STDOUT)
|
22
22
|
end
|
23
23
|
|
24
|
-
it "should log to /tmp/development.log if
|
25
|
-
ENV['
|
24
|
+
it "should log to /tmp/development.log if ENVIRO_LOG_DIR is /tmp and ENVIRO_ENV is development" do
|
25
|
+
ENV['ENVIRO_LOG_DIR'] = '/tmp'
|
26
26
|
TestEnviroLogger.logger.instance_variable_get(:@logdev).dev.path.should == '/tmp/development.log'
|
27
27
|
end
|
28
28
|
|
@@ -33,7 +33,7 @@ describe Enviro::Logger do
|
|
33
33
|
end
|
34
34
|
|
35
35
|
it "should raise when log file is not writable" do
|
36
|
-
ENV['
|
36
|
+
ENV['ENVIRO_LOG_DIR'] = '/tmp/this_dir_is_not_here'
|
37
37
|
expect {
|
38
38
|
TestEnviroLogger.logger
|
39
39
|
}.should raise_error(Enviro::Logger::DirectoryNotFound)
|
@@ -53,10 +53,10 @@ describe Enviro::Logger do
|
|
53
53
|
end
|
54
54
|
|
55
55
|
it "should inherit the logger from Rails should it be loaded" do
|
56
|
-
# if we set the log dir to something that doesn't exist
|
56
|
+
# if we set the log dir to something that doesn't exist
|
57
57
|
# we can more sure that the Rails.logger is getting used
|
58
58
|
# since otherwise we would raise an error due to the missing dir
|
59
|
-
ENV['
|
59
|
+
ENV['ENVIRO_LOG_DIR'] = '/tmp/this_should_not_exits'
|
60
60
|
TestEnviroLogger.logger.instance_variable_get(:@logdev).dev.should == Rails.logger.instance_variable_get(:@logdev).dev
|
61
61
|
end
|
62
62
|
end
|
@@ -70,9 +70,9 @@ describe Enviro::Logger do
|
|
70
70
|
include Enviro::Logger
|
71
71
|
logger_dir_env :custom_log
|
72
72
|
end
|
73
|
-
ENV['
|
74
|
-
ENV['
|
75
|
-
ENV['
|
73
|
+
ENV['ENVIRO_LOG_DIR'] = nil
|
74
|
+
ENV['ENVIRO_CONF_PATH'] = nil
|
75
|
+
ENV['ENVIRO_ENV'] = nil
|
76
76
|
end
|
77
77
|
|
78
78
|
it "should upcase the logger_dir_env attribute" do
|
data/spec/enviro/version_spec.rb
CHANGED
metadata
CHANGED
@@ -1,91 +1,94 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: enviro
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.4
|
3
|
+
version: !ruby/object:Gem::Version
|
5
4
|
prerelease:
|
5
|
+
version: 0.0.5
|
6
6
|
platform: ruby
|
7
|
-
authors:
|
7
|
+
authors:
|
8
8
|
- Bram Swenson
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
|
12
|
+
|
13
|
+
date: 2011-06-18 00:00:00 -07:00
|
13
14
|
default_executable:
|
14
|
-
dependencies:
|
15
|
-
- !ruby/object:Gem::Dependency
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
16
17
|
name: cucumber
|
17
|
-
|
18
|
+
prerelease: false
|
19
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
18
20
|
none: false
|
19
|
-
requirements:
|
20
|
-
- -
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version:
|
21
|
+
requirements:
|
22
|
+
- - ">="
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: "0"
|
23
25
|
type: :development
|
24
|
-
|
25
|
-
|
26
|
-
- !ruby/object:Gem::Dependency
|
26
|
+
version_requirements: *id001
|
27
|
+
- !ruby/object:Gem::Dependency
|
27
28
|
name: rspec
|
28
|
-
|
29
|
+
prerelease: false
|
30
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
29
31
|
none: false
|
30
|
-
requirements:
|
31
|
-
- -
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version:
|
32
|
+
requirements:
|
33
|
+
- - ">="
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: "0"
|
34
36
|
type: :development
|
35
|
-
|
36
|
-
|
37
|
-
- !ruby/object:Gem::Dependency
|
37
|
+
version_requirements: *id002
|
38
|
+
- !ruby/object:Gem::Dependency
|
38
39
|
name: autotest-standalone
|
39
|
-
|
40
|
+
prerelease: false
|
41
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
40
42
|
none: false
|
41
|
-
requirements:
|
42
|
-
- -
|
43
|
-
- !ruby/object:Gem::Version
|
44
|
-
version:
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: "0"
|
45
47
|
type: :development
|
46
|
-
|
47
|
-
|
48
|
-
- !ruby/object:Gem::Dependency
|
48
|
+
version_requirements: *id003
|
49
|
+
- !ruby/object:Gem::Dependency
|
49
50
|
name: autotest-growl
|
50
|
-
|
51
|
+
prerelease: false
|
52
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
51
53
|
none: false
|
52
|
-
requirements:
|
53
|
-
- -
|
54
|
-
- !ruby/object:Gem::Version
|
55
|
-
version:
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: "0"
|
56
58
|
type: :development
|
57
|
-
|
58
|
-
|
59
|
-
- !ruby/object:Gem::Dependency
|
59
|
+
version_requirements: *id004
|
60
|
+
- !ruby/object:Gem::Dependency
|
60
61
|
name: simplecov
|
61
|
-
|
62
|
+
prerelease: false
|
63
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
62
64
|
none: false
|
63
|
-
requirements:
|
64
|
-
- -
|
65
|
-
- !ruby/object:Gem::Version
|
66
|
-
version:
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: "0"
|
67
69
|
type: :development
|
68
|
-
|
69
|
-
|
70
|
-
- !ruby/object:Gem::Dependency
|
70
|
+
version_requirements: *id005
|
71
|
+
- !ruby/object:Gem::Dependency
|
71
72
|
name: ruby-debug19
|
72
|
-
|
73
|
+
prerelease: false
|
74
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
73
75
|
none: false
|
74
|
-
requirements:
|
75
|
-
- -
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
version:
|
76
|
+
requirements:
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: "0"
|
78
80
|
type: :development
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
and more. '
|
83
|
-
email:
|
81
|
+
version_requirements: *id006
|
82
|
+
description: " Add rails like application wide environment configuration, logging and more. "
|
83
|
+
email:
|
84
84
|
- bram@craniumisajar.com
|
85
85
|
executables: []
|
86
|
+
|
86
87
|
extensions: []
|
88
|
+
|
87
89
|
extra_rdoc_files: []
|
88
|
-
|
90
|
+
|
91
|
+
files:
|
89
92
|
- .gitignore
|
90
93
|
- .rspec
|
91
94
|
- .rvmrc
|
@@ -98,6 +101,7 @@ files:
|
|
98
101
|
- features/step_definitions/.initialize_steps.rb.swp
|
99
102
|
- features/step_definitions/version_steps.rb
|
100
103
|
- features/support/env.rb
|
104
|
+
- lib/core_ext/hash.rb
|
101
105
|
- lib/enviro.rb
|
102
106
|
- lib/enviro/configuration.rb
|
103
107
|
- lib/enviro/environate.rb
|
@@ -114,28 +118,41 @@ files:
|
|
114
118
|
- tasks/default.rake
|
115
119
|
- tasks/rspec.rake
|
116
120
|
has_rdoc: true
|
117
|
-
homepage:
|
121
|
+
homepage: ""
|
118
122
|
licenses: []
|
123
|
+
|
119
124
|
post_install_message:
|
120
125
|
rdoc_options: []
|
121
|
-
|
126
|
+
|
127
|
+
require_paths:
|
122
128
|
- lib
|
123
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
129
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
124
130
|
none: false
|
125
|
-
requirements:
|
126
|
-
- -
|
127
|
-
- !ruby/object:Gem::Version
|
128
|
-
version:
|
129
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
131
|
+
requirements:
|
132
|
+
- - ">="
|
133
|
+
- !ruby/object:Gem::Version
|
134
|
+
version: "0"
|
135
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
130
136
|
none: false
|
131
|
-
requirements:
|
132
|
-
- -
|
133
|
-
- !ruby/object:Gem::Version
|
134
|
-
version:
|
137
|
+
requirements:
|
138
|
+
- - ">="
|
139
|
+
- !ruby/object:Gem::Version
|
140
|
+
version: "0"
|
135
141
|
requirements: []
|
142
|
+
|
136
143
|
rubyforge_project: enviro
|
137
|
-
rubygems_version: 1.
|
144
|
+
rubygems_version: 1.6.1
|
138
145
|
signing_key:
|
139
146
|
specification_version: 3
|
140
147
|
summary: Add rails like application wide environment configuration, logging and more.
|
141
|
-
test_files:
|
148
|
+
test_files:
|
149
|
+
- features/enviro/version.feature
|
150
|
+
- features/step_definitions/.initialize_steps.rb.swp
|
151
|
+
- features/step_definitions/version_steps.rb
|
152
|
+
- features/support/env.rb
|
153
|
+
- spec/enviro/configuration_spec.rb
|
154
|
+
- spec/enviro/environate_spec.rb
|
155
|
+
- spec/enviro/environment_spec.rb
|
156
|
+
- spec/enviro/logger_spec.rb
|
157
|
+
- spec/enviro/version_spec.rb
|
158
|
+
- spec/spec_helper.rb
|