simple_rails_configurator 0.2.0
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 +7 -0
- data/.gitignore +8 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +21 -0
- data/README.md +43 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/simple_rails_configurator.rb +38 -0
- data/lib/simple_rails_configurator/version.rb +3 -0
- data/simple_rails_configurator.gemspec +25 -0
- metadata +82 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 88552da64ce6fd21302330a6e11ae95535b47fd4
|
4
|
+
data.tar.gz: 60613840c77bf32f68c29ac17c10bb9f174bf9be
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b4426b8fa0b7e6b5b154c4e5b1af0fed2da50e78b8e73854bb09751db816fa528be703907b5ee0267024d0eccca66b382cc70bd06b76cde947ea74e2843c7f3d
|
7
|
+
data.tar.gz: 0d73cc3702d7cc1bffb759d837ce838e456917942b1d76d70e8fcb41c17a883941b5af152a99228add0ed877f28b9cf14b041c6da4114f084ec634c9f2c823d9
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 TODO: Write your name
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# Simple Rails Configurator
|
2
|
+
|
3
|
+
Easily load custom yml configuration files into the Rails environment.
|
4
|
+
|
5
|
+
Features:
|
6
|
+
|
7
|
+
- ERB support
|
8
|
+
- Supports per-environment configurations within loaded files
|
9
|
+
- Injects configurations directly into `Rails.application.config`
|
10
|
+
- Local overrides with `.override` files
|
11
|
+
- Recursive directory traversal
|
12
|
+
|
13
|
+
## Installation
|
14
|
+
|
15
|
+
Add this line to your application's Gemfile:
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
gem 'simple_rails_configurator', :git => 'https://bitbucket.org/apsislabs/simple_rails_configurator.git'
|
19
|
+
```
|
20
|
+
|
21
|
+
And then execute:
|
22
|
+
|
23
|
+
$ bundle install
|
24
|
+
|
25
|
+
Or install it yourself as:
|
26
|
+
|
27
|
+
$ gem install simple_rails_configurator , :git => 'https://bitbucket.org/apsislabs/simple_rails_configurator.git'
|
28
|
+
|
29
|
+
## Usage
|
30
|
+
|
31
|
+
In `environment.rb`, `require` this gem and then add `SimpleRailsConfigurator::configure!('PATH_TO_CUSTOM_CONFIG_DIR')`. The path should be appropriately specified from the Rails root path. All YML/YAML files in the given directory (and subdirectories) will be injected into the Rails configuration object. If you don't pass an argument to `configure!`, the default path is `"#{Rails.root}/config/custom"`.
|
32
|
+
|
33
|
+
To create a local override (parsed only when `Rails.env == 'local' || Rails.env == 'development'`), for the file `foo_config.yml`, create `foo_config.yml.override` next to it. Any values set in this file will override those in `foo_config.yml`.
|
34
|
+
|
35
|
+
Access the imported configurations at `Rails.application.config.filename['config_var']`. Note that at the moment only the base filename is used, so if you have `config/custom/foo.yml` and `config/custom/bar/foo.yml`, only one of them will take effect.
|
36
|
+
|
37
|
+
## Development
|
38
|
+
|
39
|
+
After checking out the repo, run `bin/setup` to install dependencies.
|
40
|
+
|
41
|
+
## License
|
42
|
+
|
43
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "simple_rails_configurator"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
require "simple_rails_configurator/version"
|
2
|
+
|
3
|
+
module SimpleRailsConfigurator
|
4
|
+
def self.configure!(path=nil)
|
5
|
+
path ||= Rails.root.join('config', 'custom')
|
6
|
+
|
7
|
+
files = Dir.glob(File.join(path, '**', '*.{yml,yaml}'))
|
8
|
+
files.each{ |file| configure_from_file(file) }
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.configure_from_file(filename)
|
12
|
+
# TODO: Pass down a path prefix and implement "namespaces" based on location?
|
13
|
+
yaml = load_config_yaml(filename)
|
14
|
+
|
15
|
+
if is_local?
|
16
|
+
override = load_config_yaml("#{filename}.override")
|
17
|
+
yaml.merge!(override)
|
18
|
+
end
|
19
|
+
|
20
|
+
name = File.basename(filename).rpartition('.')[0]
|
21
|
+
Rails.application.config.send("#{name}=".to_sym, yaml)
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.load_config_yaml(filename)
|
25
|
+
if File.exist?(filename)
|
26
|
+
config_erb = ERB.new(File.read(filename))
|
27
|
+
yaml = YAML.load(config_erb.result)
|
28
|
+
|
29
|
+
return yaml[Rails.env] if yaml.key?(Rails.env)
|
30
|
+
return yaml
|
31
|
+
end
|
32
|
+
return {}
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.is_local?
|
36
|
+
Rails.env.development? || Rails.env.local?
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "simple_rails_configurator/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "simple_rails_configurator"
|
8
|
+
spec.version = SimpleRailsConfigurator::VERSION
|
9
|
+
spec.authors = ["Henry Keiter"]
|
10
|
+
spec.email = ["henry@apsis.io"]
|
11
|
+
|
12
|
+
spec.summary = 'Quickly import ERB configs from anywhere.'
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
17
|
+
f.match(%r{^(test|spec|features)/})
|
18
|
+
end
|
19
|
+
spec.bindir = "exe"
|
20
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
|
+
spec.require_paths = ["lib"]
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
24
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: simple_rails_configurator
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Henry Keiter
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-06-12 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.16'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.16'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
description:
|
42
|
+
email:
|
43
|
+
- henry@apsis.io
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- Gemfile
|
50
|
+
- LICENSE.txt
|
51
|
+
- README.md
|
52
|
+
- Rakefile
|
53
|
+
- bin/console
|
54
|
+
- bin/setup
|
55
|
+
- lib/simple_rails_configurator.rb
|
56
|
+
- lib/simple_rails_configurator/version.rb
|
57
|
+
- simple_rails_configurator.gemspec
|
58
|
+
homepage: ''
|
59
|
+
licenses:
|
60
|
+
- MIT
|
61
|
+
metadata: {}
|
62
|
+
post_install_message:
|
63
|
+
rdoc_options: []
|
64
|
+
require_paths:
|
65
|
+
- lib
|
66
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
71
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
requirements: []
|
77
|
+
rubyforge_project:
|
78
|
+
rubygems_version: 2.6.13
|
79
|
+
signing_key:
|
80
|
+
specification_version: 4
|
81
|
+
summary: Quickly import ERB configs from anywhere.
|
82
|
+
test_files: []
|