grande 0.0.4 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/grande/config_loader.rb +12 -44
- data/lib/grande/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1fae0574e0b29e088d81115bd1a39d7a4501b2f4aa720a198c6819c0ad1873db
|
4
|
+
data.tar.gz: 23fbf3ddb5d1e5e98f6c8f2a2b6d78240256ad5adfb398f0c1b69f9cd541e3aa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a6b091758ad17f6ef5ca7cde8e49b28aac601c66ff75088625548b237b0f22d54949d417ba3b83f7d1149610e47ea0f3df678d0e74650d433a8b827a9726c4f5
|
7
|
+
data.tar.gz: 3c2f95eed2828a9d711687284ee0390c926d68f2f331d1b637e6654be00287c452185d08b661fb899d61948b41c8498729406897a0d867086443d2e99dc3e741
|
data/lib/grande/config_loader.rb
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
require '
|
2
|
+
require 'comff'
|
3
3
|
|
4
4
|
class Grande::ConfigLoader
|
5
|
+
attr_reader :comff
|
6
|
+
|
5
7
|
def initialize
|
6
|
-
@
|
8
|
+
@comff = nil
|
7
9
|
|
8
10
|
default_path = File.join(Grande.c.app.root_path, 'config/config.yml')
|
9
11
|
|
@@ -23,51 +25,17 @@ class Grande::ConfigLoader
|
|
23
25
|
end
|
24
26
|
end
|
25
27
|
|
26
|
-
def get_int(
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
end
|
31
|
-
|
32
|
-
def get_int!(key)
|
33
|
-
value = get_int(key)
|
34
|
-
raise "Config key #{key} is required" unless value
|
35
|
-
Integer(value)
|
36
|
-
end
|
37
|
-
|
38
|
-
def get_str(key, default=nil)
|
39
|
-
env_var_name = key_to_env_var_name(key)
|
40
|
-
return ENV[env_var_name] if ENV.key?(env_var_name)
|
41
|
-
|
42
|
-
parts = key.split('.')
|
43
|
-
base_obj = if parts.length == 1
|
44
|
-
@conf
|
45
|
-
else
|
46
|
-
@conf.dig(*parts[0...-1])
|
47
|
-
end
|
48
|
-
|
49
|
-
# binding.pry if key =="redis.url"
|
50
|
-
|
51
|
-
base_obj.fetch(parts.last, default)
|
52
|
-
end
|
53
|
-
|
54
|
-
def get_str!(key)
|
55
|
-
none = Object.new
|
56
|
-
value = get_str(key, none)
|
57
|
-
raise "Config key #{key} is required" if value == none
|
58
|
-
|
59
|
-
value
|
60
|
-
end
|
28
|
+
def get_int(*a, **kw); @comff.get_int(*a, **kw); end
|
29
|
+
def get_int!(*a, **kw); @comff.get_int!(*a, **kw); end
|
30
|
+
def get_str(*a, **kw); @comff.get_str(*a, **kw); end
|
31
|
+
def get_str!(*a, **kw); @comff.get_str!(*a, **kw); end
|
32
|
+
def get_bool(*a, **kw); @comff.get_bool(*a, **kw); end
|
33
|
+
def get_bool!(*a, **kw); @comff.get_bool!(*a, **kw); end
|
61
34
|
|
62
35
|
private
|
63
36
|
|
64
|
-
# Convert key format from foo.bar.qux
|
65
|
-
# into FOO_BAR_QUX
|
66
|
-
def key_to_env_var_name(key)
|
67
|
-
key.split('.').map(&:upcase).join('_')
|
68
|
-
end
|
69
|
-
|
70
37
|
def load_conf_file!(path)
|
71
|
-
|
38
|
+
configuration = File.read(path)
|
39
|
+
@comff = Comff.new(configuration)
|
72
40
|
end
|
73
41
|
end
|
data/lib/grande/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: grande
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- André D. Piske
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-10-02 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: |2
|
14
14
|
Opinionated starting point for creating ruby apps.
|
@@ -49,7 +49,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
49
49
|
- !ruby/object:Gem::Version
|
50
50
|
version: '0'
|
51
51
|
requirements: []
|
52
|
-
rubygems_version: 3.2.
|
52
|
+
rubygems_version: 3.2.28
|
53
53
|
signing_key:
|
54
54
|
specification_version: 4
|
55
55
|
summary: Superpower your small but grande app
|