hookworm-base 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/hookworm/base/version.rb +1 -1
- data/lib/hookworm/base.rb +5 -0
- data/lib/hookworm/config.rb +20 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7dfa1ddd5cd53f1277f44e7fce0928de3df975db
|
4
|
+
data.tar.gz: 11479ee035a20330f503a30168d4a01b73d81b17
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f92fad13d8b48922083513b157f75eddc42cdaa0b89709bc743de9e6643d19d39af45911c18b4008cd7ef028856723ab2200af3eb4a419eb948e41b92bd1d107
|
7
|
+
data.tar.gz: 77a05a682c165134ff4219435bb91881b32b95beb06d70d05a18074390e68eb9d62fa4b27e852bfc939dd8052fb5f255ff63a5ad94050c98f634cfc4a75285c5
|
data/lib/hookworm/base.rb
CHANGED
@@ -21,6 +21,11 @@ module Hookworm
|
|
21
21
|
private
|
22
22
|
|
23
23
|
def configure
|
24
|
+
if cfg_disabled?
|
25
|
+
log.info { 'Not configuring!' }
|
26
|
+
return
|
27
|
+
end
|
28
|
+
|
24
29
|
@cfg = JSON.parse(input_stream.read, symbolize_names: true)
|
25
30
|
File.open(cfg_file, 'w') do |f|
|
26
31
|
f.puts JSON.pretty_generate(@cfg)
|
data/lib/hookworm/config.rb
CHANGED
@@ -1,8 +1,13 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'net/http'
|
3
|
+
|
1
4
|
module Hookworm
|
2
5
|
module Config
|
3
6
|
private
|
4
7
|
|
5
8
|
def cfg
|
9
|
+
return {} if cfg_disabled?
|
10
|
+
return http_cfg if http_cfg_available?
|
6
11
|
@cfg ||= JSON.parse(File.read(cfg_file), symbolize_names: true)
|
7
12
|
end
|
8
13
|
|
@@ -10,5 +15,20 @@ module Hookworm
|
|
10
15
|
File.join(ENV['HOOKWORM_WORKING_DIR'] || Dir.pwd,
|
11
16
|
"#{File.basename($PROGRAM_NAME)}.cfg.json")
|
12
17
|
end
|
18
|
+
|
19
|
+
def http_cfg
|
20
|
+
@http_cfg ||= JSON.parse(
|
21
|
+
Net::HTTP.get_response(URI(ENV['HOOKWORM_HTTP_CFG'])).body,
|
22
|
+
symbolize_names: true
|
23
|
+
)
|
24
|
+
end
|
25
|
+
|
26
|
+
def cfg_disabled?
|
27
|
+
!!ENV['HOOKWORM_DISABLE_CFG']
|
28
|
+
end
|
29
|
+
|
30
|
+
def http_cfg_available?
|
31
|
+
!!ENV['HOOKWORM_HTTP_CFG']
|
32
|
+
end
|
13
33
|
end
|
14
34
|
end
|