ey_config 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
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.7"
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,119 +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
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.exists?(full_path)
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.exists?(possible_path)
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
-
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,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ey_config
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
5
- prerelease:
4
+ version: 0.0.8
6
5
  platform: ruby
7
6
  authors:
8
7
  - Jacob Burkhart & Michael Broadhead & others
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2014-03-03 00:00:00.000000000 Z
11
+ date: 2024-03-30 00:00:00.000000000 Z
13
12
  dependencies: []
14
13
  description: Access to additional services for Engine Yard customers.
15
14
  email:
@@ -19,35 +18,32 @@ executables:
19
18
  extensions: []
20
19
  extra_rdoc_files: []
21
20
  files:
21
+ - LICENSE
22
+ - README.md
22
23
  - bin/ey_config_local
24
+ - lib/ey_config.rb
23
25
  - lib/ey_config/local.rb
24
26
  - lib/ey_config/version.rb
25
- - lib/ey_config.rb
26
- - LICENSE
27
- - README.md
28
27
  homepage: http://github.com/engineyard/ey_config
29
28
  licenses: []
29
+ metadata: {}
30
30
  post_install_message:
31
31
  rdoc_options: []
32
32
  require_paths:
33
33
  - lib
34
34
  required_ruby_version: !ruby/object:Gem::Requirement
35
- none: false
36
35
  requirements:
37
- - - ! '>='
36
+ - - ">="
38
37
  - !ruby/object:Gem::Version
39
38
  version: '0'
40
39
  required_rubygems_version: !ruby/object:Gem::Requirement
41
- none: false
42
40
  requirements:
43
- - - ! '>='
41
+ - - ">="
44
42
  - !ruby/object:Gem::Version
45
43
  version: '0'
46
44
  requirements: []
47
- rubyforge_project:
48
- rubygems_version: 1.8.25
45
+ rubygems_version: 3.4.10
49
46
  signing_key:
50
- specification_version: 3
47
+ specification_version: 4
51
48
  summary: Engine Yard Configuration
52
49
  test_files: []
53
- has_rdoc: