ey_config 0.0.6 → 0.0.8

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 3807b6b7db6e0ff903b5c889843a1ba1add6eace07d1a47cee537488b94f0f3a
4
+ data.tar.gz: 9d2cec32c1310f00deadfd125a17d568291051c02bd8cb1737a1a4deaa9cab22
5
+ SHA512:
6
+ metadata.gz: a3ff1db89b8bef801d88c740ccd85e8adf809ebed770fefa8c6298bd605d2440b74c2bd9dfe168c2b80233f5dd2cb2aa5ee9cbadf5f00bf757ca890f3497417c
7
+ data.tar.gz: fee9fbf5112c864034c6b91bdeae5d082310e9f37f85d9ce6d95fc8497dddd7991ece7ffa2b81b19f455e0344e6890513d06ba620d4c612d5b0c90ef01b51b27
data/LICENSE CHANGED
@@ -1,19 +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
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
19
  THE SOFTWARE.
data/README.md CHANGED
@@ -1,46 +1,46 @@
1
- # Engine Yard Configuration
2
-
3
- Ruby interface to additional services for customers of Engine Yard.
4
-
5
- ## Synopsis
6
-
7
- EY::Config.get(:shared_db_r_us, "db_hostname")
8
-
9
- This will read the value for the `db_hostname` variable, as provided by the `shared_db_r_us` service.
10
-
11
- In local development mode, you won't have access to the service, so you'll want to use `ey_config_local` command-line tool to write out a file at "config/ey_services_config_local.yml".
12
- It's OK to commit this file to your repository. It will be used as a fallback in production in case you haven't activated the `shared_db_r_us` for a given environment.
13
-
14
- See the **Code Snippet** documentation for individual services to see what variables they provide, and common usages.
15
-
16
- ## How it works
17
-
18
- When you deploy your app on Engine Yard cloud, the deployment system (https://github.com/engineyard/engineyard-serverside) will write out the file "config/ey_services_config_deploy.yml".
19
- This file contains all the variables provided to your app, grouped by the Add-ons you have activated.
20
-
21
- `EY::Config.get` will read variables from this file, or fallback to "config/ey_services_config_local.yml", which you should create for running your app in development mode.
22
-
23
- That's it!
24
-
25
- ## Contributing to EY::Config
26
-
27
- * Check out the latest revision from the master branch
28
- * 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
29
- * Fork the project
30
- * Start a feature/bugfix branch
31
- * Commit and push until you are happy with your contribution
32
- * Send a pull request for your branch
33
- * Please add tests for any new code
34
-
35
- ## Releasing
36
-
37
- gem install gem-release
38
- gem bump --tag
39
- gem release
40
-
41
-
42
- ## Copyright
43
-
44
- Copyright (c) 2011, 2012 Engine Yard, Inc. See LICENSE.txt for
45
- further details.
46
-
1
+ # Engine Yard Configuration
2
+
3
+ Ruby interface to additional services for customers of Engine Yard.
4
+
5
+ ## Synopsis
6
+
7
+ EY::Config.get(:shared_db_r_us, "db_hostname")
8
+
9
+ This will read the value for the `db_hostname` variable, as provided by the `shared_db_r_us` service.
10
+
11
+ In local development mode, you won't have access to the service, so you'll want to use `ey_config_local` command-line tool to write out a file at "config/ey_services_config_local.yml".
12
+ It's OK to commit this file to your repository. It will be used as a fallback in production in case you haven't activated the `shared_db_r_us` for a given environment.
13
+
14
+ See the **Code Snippet** documentation for individual services to see what variables they provide, and common usages.
15
+
16
+ ## How it works
17
+
18
+ When you deploy your app on Engine Yard cloud, the deployment system (https://github.com/engineyard/engineyard-serverside) will write out the file "config/ey_services_config_deploy.yml".
19
+ This file contains all the variables provided to your app, grouped by the Add-ons you have activated.
20
+
21
+ `EY::Config.get` will read variables from this file, or fallback to "config/ey_services_config_local.yml", which you should create for running your app in development mode.
22
+
23
+ That's it!
24
+
25
+ ## Contributing to EY::Config
26
+
27
+ * Check out the latest revision from the master branch
28
+ * 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
29
+ * Fork the project
30
+ * Start a feature/bugfix branch
31
+ * Commit and push until you are happy with your contribution
32
+ * Send a pull request for your branch
33
+ * Please add tests for any new code
34
+
35
+ ## Releasing
36
+
37
+ gem install gem-release
38
+ gem bump --tag
39
+ gem release
40
+
41
+
42
+ ## Copyright
43
+
44
+ Copyright (c) 2011, 2012 Engine Yard, Inc. See LICENSE.txt for
45
+ further details.
46
+
data/bin/ey_config_local CHANGED
@@ -1,15 +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}."
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}."
@@ -1,36 +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
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
@@ -1,5 +1,5 @@
1
- module EY
2
- class Config
3
- VERSION = "0.0.6"
4
- end
5
- end
1
+ module EY
2
+ class Config
3
+ VERSION = "0.0.8" # AI-GEN - cursor
4
+ end
5
+ end
data/lib/ey_config.rb CHANGED
@@ -1,110 +1,119 @@
1
- require File.expand_path('../ey_config/local', __FILE__)
2
-
3
- module EY
4
- class Config
5
- class << self
6
- DEPLOYED_CONFIG_PATH = 'config/ey_services_config_deploy.yml'
7
- PATHS_TO_CHECK = [DEPLOYED_CONFIG_PATH, EY::Config::Local.config_path]
8
-
9
- def config_path=(val)
10
- @full_path = nil
11
- @config_paths = [val]
12
- end
13
-
14
- def config_paths
15
- @config_paths ||= PATHS_TO_CHECK
16
- end
17
-
18
- def full_path
19
- @full_path ||= find_config(config_paths)
20
- end
21
-
22
- def init
23
- unless File.exists?(full_path)
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
33
- end
34
- @config = YAML.load_file(full_path)
35
- unless valid_structure?(@config)
36
- ey_config_empty_warning(full_path, @config)
37
- end
38
- end
39
-
40
- def get(*args)
41
- @args = args
42
- init unless @config
43
- hash = @config.dup
44
- args.each do |arg|
45
- hash = hash[arg.to_s] if hash
46
- end
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
58
- end
59
-
60
- private
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
-
79
- def ey_config_local_usage
80
- @args ||= []
81
-
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 ''
88
- end
89
-
90
- def find_config(config_paths)
91
- possible_paths = []
92
- config_paths.each do |config_path|
93
- possible_path = File.expand_path(config_path)
94
- possible_paths << possible_path
95
- if File.exists?(possible_path)
96
- return possible_path
97
- end
98
- end
99
- raise ArgumentError, "Expected to find EY::Config YAML file at one of: #{possible_paths.inspect}"
100
- end
101
-
102
- def valid_structure?(config)
103
- config == {} or
104
- (config.respond_to?(:has_key?) and
105
- config.values.first.respond_to?(:has_key?))
106
- end
107
- end
108
- end
109
- end
110
-
1
+ require File.expand_path('../ey_config/local', __FILE__)
2
+
3
+ module EY
4
+ class Config
5
+ class << self
6
+ DEPLOYED_CONFIG_PATH = 'config/ey_services_config_deploy.yml'
7
+ PATHS_TO_CHECK = [DEPLOYED_CONFIG_PATH, EY::Config::Local.config_path]
8
+
9
+ def config
10
+ @config || init
11
+ end
12
+
13
+ def config_path=(val)
14
+ @full_path = nil
15
+ @config_paths = [val]
16
+ end
17
+
18
+ def config_paths
19
+ @config_paths ||= PATHS_TO_CHECK
20
+ end
21
+
22
+ def full_path
23
+ @full_path ||= find_config(config_paths)
24
+ end
25
+
26
+ def init
27
+ unless File.exist?(full_path) # AI-GEN - cursor
28
+ err_msg = ""
29
+ if detected_a_dev_environment?
30
+ ey_config_local_usage
31
+ err_msg = "Expected to find EY::Config YAML file at: #{EY::Config::Local.config_path}"
32
+ else
33
+ err_msg = "Expected to find EY::Config YAML file at: #{DEPLOYED_CONFIG_PATH}"
34
+ end
35
+ warn err_msg
36
+ raise ArgumentError, err_msg
37
+ end
38
+ begin
39
+ YAML
40
+ rescue
41
+ require 'yaml'
42
+ end
43
+ @config = YAML.load_file(full_path)
44
+ unless valid_structure?(config)
45
+ ey_config_empty_warning(full_path, config)
46
+ end
47
+ @config
48
+ end
49
+
50
+ def get(*args)
51
+ @args = args
52
+ hash = config.dup
53
+ args.each do |arg|
54
+ hash = hash[arg.to_s] if hash
55
+ end
56
+ if hash.nil?
57
+ err_message = "No config found for #{args.inspect}. "
58
+ if detected_a_dev_environment?
59
+ err_message += "You can put development/fallback configs in: #{EY::Config::Local.config_path}"
60
+ else
61
+ err_message += "Activate the services that provides '#{args.first}' or remove the code that uses it."
62
+ end
63
+ warn err_message
64
+ raise ArgumentError, err_message
65
+ end
66
+ hash.freeze
67
+ end
68
+
69
+ private
70
+
71
+ def detected_a_dev_environment?
72
+ env = ENV['RAILS_ENV'] || ENV['RACK_ENV']
73
+ !env || env.to_s.match(/test|development/i)
74
+ end
75
+
76
+ def warn(arg)
77
+ STDERR.puts arg
78
+ end
79
+
80
+ def ey_config_empty_warning(full_path, config)
81
+ warn ''
82
+ warn "*" * 80
83
+ warn " Expected YAML file at: #{full_path} to contain a hash of hashes, got: #{config.inspect}"
84
+ warn "*" * 80
85
+ warn ''
86
+ end
87
+
88
+ def ey_config_local_usage
89
+ @args ||= []
90
+
91
+ warn ''
92
+ warn "*" * 80
93
+ warn " To generate a config file for local development, run the following:"
94
+ warn " $ ey_config_local #{@args.join(' ')}"
95
+ warn "*" * 80
96
+ warn ''
97
+ end
98
+
99
+ def find_config(config_paths)
100
+ possible_paths = []
101
+ config_paths.each do |config_path|
102
+ possible_path = File.expand_path(config_path)
103
+ possible_paths << possible_path
104
+ if File.exist?(possible_path) # AI-GEN - cursor
105
+ return possible_path
106
+ end
107
+ end
108
+ raise ArgumentError, "Expected to find EY::Config YAML file at one of: #{possible_paths.inspect}"
109
+ end
110
+
111
+ def valid_structure?(config)
112
+ config == {} or
113
+ (config.respond_to?(:has_key?) and
114
+ config.values.first.respond_to?(:has_key?))
115
+ end
116
+ end
117
+ end
118
+ end
119
+
metadata CHANGED
@@ -1,71 +1,49 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: ey_config
3
- version: !ruby/object:Gem::Version
4
- hash: 19
5
- prerelease:
6
- segments:
7
- - 0
8
- - 0
9
- - 6
10
- version: 0.0.6
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.8
11
5
  platform: ruby
12
- authors:
6
+ authors:
13
7
  - Jacob Burkhart & Michael Broadhead & others
14
8
  autorequire:
15
9
  bindir: bin
16
10
  cert_chain: []
17
-
18
- date: 2012-05-14 00:00:00 Z
11
+ date: 2024-03-30 00:00:00.000000000 Z
19
12
  dependencies: []
20
-
21
13
  description: Access to additional services for Engine Yard customers.
22
- email:
14
+ email:
23
15
  - jacob@engineyard.com
24
- executables:
16
+ executables:
25
17
  - ey_config_local
26
18
  extensions: []
27
-
28
19
  extra_rdoc_files: []
29
-
30
- files:
20
+ files:
21
+ - LICENSE
22
+ - README.md
31
23
  - bin/ey_config_local
24
+ - lib/ey_config.rb
32
25
  - lib/ey_config/local.rb
33
26
  - lib/ey_config/version.rb
34
- - lib/ey_config.rb
35
- - LICENSE
36
- - README.md
37
27
  homepage: http://github.com/engineyard/ey_config
38
28
  licenses: []
39
-
29
+ metadata: {}
40
30
  post_install_message:
41
31
  rdoc_options: []
42
-
43
- require_paths:
32
+ require_paths:
44
33
  - lib
45
- required_ruby_version: !ruby/object:Gem::Requirement
46
- none: false
47
- requirements:
34
+ required_ruby_version: !ruby/object:Gem::Requirement
35
+ requirements:
48
36
  - - ">="
49
- - !ruby/object:Gem::Version
50
- hash: 3
51
- segments:
52
- - 0
53
- version: "0"
54
- required_rubygems_version: !ruby/object:Gem::Requirement
55
- none: false
56
- requirements:
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ required_rubygems_version: !ruby/object:Gem::Requirement
40
+ requirements:
57
41
  - - ">="
58
- - !ruby/object:Gem::Version
59
- hash: 3
60
- segments:
61
- - 0
62
- version: "0"
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
63
44
  requirements: []
64
-
65
- rubyforge_project:
66
- rubygems_version: 1.8.10
45
+ rubygems_version: 3.4.10
67
46
  signing_key:
68
- specification_version: 3
47
+ specification_version: 4
69
48
  summary: Engine Yard Configuration
70
49
  test_files: []
71
-