sb-config 0.3.0 → 0.4.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
2
  SHA256:
3
- metadata.gz: 628110db876f85de4fd98168d840580c1c3aade4d2f8631d51fe9a8d84b57f1b
4
- data.tar.gz: 010e9d52c99e3e187c5c9da530e9ade2829a06d94a5b0cec0a92f99514bb3e5e
3
+ metadata.gz: 1dc6657315d301f7debb157655cb01ae9bca71c0dd1a727ed9f5dddeef480c28
4
+ data.tar.gz: 170d9b431ca873f892c867602adf473c2186587a5220f707da718b3226680975
5
5
  SHA512:
6
- metadata.gz: 2801078134f854e0bcdce6dde470bb9d7d139d3704e41510635f71920b18164aae9191bdf5c9edcab24005935a86ba9a42c2048c4df52a6fbc95f82a05505132
7
- data.tar.gz: d1e12993f9324612acfb9eef3dd12eb14edd9a145f1b0bb8d6d58caef8b031662b8277e92c62854f98870a0bca3d407e9edaec9c343db993ed552f765dba994a
6
+ metadata.gz: a62c856428581c0b4299abe61357a799372f33d56a96731e884cc57944bcefdceeb79b8b0c71da46e30d0d25e91613473002d90b3a8328748e9bcf6dffc0c1e2
7
+ data.tar.gz: eb3fb361e4cf897d9694608fd46c2dbd4d190a529ff6d47808eda4a822e2de017bdda02088bd49ee3e00016d298f84331d36e259a89932da13917c97dc8d5087
@@ -9,6 +9,39 @@ module Sb
9
9
 
10
10
  @@store = {}
11
11
 
12
+ def self.loaded?
13
+ @@store.any?
14
+ end
15
+
16
+ def self.search_and_load
17
+ # this dir, this dir's dir, etc...
18
+ # get working dir
19
+ # load up
20
+ wd = Dir.pwd
21
+
22
+ f1 = File.join wd, 'config/config.json'
23
+ f2 = "~/.sb/config/config.json"
24
+ f3 = ENV['SB_CONFIG_PATH'] || ''
25
+ files = [f1, f2, f3]
26
+ files.each do |f|
27
+ if File.exists?(f)
28
+ self.load(f)
29
+ puts('loaded')
30
+ return true
31
+ end
32
+ end
33
+
34
+ wda = wd.split('/')
35
+ wda.count.times do |t|
36
+ f = File.join(wda[0..-(t + 1)].join('/'), 'config.json')
37
+ if File.exists?(f)
38
+ self.load(f)
39
+ puts('loaded')
40
+ return true
41
+ end
42
+ end
43
+ end
44
+
12
45
  def self.load path, type=nil
13
46
  # infer type if nil
14
47
 
@@ -45,3 +78,15 @@ module Sb
45
78
  end
46
79
  end
47
80
  end
81
+
82
+ Sb::Config.search_and_load
83
+ #puts Sb::Config.loaded?
84
+
85
+ =begin
86
+ bundle config gem
87
+ * go up tree till secrets are found
88
+ check config/config
89
+ check ~/.sb/config/config
90
+ check SB_CONFIG_PATH (=/path/to/config)
91
+ check config
92
+ =end
@@ -1,5 +1,5 @@
1
1
  module Sb
2
2
  module Config
3
- VERSION = "0.3.0"
3
+ VERSION = "0.4.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sb-config
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - iodevel