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 +4 -4
- data/lib/sb/config.rb +45 -0
- data/lib/sb/config/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1dc6657315d301f7debb157655cb01ae9bca71c0dd1a727ed9f5dddeef480c28
|
4
|
+
data.tar.gz: 170d9b431ca873f892c867602adf473c2186587a5220f707da718b3226680975
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a62c856428581c0b4299abe61357a799372f33d56a96731e884cc57944bcefdceeb79b8b0c71da46e30d0d25e91613473002d90b3a8328748e9bcf6dffc0c1e2
|
7
|
+
data.tar.gz: eb3fb361e4cf897d9694608fd46c2dbd4d190a529ff6d47808eda4a822e2de017bdda02088bd49ee3e00016d298f84331d36e259a89932da13917c97dc8d5087
|
data/lib/sb/config.rb
CHANGED
@@ -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
|
data/lib/sb/config/version.rb
CHANGED