eventhub-processor2 1.16.0 → 1.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a2739edbb95a3f9601733c2bde861c8e3503521614fe40f2a0610d4a25c00e92
4
- data.tar.gz: fe134c8b0a783a72bce0cf9c8cad969ee6c924d0de2a531306d6c78390aa2a40
3
+ metadata.gz: 78506dd98d394a48e12d31f9e3548bda5ef44674e4e964bf783a3b0374ee100d
4
+ data.tar.gz: 24f228ec36df83139a4b44d8ac80e51dc60639422f74ebe3713a5eddc7c05c74
5
5
  SHA512:
6
- metadata.gz: fcd107c5823805cf7031c0609d3a8ca2a1dd53e48886477c8ebd3640ad4b59c2b094b8268307510d90d3149e05d7b9b9755dcce1841b5a79dac319c05544b482
7
- data.tar.gz: 2af45eadf2bd6491a6ad2bc59f519ce2045cab9753848b2f45a5f94f3e9848eae7234d9ecd82faae4adcac66e1aa7e2d591633c970c7ed0a66d60fb7e815824d
6
+ metadata.gz: 9b631a080f4e71f3739f2c8ebdc75ea50173493518f623ec0e394bdf42a10c524fadc123c6ad0e4a42b71d5b7cae625d0c58850f47ccbdb7e78eb411870aaa90
7
+ data.tar.gz: c3809dc7e46f87ce03e3ca44c2fb3caec3213d70b85d1e565bdf945f3a5b32b752c85281524a21197e30eb55bb7bd7fe6bfce423f0c0e564da65c30c7d3daefc
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog of EventHub::Processor2
2
2
 
3
+ ## 1.17.0 / 2022-12-21
4
+
5
+ * Ability to load and merge more config file based on a name or a pattern
6
+ * Update dependencies
7
+
3
8
  ## 1.16.0 / 2022-12-18
4
9
 
5
10
  * Updated gem dependencies
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- eventhub-processor2 (1.16.0)
4
+ eventhub-processor2 (1.17.0)
5
5
  bunny (~> 2.20)
6
6
  celluloid (~> 0.18)
7
7
  eventhub-components (~> 0.2)
@@ -12,7 +12,7 @@ GEM
12
12
  specs:
13
13
  amq-protocol (2.3.2)
14
14
  ast (2.4.2)
15
- bunny (2.20.0)
15
+ bunny (2.20.1)
16
16
  amq-protocol (~> 2.3, >= 2.3.1)
17
17
  sorted_set (~> 1, >= 1.0.2)
18
18
  celluloid (0.18.0)
@@ -47,7 +47,7 @@ GEM
47
47
  diff-lcs (>= 1.2.0, < 2.0)
48
48
  rspec-support (~> 3.12.0)
49
49
  rspec-support (3.12.0)
50
- rubocop (1.39.0)
50
+ rubocop (1.40.0)
51
51
  json (~> 2.3)
52
52
  parallel (~> 1.10)
53
53
  parser (>= 3.1.2.1)
@@ -73,9 +73,9 @@ GEM
73
73
  sorted_set (1.0.3)
74
74
  rbtree
75
75
  set (~> 1.0)
76
- standard (1.19.1)
76
+ standard (1.20.0)
77
77
  language_server-protocol (~> 3.17.0.2)
78
- rubocop (= 1.39.0)
78
+ rubocop (= 1.40.0)
79
79
  rubocop-performance (= 1.15.1)
80
80
  timers (4.3.5)
81
81
  unicode-display_width (2.3.0)
@@ -93,7 +93,7 @@ DEPENDENCIES
93
93
  rake (~> 13.0)
94
94
  rspec (~> 3.11)
95
95
  simplecov (~> 0.21)
96
- standard (~> 1.17)
96
+ standard (~> 1.20)
97
97
 
98
98
  BUNDLED WITH
99
99
  2.3.26
data/README.md CHANGED
@@ -181,6 +181,46 @@ Processor2 symbolizes keys and sub-keys from configuration files automatically.
181
181
  database['name']['subname'] # => "value"
182
182
  ```
183
183
 
184
+ Version 1.17 and newer allows you to load and merge more configuration files programmatically. It is expected that load! is called once (implicit during class initialization) and then load_more! zero, one, or multiple times. All additional files loaded with load_more! are hash deep merged into one configuration structure. Exceptions while loading of files will be catched and shown as warnings.
185
+ ```ruby
186
+ # specify a file
187
+ EventHub::Configuration.load_more!(pattern: "config/another_config.json")
188
+
189
+ # specify glob patterns to load multiple files
190
+ EventHub::Configuration.load_more!(pattern: "config/processes/**/*.json")
191
+ EventHub::Configuration.load_more!(pattern: "config/templates/**/*.json")
192
+ ```
193
+ If you have conflicting hashes, the previous settings will be overwritten.
194
+
195
+ 1st file loaded
196
+ ```json
197
+ {
198
+ "test": {
199
+ "a": "a_value",
200
+ "b": "b_value"
201
+ }
202
+ }
203
+ ```
204
+ 2nd file loaded
205
+ ```json
206
+ {
207
+ "test": {
208
+ "b": "another_value"
209
+ }
210
+ }
211
+ ```
212
+
213
+ Final configuration result
214
+ ```json
215
+ {
216
+ "test": {
217
+ "a": "a_value",
218
+ "b": "another_value"
219
+ }
220
+ }
221
+
222
+ ```
223
+
184
224
  ## Development
185
225
 
186
226
  ```
@@ -31,5 +31,5 @@ Gem::Specification.new do |spec|
31
31
  spec.add_development_dependency "rake", "~> 13.0"
32
32
  spec.add_development_dependency "rspec", "~> 3.11"
33
33
  spec.add_development_dependency "simplecov", "~> 0.21"
34
- spec.add_development_dependency "standard", "~> 1.17"
34
+ spec.add_development_dependency "standard", "~> 1.20"
35
35
  end
@@ -79,6 +79,24 @@ module EventHub
79
79
  deep_merge!(@config_data, new_data)
80
80
  end
81
81
 
82
+ # load and merge more configuration files
83
+ def load_more!(args = {})
84
+ return unless args[:pattern]
85
+
86
+ Dir.glob(args[:pattern]).each do |name|
87
+ next if File.directory?(name)
88
+
89
+ begin
90
+ EventHub.logger.info("About to load file [#{name}]...")
91
+ new_data = JSON.parse(File.read(name), symbolize_names: true)
92
+ new_data = new_data[@environment.to_sym]
93
+ deep_merge!(@config_data, new_data)
94
+ rescue => e
95
+ EventHub.logger.warn("Exception while loading file [#{name}]: #{e}")
96
+ end
97
+ end
98
+ end
99
+
82
100
  # Deep merging of hashes
83
101
  # deep_merge by Stefan Rusterholz, see http://www.ruby-forum.com/topic/142809
84
102
  def deep_merge!(target, data)
@@ -1,3 +1,3 @@
1
1
  module EventHub
2
- VERSION = "1.16.0".freeze
2
+ VERSION = "1.17.0".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eventhub-processor2
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.16.0
4
+ version: 1.17.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steiner, Thomas
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-12-19 00:00:00.000000000 Z
11
+ date: 2022-12-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: celluloid
@@ -128,14 +128,14 @@ dependencies:
128
128
  requirements:
129
129
  - - "~>"
130
130
  - !ruby/object:Gem::Version
131
- version: '1.17'
131
+ version: '1.20'
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
- version: '1.17'
138
+ version: '1.20'
139
139
  description: Next generation gem to build ruby based eventhub processor
140
140
  email:
141
141
  - thomas.steiner@ikey.ch