ey_config 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2011 Engine Yard
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,22 @@
1
+
2
+ = Engine Yard Configuration
3
+
4
+ Ruby interface to additional services for customers of Engine Yard.
5
+
6
+ Description goes here.
7
+
8
+ == Contributing to engineyard::configuration
9
+
10
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
11
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
12
+ * Fork the project
13
+ * Start a feature/bugfix branch
14
+ * Commit and push until you are happy with your contribution
15
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
16
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
17
+
18
+ == Copyright
19
+
20
+ Copyright (c) 2011 Engine Yard, Inc.. See LICENSE.txt for
21
+ further details.
22
+
@@ -0,0 +1,5 @@
1
+ module EY
2
+ class Config
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
data/lib/ey_config.rb ADDED
@@ -0,0 +1,58 @@
1
+ module EY
2
+ class Config
3
+ class << self
4
+ PATHS_TO_CHECK = ['config/ey_services_config_deploy.yml', 'config/ey_services_config_local.yml']
5
+
6
+ def config_path=(val)
7
+ @full_path = nil
8
+ @config_paths = [val]
9
+ end
10
+
11
+ def config_paths
12
+ @config_paths ||= PATHS_TO_CHECK
13
+ end
14
+
15
+ def full_path
16
+ @full_path ||= find_config(config_paths)
17
+ end
18
+
19
+ def init
20
+ unless File.exists?(full_path)
21
+ raise ArgumentError, "Expected to find EY::Config YAML file at: #{full_path}"
22
+ end
23
+ @config = YAML.load_file(full_path)
24
+ unless valid_structure?(@config)
25
+ raise ArgumentError, "Expected YAML file at: #{full_path} to contain a hash of hashes, got: #{@config.inspect}"
26
+ end
27
+ end
28
+ def get(*args)
29
+ init unless @config
30
+ hash = @config
31
+ args.each do |arg|
32
+ hash = hash[arg.to_s] if hash
33
+ end
34
+ hash.dup
35
+ end
36
+
37
+ private
38
+
39
+ def find_config(config_paths)
40
+ possible_paths = []
41
+ config_paths.each do |config_path|
42
+ possible_path = File.expand_path(config_path)
43
+ possible_paths << possible_path
44
+ if File.exists?(possible_path)
45
+ return possible_path
46
+ end
47
+ end
48
+ raise ArgumentError, "Expected to find EY::Config YAML file at one of: #{possible_paths.inspect}"
49
+ end
50
+
51
+ def valid_structure?(config)
52
+ config.respond_to?(:has_key?) and
53
+ config.values.first.respond_to?(:has_key?)
54
+ end
55
+ end
56
+ end
57
+ end
58
+
metadata ADDED
@@ -0,0 +1,69 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ey_config
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Jacob Burkhart & Michael Broadhead & others
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-11-08 00:00:00 Z
19
+ dependencies: []
20
+
21
+ description: Access to additional services for Engine Yard customers.
22
+ email:
23
+ - jacob@engineyard.com
24
+ executables: []
25
+
26
+ extensions: []
27
+
28
+ extra_rdoc_files: []
29
+
30
+ files:
31
+ - lib/ey_config/version.rb
32
+ - lib/ey_config.rb
33
+ - LICENSE
34
+ - README.md
35
+ homepage: http://github.com/engineyard/ey_config
36
+ licenses: []
37
+
38
+ post_install_message:
39
+ rdoc_options: []
40
+
41
+ require_paths:
42
+ - lib
43
+ required_ruby_version: !ruby/object:Gem::Requirement
44
+ none: false
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ hash: 3
49
+ segments:
50
+ - 0
51
+ version: "0"
52
+ required_rubygems_version: !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ hash: 3
58
+ segments:
59
+ - 0
60
+ version: "0"
61
+ requirements: []
62
+
63
+ rubyforge_project:
64
+ rubygems_version: 1.8.10
65
+ signing_key:
66
+ specification_version: 3
67
+ summary: Engine Yard Configuration
68
+ test_files: []
69
+