process_settings 0.11.0.pre.4 → 0.11.0.pre.5

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: 00cb781d3385028324b7dd6f55e12da7550901107adf78ee57abde78987335b4
4
- data.tar.gz: b8ae66252379583f2ac9a8da599e54d559fbd92d4d40b12d36faa6539114e511
3
+ metadata.gz: ada8f710e24244a34005a22536e106cf086863b110d1908f58503df01797dedb
4
+ data.tar.gz: ae8fa6f78f2d4894a81f4e806b8408790520c38b0a19df723fe4a572eb3ffea4
5
5
  SHA512:
6
- metadata.gz: c0229a56f9a6e8f6fe20fa0b19cdb82f2df4d82dbd3abd0c7d74cd0b136200e7ac48a261252b60fcd467f6b0c8a8967e8b62e6237f8cf737d871edbc8c0db189
7
- data.tar.gz: 528650ea37e3fa716b588d76d5cef31af6e06e6d5fd506b4f7b65f13d51e38fd45a3f65a3c004cff0e294df47ec9397c29870dd26cdba0ea05ec5b80ef21bb3e
6
+ metadata.gz: 5f58df6d01c42db7ec61b2c2815d3fdbe9cc8552e754edcad4e40a63816bbb6a621290acf2c0c636f87902e8fc10f28fc5330e4fd7250f8755e7d4c22f090304
7
+ data.tar.gz: 5a9ef3528655fbe57d3d23d9a2714fdc3223f9cc7234237cd20beb0f26891571f444d5a325bc2df1d9bfbff8e117b67ad769c797b2033c838c88064dc1bb567c
@@ -3,6 +3,7 @@
3
3
  require 'active_support'
4
4
  require 'listen'
5
5
  require 'psych'
6
+ require 'active_support/deprecation'
6
7
 
7
8
  require 'process_settings/abstract_monitor'
8
9
  require 'process_settings/targeted_settings'
@@ -20,32 +21,40 @@ module ProcessSettings
20
21
  @untargeted_settings = nil
21
22
  @last_untargetted_settings = nil
22
23
 
23
- start
24
+ start_internal(enable_listen_thread?)
24
25
  end
25
26
 
26
- # starts listening for changes
27
- # Note: This method creates a new thread that will be monitoring for changes
28
- # do to the nature of how the Listen gem works, there is no record of
29
- # existing threads, calling this mutliple times will result in spinning off
30
- # multiple listen threads and will have unknow effects
31
27
  def start
32
- path = File.dirname(file_path)
33
-
34
- # to eliminate any race condition:
35
- # 1. set up file watcher
36
- # 2. start it (this should trigger if any changes have been made since (1))
37
- # 3. load the file
28
+ start_internal(enable_listen_thread?)
29
+ end
30
+ deprecate :start, deprecator: ActiveSupport::Deprecation.new('1.0', 'ProcessSettings') # will become private
38
31
 
39
- @listener = file_change_notifier.to(path) do |modified, added, _removed|
40
- if modified.include?(file_path) || added.include?(file_path)
41
- logger.info("ProcessSettings::Monitor file #{file_path} changed. Reloading.")
42
- load_untargeted_settings
32
+ private
43
33
 
44
- load_statically_targeted_settings
34
+ # optionally starts listening for changes, then loads current settings
35
+ # Note: If with_listen_thread is truthy, this method creates a new thread that will be
36
+ # monitoring for changes.
37
+ # Due to how the Listen gem works, there is no record of
38
+ # existing threads; calling this multiple times will result in spinning off
39
+ # multiple listen threads and will have unknown effects.
40
+ def start_internal(with_listen_thread)
41
+ if with_listen_thread
42
+ path = File.dirname(file_path)
43
+
44
+ # to eliminate any race condition:
45
+ # 1. set up file watcher
46
+ # 2. start it (this should trigger if any changes have been made since (1))
47
+ # 3. load the file
48
+
49
+ @listener = file_change_notifier.to(path) do |modified, added, _removed|
50
+ if modified.include?(file_path) || added.include?(file_path)
51
+ logger.info("ProcessSettings::Monitor file #{file_path} changed. Reloading.")
52
+ load_untargeted_settings
53
+
54
+ load_statically_targeted_settings
55
+ end
45
56
  end
46
- end
47
57
 
48
- if enable_listen_thread?
49
58
  @listener.start
50
59
  end
51
60
 
@@ -75,10 +84,10 @@ module ProcessSettings
75
84
  end
76
85
  end
77
86
 
78
- private
79
-
80
87
  def service_env
81
- (defined?(Rails) && Rails.env) || ENV['SERVICE_ENV']
88
+ if defined?(Rails) && Rails.respond_to(:env)
89
+ Rails.env
90
+ end || ENV['SERVICE_ENV']
82
91
  end
83
92
 
84
93
  # Loads the most recent settings from disk
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ProcessSettings
4
- VERSION = '0.11.0.pre.4'
4
+ VERSION = '0.11.0.pre.5'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: process_settings
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.0.pre.4
4
+ version: 0.11.0.pre.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Invoca