ey_config 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +9 -11
- data/bin/ey_config_local +15 -0
- data/lib/ey_config/local.rb +36 -0
- data/lib/ey_config/version.rb +2 -2
- data/lib/ey_config.rb +18 -1
- metadata +11 -7
data/README.md
CHANGED
@@ -1,22 +1,20 @@
|
|
1
|
-
|
2
|
-
= Engine Yard Configuration
|
1
|
+
# Engine Yard Configuration
|
3
2
|
|
4
3
|
Ruby interface to additional services for customers of Engine Yard.
|
5
4
|
|
6
|
-
|
7
|
-
|
8
|
-
== Contributing to engineyard::configuration
|
5
|
+
## Contributing to EY::Config
|
9
6
|
|
10
|
-
* Check out the latest
|
11
|
-
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
7
|
+
* Check out the latest revision from the master branch
|
8
|
+
* Check out the [issue tracker](https://github.com/engineyard/ey_config/issues) to make sure someone already hasn't requested it and/or contributed it
|
12
9
|
* Fork the project
|
13
10
|
* Start a feature/bugfix branch
|
14
11
|
* Commit and push until you are happy with your contribution
|
15
|
-
*
|
16
|
-
* Please
|
12
|
+
* Send a pull request for your branch
|
13
|
+
* Please add tests for any new code
|
14
|
+
|
17
15
|
|
18
|
-
|
16
|
+
## Copyright
|
19
17
|
|
20
|
-
Copyright (c) 2011 Engine Yard, Inc
|
18
|
+
Copyright (c) 2011, 2012 Engine Yard, Inc. See LICENSE.txt for
|
21
19
|
further details.
|
22
20
|
|
data/bin/ey_config_local
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
$:.unshift(File.expand_path('../../lib', __FILE__))
|
3
|
+
require 'ey_config'
|
4
|
+
|
5
|
+
if ARGV.empty? || ARGV.first == '-h' || ARGV.first == '--help'
|
6
|
+
STDERR.puts "EY::Config::Local"
|
7
|
+
STDERR.puts " Generate YAML file placeholder for development/testing with the EY::Config gem."
|
8
|
+
STDERR.puts " "
|
9
|
+
STDERR.puts " Usage:"
|
10
|
+
STDERR.puts " #{__FILE__} <key> [<key2> [<key3> [...]]]"
|
11
|
+
exit 1
|
12
|
+
end
|
13
|
+
|
14
|
+
EY::Config::Local.generate *ARGV
|
15
|
+
STDERR.puts "Wrote to #{File.expand_path(EY::Config::Local.config_path).inspect}."
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
3
|
+
module EY
|
4
|
+
class Config
|
5
|
+
class Local
|
6
|
+
class << self
|
7
|
+
def config_path
|
8
|
+
'config/ey_services_config_local.yml'
|
9
|
+
end
|
10
|
+
|
11
|
+
def generate(*args)
|
12
|
+
contents = existing_contents
|
13
|
+
contents = {} unless contents.is_a?(Hash)
|
14
|
+
tmp = contents
|
15
|
+
|
16
|
+
args[0 ... -1].each do |arg|
|
17
|
+
tmp[arg] ||= {}
|
18
|
+
tmp = tmp[arg]
|
19
|
+
end
|
20
|
+
tmp[args.last] = 'SAMPLE'
|
21
|
+
|
22
|
+
FileUtils.mkdir_p('config')
|
23
|
+
File.open(config_path, 'w') do |f|
|
24
|
+
f.print YAML.dump(contents)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def existing_contents
|
29
|
+
YAML.load_file(config_path)
|
30
|
+
rescue Errno::ENOENT
|
31
|
+
{}
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/lib/ey_config/version.rb
CHANGED
data/lib/ey_config.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
|
+
require File.expand_path('../ey_config/local', __FILE__)
|
2
|
+
|
1
3
|
module EY
|
2
4
|
class Config
|
3
5
|
class << self
|
4
|
-
PATHS_TO_CHECK = ['config/ey_services_config_deploy.yml',
|
6
|
+
PATHS_TO_CHECK = ['config/ey_services_config_deploy.yml', EY::Config::Local.config_path]
|
5
7
|
|
6
8
|
def config_path=(val)
|
7
9
|
@full_path = nil
|
@@ -18,14 +20,17 @@ module EY
|
|
18
20
|
|
19
21
|
def init
|
20
22
|
unless File.exists?(full_path)
|
23
|
+
ey_config_local_usage
|
21
24
|
raise ArgumentError, "Expected to find EY::Config YAML file at: #{full_path}"
|
22
25
|
end
|
23
26
|
@config = YAML.load_file(full_path)
|
24
27
|
unless valid_structure?(@config)
|
28
|
+
ey_config_local_usage
|
25
29
|
raise ArgumentError, "Expected YAML file at: #{full_path} to contain a hash of hashes, got: #{@config.inspect}"
|
26
30
|
end
|
27
31
|
end
|
28
32
|
def get(*args)
|
33
|
+
@args = args
|
29
34
|
init unless @config
|
30
35
|
hash = @config
|
31
36
|
args.each do |arg|
|
@@ -36,6 +41,17 @@ module EY
|
|
36
41
|
|
37
42
|
private
|
38
43
|
|
44
|
+
def ey_config_local_usage
|
45
|
+
@args ||= []
|
46
|
+
|
47
|
+
STDERR.puts ''
|
48
|
+
STDERR.puts "*" * 80
|
49
|
+
STDERR.puts " To generate a config file for local development, run the following:"
|
50
|
+
STDERR.puts " $ ey_config_local #{@args.join(' ')}"
|
51
|
+
STDERR.puts "*" * 80
|
52
|
+
STDERR.puts ''
|
53
|
+
end
|
54
|
+
|
39
55
|
def find_config(config_paths)
|
40
56
|
possible_paths = []
|
41
57
|
config_paths.each do |config_path|
|
@@ -45,6 +61,7 @@ module EY
|
|
45
61
|
return possible_path
|
46
62
|
end
|
47
63
|
end
|
64
|
+
ey_config_local_usage
|
48
65
|
raise ArgumentError, "Expected to find EY::Config YAML file at one of: #{possible_paths.inspect}"
|
49
66
|
end
|
50
67
|
|
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: 27
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jacob Burkhart & Michael Broadhead & others
|
@@ -15,23 +15,27 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
18
|
+
date: 2012-02-08 00:00:00 -08:00
|
19
|
+
default_executable: ey_config_local
|
19
20
|
dependencies: []
|
20
21
|
|
21
22
|
description: Access to additional services for Engine Yard customers.
|
22
23
|
email:
|
23
24
|
- jacob@engineyard.com
|
24
|
-
executables:
|
25
|
-
|
25
|
+
executables:
|
26
|
+
- ey_config_local
|
26
27
|
extensions: []
|
27
28
|
|
28
29
|
extra_rdoc_files: []
|
29
30
|
|
30
31
|
files:
|
32
|
+
- bin/ey_config_local
|
33
|
+
- lib/ey_config/local.rb
|
31
34
|
- lib/ey_config/version.rb
|
32
35
|
- lib/ey_config.rb
|
33
36
|
- LICENSE
|
34
37
|
- README.md
|
38
|
+
has_rdoc: true
|
35
39
|
homepage: http://github.com/engineyard/ey_config
|
36
40
|
licenses: []
|
37
41
|
|
@@ -61,7 +65,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
61
65
|
requirements: []
|
62
66
|
|
63
67
|
rubyforge_project:
|
64
|
-
rubygems_version: 1.
|
68
|
+
rubygems_version: 1.5.2
|
65
69
|
signing_key:
|
66
70
|
specification_version: 3
|
67
71
|
summary: Engine Yard Configuration
|