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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 99f854af250858730eb43878c03ed35d3a7f257c529d75fdcbcddf8e797fb42b
4
- data.tar.gz: e8a8f20f0dccfaa1b7af7568dd5b063573ff45c6e23429cee9d0bdb9af44abe9
3
+ metadata.gz: 1fae0574e0b29e088d81115bd1a39d7a4501b2f4aa720a198c6819c0ad1873db
4
+ data.tar.gz: 23fbf3ddb5d1e5e98f6c8f2a2b6d78240256ad5adfb398f0c1b69f9cd541e3aa
5
5
  SHA512:
6
- metadata.gz: 41880ab13a1a273a27516748329c77103f6b7e875ef958fe0d1e5df8fdd95bba9122bf9e1d8fe4be8a141eefdcf0afa1b34b25e0f85fa4b8a5127f9d94e8246d
7
- data.tar.gz: 290d8dbd69e9236bc803159e0c455f5aa141a49560fa84f936faf5dfafbd4a545960270cd6891f5cbaa56183f4cb8b61fdc556f4ec15506ef03c07f7ad8892f2
6
+ metadata.gz: a6b091758ad17f6ef5ca7cde8e49b28aac601c66ff75088625548b237b0f22d54949d417ba3b83f7d1149610e47ea0f3df678d0e74650d433a8b827a9726c4f5
7
+ data.tar.gz: 3c2f95eed2828a9d711687284ee0390c926d68f2f331d1b637e6654be00287c452185d08b661fb899d61948b41c8498729406897a0d867086443d2e99dc3e741
@@ -1,9 +1,11 @@
1
1
  # frozen_string_literal: true
2
- require 'yaml'
2
+ require 'comff'
3
3
 
4
4
  class Grande::ConfigLoader
5
+ attr_reader :comff
6
+
5
7
  def initialize
6
- @conf = nil
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(key, default=nil)
27
- value = get_str(key)
28
- return default if value == nil
29
- Integer(value)
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
- @conf = YAML.safe_load(File.read(path))
38
+ configuration = File.read(path)
39
+ @comff = Comff.new(configuration)
72
40
  end
73
41
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Grande
4
- VERSION = "0.0.4"
4
+ VERSION = "0.1.1"
5
5
  end
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.0.4
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-06-26 00:00:00.000000000 Z
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.18
52
+ rubygems_version: 3.2.28
53
53
  signing_key:
54
54
  specification_version: 4
55
55
  summary: Superpower your small but grande app