ey_config 0.0.2 → 0.0.4
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/lib/ey_config.rb +48 -14
- data/lib/ey_config/version.rb +1 -1
- metadata +5 -7
data/lib/ey_config.rb
CHANGED
@@ -3,7 +3,8 @@ require File.expand_path('../ey_config/local', __FILE__)
|
|
3
3
|
module EY
|
4
4
|
class Config
|
5
5
|
class << self
|
6
|
-
|
6
|
+
DEPLOYED_CONFIG_PATH = 'config/ey_services_config_deploy.yml'
|
7
|
+
PATHS_TO_CHECK = [DEPLOYED_CONFIG_PATH, EY::Config::Local.config_path]
|
7
8
|
|
8
9
|
def config_path=(val)
|
9
10
|
@full_path = nil
|
@@ -20,36 +21,70 @@ module EY
|
|
20
21
|
|
21
22
|
def init
|
22
23
|
unless File.exists?(full_path)
|
23
|
-
|
24
|
-
|
24
|
+
err_msg = ""
|
25
|
+
if detected_a_dev_environment?
|
26
|
+
ey_config_local_usage
|
27
|
+
err_msg = "Expected to find EY::Config YAML file at: #{EY::Config::Local.config_path}"
|
28
|
+
else
|
29
|
+
err_msg = "Expected to find EY::Config YAML file at: #{DEPLOYED_CONFIG_PATH}"
|
30
|
+
end
|
31
|
+
warn err_msg
|
32
|
+
raise ArgumentError, err_msg
|
25
33
|
end
|
26
34
|
@config = YAML.load_file(full_path)
|
27
35
|
unless valid_structure?(@config)
|
28
|
-
|
29
|
-
raise ArgumentError, "Expected YAML file at: #{full_path} to contain a hash of hashes, got: #{@config.inspect}"
|
36
|
+
ey_config_empty_warning(full_path, @config)
|
30
37
|
end
|
31
38
|
end
|
39
|
+
|
32
40
|
def get(*args)
|
33
41
|
@args = args
|
34
42
|
init unless @config
|
35
|
-
hash = @config
|
43
|
+
hash = @config.dup
|
36
44
|
args.each do |arg|
|
37
45
|
hash = hash[arg.to_s] if hash
|
38
46
|
end
|
39
|
-
hash.
|
47
|
+
if hash.nil?
|
48
|
+
err_message = "No config found for #{args.inspect}. "
|
49
|
+
if detected_a_dev_environment?
|
50
|
+
err_message += "You can put development/fallback configs in: #{EY::Config::Local.config_path}"
|
51
|
+
else
|
52
|
+
err_message += "Activate the services that provides '#{args.first}' or remove the code that uses it."
|
53
|
+
end
|
54
|
+
warn err_message
|
55
|
+
raise ArgumentError, err_message
|
56
|
+
end
|
57
|
+
hash.freeze
|
40
58
|
end
|
41
59
|
|
42
60
|
private
|
43
61
|
|
62
|
+
def detected_a_dev_environment?
|
63
|
+
env = ENV['RAILS_ENV'] || ENV['RACK_ENV']
|
64
|
+
!env || env.to_s.match(/test|development/i)
|
65
|
+
end
|
66
|
+
|
67
|
+
def warn(arg)
|
68
|
+
STDERR.puts arg
|
69
|
+
end
|
70
|
+
|
71
|
+
def ey_config_empty_warning(full_path, config)
|
72
|
+
warn ''
|
73
|
+
warn "*" * 80
|
74
|
+
warn " Expected YAML file at: #{full_path} to contain a hash of hashes, got: #{config.inspect}"
|
75
|
+
warn "*" * 80
|
76
|
+
warn ''
|
77
|
+
end
|
78
|
+
|
44
79
|
def ey_config_local_usage
|
45
80
|
@args ||= []
|
46
81
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
82
|
+
warn ''
|
83
|
+
warn "*" * 80
|
84
|
+
warn " To generate a config file for local development, run the following:"
|
85
|
+
warn " $ ey_config_local #{@args.join(' ')}"
|
86
|
+
warn "*" * 80
|
87
|
+
warn ''
|
53
88
|
end
|
54
89
|
|
55
90
|
def find_config(config_paths)
|
@@ -61,7 +96,6 @@ module EY
|
|
61
96
|
return possible_path
|
62
97
|
end
|
63
98
|
end
|
64
|
-
ey_config_local_usage
|
65
99
|
raise ArgumentError, "Expected to find EY::Config YAML file at one of: #{possible_paths.inspect}"
|
66
100
|
end
|
67
101
|
|
data/lib/ey_config/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ey_config
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 4
|
10
|
+
version: 0.0.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jacob Burkhart & Michael Broadhead & others
|
@@ -15,8 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-02
|
19
|
-
default_executable: ey_config_local
|
18
|
+
date: 2012-04-02 00:00:00 Z
|
20
19
|
dependencies: []
|
21
20
|
|
22
21
|
description: Access to additional services for Engine Yard customers.
|
@@ -35,7 +34,6 @@ files:
|
|
35
34
|
- lib/ey_config.rb
|
36
35
|
- LICENSE
|
37
36
|
- README.md
|
38
|
-
has_rdoc: true
|
39
37
|
homepage: http://github.com/engineyard/ey_config
|
40
38
|
licenses: []
|
41
39
|
|
@@ -65,7 +63,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
65
63
|
requirements: []
|
66
64
|
|
67
65
|
rubyforge_project:
|
68
|
-
rubygems_version: 1.
|
66
|
+
rubygems_version: 1.8.19
|
69
67
|
signing_key:
|
70
68
|
specification_version: 3
|
71
69
|
summary: Engine Yard Configuration
|