appconfig-rails 0.0.3
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/lib/app_config.rb +29 -0
- metadata +45 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: f79c80fb74476e8367185c5af31733e2bcac13e8e81dacfc8bc08fa3d2fe63f4
|
4
|
+
data.tar.gz: 02f3bf43e8fed64ee016ede87f6ac0a02dc583c4912ceb7abb14397b2542362f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7d48d0e7f45e96c87a79a3a12cf8e099dd87cd26eb34579d42cf29645adbe5d3cf0ea0e5d143771f981a23ee2a9477f9fdfc0459053b4733fa95167d94bbcc2c
|
7
|
+
data.tar.gz: cb5efd32847d4131ca19a2230800fccd2a2571f1fb8d2504c1abe91feeae2ff2c31c197ebde933e1c2fb7e127d509423c45c181737da18b47f4ee9f1dd20c138
|
data/lib/app_config.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
class AppConfig
|
2
|
+
@@env_prefix = nil unless defined?(@@env_prefix)
|
3
|
+
def self.env_prefix
|
4
|
+
@@env_prefix
|
5
|
+
end
|
6
|
+
def self.env_prefix=(value)
|
7
|
+
@@env_prefix = value
|
8
|
+
end
|
9
|
+
|
10
|
+
@@config = nil unless defined?(@@config)
|
11
|
+
def self.config
|
12
|
+
@@config
|
13
|
+
end
|
14
|
+
def self.config=(value)
|
15
|
+
@@config = value
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.[](name, default = nil)
|
19
|
+
ENV.fetch("#{env_prefix}#{name.to_s.upcase.sub('-','_')}", config.respond_to?(:fetch) ? config.fetch(name, default) : nil)
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.method_missing(name, *args, &block)
|
23
|
+
if block_given?
|
24
|
+
self[name, yield(*args)]
|
25
|
+
else
|
26
|
+
self[name, args.first]
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
metadata
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: appconfig-rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.3
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Cristiano Boncompagni
|
8
|
+
- Intersail Engineering Srl
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2020-03-26 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: The gem allows you to set configuration options by a YAML file or by
|
15
|
+
ENV variables. The variables take precedence over YAML options
|
16
|
+
email: cristiano.boncompagni@intersail.it
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- lib/app_config.rb
|
22
|
+
homepage: https://rubygems.org/gems/appconfig-rails
|
23
|
+
licenses:
|
24
|
+
- MIT
|
25
|
+
metadata: {}
|
26
|
+
post_install_message:
|
27
|
+
rdoc_options: []
|
28
|
+
require_paths:
|
29
|
+
- lib
|
30
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
requirements: []
|
41
|
+
rubygems_version: 3.1.2
|
42
|
+
signing_key:
|
43
|
+
specification_version: 4
|
44
|
+
summary: A gem to configure a Rails application by YAML file and/or ENV variables
|
45
|
+
test_files: []
|