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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: db2ca1e5e40bca46760aa032b053cffaf57be4cf
4
- data.tar.gz: 800a4b5c1b3def984e054891a89017ff2af03b42
3
+ metadata.gz: 7dfa1ddd5cd53f1277f44e7fce0928de3df975db
4
+ data.tar.gz: 11479ee035a20330f503a30168d4a01b73d81b17
5
5
  SHA512:
6
- metadata.gz: d9bddc068e605ab7a09b02a263f978953dad1a05bc92e2c1aeeb8de265603c6ddd12a9c05ea7f846126b7138089fb07d45b7df633b162cb64100806d0f9bde30
7
- data.tar.gz: 1c3f8e644d4cf98c8fc9e3cd23744fe7553346ff213d7ed2d882603243e7a465c07de990c246558548af8cf831770162934a6993b094d7df7bc5588614004a56
6
+ metadata.gz: f92fad13d8b48922083513b157f75eddc42cdaa0b89709bc743de9e6643d19d39af45911c18b4008cd7ef028856723ab2200af3eb4a419eb948e41b92bd1d107
7
+ data.tar.gz: 77a05a682c165134ff4219435bb91881b32b95beb06d70d05a18074390e68eb9d62fa4b27e852bfc939dd8052fb5f255ff63a5ad94050c98f634cfc4a75285c5
@@ -1,5 +1,5 @@
1
1
  module Hookworm
2
2
  module Base
3
- VERSION = '0.2.1'
3
+ VERSION = '0.3.0'
4
4
  end
5
5
  end
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)
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hookworm-base
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Buch