simple_rails_configurator 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 88552da64ce6fd21302330a6e11ae95535b47fd4
4
- data.tar.gz: 60613840c77bf32f68c29ac17c10bb9f174bf9be
2
+ SHA256:
3
+ metadata.gz: 9ab9e23067513aee67e5a3b964ab83be8cde94376b8db1db7d52122a04a90dae
4
+ data.tar.gz: ac58c837e56b0555a7c28c891152d4fcf50b091c46bac6a9bbd80980bfc32a34
5
5
  SHA512:
6
- metadata.gz: b4426b8fa0b7e6b5b154c4e5b1af0fed2da50e78b8e73854bb09751db816fa528be703907b5ee0267024d0eccca66b382cc70bd06b76cde947ea74e2843c7f3d
7
- data.tar.gz: 0d73cc3702d7cc1bffb759d837ce838e456917942b1d76d70e8fcb41c17a883941b5af152a99228add0ed877f28b9cf14b041c6da4114f084ec634c9f2c823d9
6
+ metadata.gz: ddfec6707ff1df31b91071b08e7f2f530781ddb42d743d5ab9d505f50cb423861fe5b1982007c9e40f5bd0d2d91a4a81ee7d4e732ef92591e902286eb382fe3c
7
+ data.tar.gz: 98626b47d78bb67f3dfa1c515d2b25bf56af5661d666a5ce48115b79d512febd3d52c03e2087ce5c3d5d9bb86d7ef4f7143a60a3fdc47182408813fd27576c6d
data/.gitignore CHANGED
@@ -6,3 +6,5 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
+
10
+ *Gemfile.lock
@@ -1,3 +1,3 @@
1
1
  module SimpleRailsConfigurator
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -1,18 +1,22 @@
1
- require "simple_rails_configurator/version"
1
+ # frozen_string_literal: true
2
2
 
3
+ require 'simple_rails_configurator/version'
4
+
5
+ # Module for loading environment-specific config from
6
+ # single yaml files
3
7
  module SimpleRailsConfigurator
4
- def self.configure!(path=nil)
8
+ def self.configure!(path = nil)
5
9
  path ||= Rails.root.join('config', 'custom')
6
10
 
7
11
  files = Dir.glob(File.join(path, '**', '*.{yml,yaml}'))
8
- files.each{ |file| configure_from_file(file) }
12
+ files.each { |file| configure_from_file(file) }
9
13
  end
10
14
 
11
15
  def self.configure_from_file(filename)
12
16
  # TODO: Pass down a path prefix and implement "namespaces" based on location?
13
17
  yaml = load_config_yaml(filename)
14
18
 
15
- if is_local?
19
+ if local?
16
20
  override = load_config_yaml("#{filename}.override")
17
21
  yaml.merge!(override)
18
22
  end
@@ -22,17 +26,23 @@ module SimpleRailsConfigurator
22
26
  end
23
27
 
24
28
  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)
29
+ return {} unless File.exist?(filename)
28
30
 
29
- return yaml[Rails.env] if yaml.key?(Rails.env)
30
- return yaml
31
- end
32
- return {}
31
+ config_erb = ERB.new(File.read(filename))
32
+ yaml = safe_load_yaml(config_erb.result)
33
+
34
+ return yaml[Rails.env] if yaml.key?(Rails.env)
35
+
36
+ yaml
33
37
  end
34
38
 
35
- def self.is_local?
39
+ def self.local?
36
40
  Rails.env.development? || Rails.env.local?
37
41
  end
42
+
43
+ def self.safe_load_yaml(filename)
44
+ YAML.safe_load(filename, aliases: true)
45
+ rescue ArgumentError
46
+ YAML.safe_load(filename)
47
+ end
38
48
  end
@@ -20,6 +20,6 @@ Gem::Specification.new do |spec|
20
20
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
21
  spec.require_paths = ["lib"]
22
22
 
23
- spec.add_development_dependency "bundler", "~> 1.16"
23
+ spec.add_development_dependency "bundler", "~> 2"
24
24
  spec.add_development_dependency "rake", "~> 10.0"
25
25
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_rails_configurator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henry Keiter
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-06-12 00:00:00.000000000 Z
11
+ date: 2023-02-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.16'
19
+ version: '2'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.16'
26
+ version: '2'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -74,8 +74,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  requirements: []
77
- rubyforge_project:
78
- rubygems_version: 2.6.13
77
+ rubygems_version: 3.0.3.1
79
78
  signing_key:
80
79
  specification_version: 4
81
80
  summary: Quickly import ERB configs from anywhere.