enviro 0.0.2 → 0.0.3

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.
@@ -16,8 +16,16 @@ module Enviro
16
16
  @_configuration_path_env
17
17
  end
18
18
 
19
+ def configuration_path_str(path=nil)
20
+ @_configuration_path_str = path
21
+ end
22
+
19
23
  def configuration_path
20
- @_configuration_path ||= (ENV[self.configuration_path_env]||'enviro.yml')
24
+ if @_configuration_path_str
25
+ @_configuration_path ||= @_configuration_path_str
26
+ else
27
+ @_configuration_path ||= (ENV[self.configuration_path_env]||'enviro.yml')
28
+ end
21
29
  end
22
30
 
23
31
  def configuration
@@ -1,3 +1,3 @@
1
1
  module Enviro
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -49,6 +49,7 @@ describe Enviro::Configuration do
49
49
  before(:each) do
50
50
  Object.send(:remove_const, :TestEnviroConfiguration) if defined?(TestEnviroConfiguration)
51
51
  ENV['CUSTOM_PATH'] = '/tmp/enviro_custom.yml'
52
+
52
53
  class TestEnviroConfiguration
53
54
  include Enviro::Environment
54
55
  include Enviro::Configuration
@@ -72,4 +73,47 @@ describe Enviro::Configuration do
72
73
  end
73
74
 
74
75
  end
76
+
77
+ context "with path specified in enviro configuration itself" do
78
+ before(:each) do
79
+ Object.send(:remove_const, :TestEnviroConfiguration) if defined?(TestEnviroConfiguration)
80
+ ENV['CUSTOM_PATH'] = '/tmp/enviro_custom.yml'
81
+ ENV['ENVY_ENV'] = nil
82
+
83
+ $custom_str_path = '/tmp/enviro_custom_str.yml'
84
+
85
+ config = {
86
+ :development => {
87
+ },
88
+ :test => {
89
+ },
90
+ :production => {
91
+ },
92
+ }
93
+ File.open($custom_str_path, 'w') do |f|
94
+ f.write(YAML.dump(config))
95
+ end
96
+
97
+ class TestEnviroConfiguration
98
+ include Enviro::Environment
99
+ include Enviro::Configuration
100
+ configuration_path_str $custom_str_path
101
+ end
102
+ end
103
+
104
+ it "should have configuration available as a struct like object" do
105
+ TestEnviroConfiguration.configuration.should respond_to(:methods)
106
+ end
107
+
108
+ it "should have configuration for current environment" do
109
+ TestEnviroConfiguration.configuration.environment.should be(:development)
110
+ end
111
+
112
+ it "should raise when configuration for current environment is not found" do
113
+ ENV['ENVY_ENV'] = 'who_the_heck_knows'
114
+ expect {
115
+ TestEnviroConfiguration.configuration.environment
116
+ }.should raise_error(Enviro::Configuration::UnknownEnvironment)
117
+ end
118
+ end
75
119
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: enviro
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -14,7 +14,7 @@ default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: cucumber
17
- requirement: &17892580 !ruby/object:Gem::Requirement
17
+ requirement: &17235500 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: '0'
23
23
  type: :development
24
24
  prerelease: false
25
- version_requirements: *17892580
25
+ version_requirements: *17235500
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: rspec
28
- requirement: &17892160 !ruby/object:Gem::Requirement
28
+ requirement: &17235080 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ! '>='
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
- version_requirements: *17892160
36
+ version_requirements: *17235080
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: autotest-standalone
39
- requirement: &17891740 !ruby/object:Gem::Requirement
39
+ requirement: &17234660 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ! '>='
@@ -44,10 +44,10 @@ dependencies:
44
44
  version: '0'
45
45
  type: :development
46
46
  prerelease: false
47
- version_requirements: *17891740
47
+ version_requirements: *17234660
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: autotest-growl
50
- requirement: &17891320 !ruby/object:Gem::Requirement
50
+ requirement: &17234240 !ruby/object:Gem::Requirement
51
51
  none: false
52
52
  requirements:
53
53
  - - ! '>='
@@ -55,10 +55,10 @@ dependencies:
55
55
  version: '0'
56
56
  type: :development
57
57
  prerelease: false
58
- version_requirements: *17891320
58
+ version_requirements: *17234240
59
59
  - !ruby/object:Gem::Dependency
60
60
  name: simplecov
61
- requirement: &17890900 !ruby/object:Gem::Requirement
61
+ requirement: &17233820 !ruby/object:Gem::Requirement
62
62
  none: false
63
63
  requirements:
64
64
  - - ! '>='
@@ -66,10 +66,10 @@ dependencies:
66
66
  version: '0'
67
67
  type: :development
68
68
  prerelease: false
69
- version_requirements: *17890900
69
+ version_requirements: *17233820
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: ruby-debug19
72
- requirement: &17890480 !ruby/object:Gem::Requirement
72
+ requirement: &17233400 !ruby/object:Gem::Requirement
73
73
  none: false
74
74
  requirements:
75
75
  - - ! '>='
@@ -77,7 +77,7 @@ dependencies:
77
77
  version: '0'
78
78
  type: :development
79
79
  prerelease: false
80
- version_requirements: *17890480
80
+ version_requirements: *17233400
81
81
  description: ! ' Add rails like application wide environment configuration, logging
82
82
  and more. '
83
83
  email: