phobos 1.3.0 → 1.4.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: a091bb89b4a3006aafa88611a19c964697e420f8
4
- data.tar.gz: 55cb3fe0c4c345863109a6687d7c6e8322b030c8
3
+ metadata.gz: 23596037a84092e128accdaee1bd9a8d5e53fe03
4
+ data.tar.gz: 68f30103a2d37881c7eea863b43abc40a75165f6
5
5
  SHA512:
6
- metadata.gz: b35b61fbae213afd28a08f933663129cef50e6adb5ff7fe639e7022cb41153122ceb1e9916c58aa2f2e01a99428756d70dff66f442302c9e57a31dda3ff4817a
7
- data.tar.gz: 8633c0846461ad1c73dda4836adbca1fb4bc9ef270d7e755f54d1b9b2d56f4068510c6ef6b09ba4b743000dec9db76cf11c62ac1cbf78828523054a76299ea3a
6
+ metadata.gz: 1f2cf322b532dd1d17de02b7c3d77b2191edc8817831dc280ac6f011f5ae68a9d776b13907fa22491b1eeb1ec7479cb476d63b8ba2a35b4c3cadd8d26667e6b6
7
+ data.tar.gz: 19071993977bcff9487efdd580c80d1d3959b55841508d9e3be683a5bffd762541521bbdbcd85ce9991f48383ee8c045dd42d790c236df482774122c638d56d3
data/CHANGELOG.md CHANGED
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
4
4
  The format is based on [Keep a Changelog](http://keepachangelog.com/)
5
5
  and this project adheres to [Semantic Versioning](http://semver.org/).
6
6
 
7
+ ## 1.4.0 (2017-08-21)
8
+
9
+ - [enhancement] Add support for hash provided settings #30
10
+
7
11
  ## 1.3.0 (2017-06-15)
8
12
 
9
13
  - [enhancement] Add support for erb syntax in phobos config file #26
@@ -20,7 +24,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
20
24
 
21
25
  ## 1.1.0 (2016-09-02)
22
26
 
23
- - [enhancement] - Removed Hashie as a dependency #12
27
+ - [enhancement] Removed Hashie as a dependency #12
24
28
  - [feature] Allow configuring consumers min_bytes & max_wait_time #15
25
29
  - [feature] Allow configuring producers max_queue_size, delivery_threshold & delivery_interval #16
26
30
  - [feature] Allow configuring force_encoding for message payload #18
data/README.md CHANGED
@@ -248,11 +248,15 @@ MyProducer
248
248
 
249
249
  When running as a standalone service, Phobos sets up a `Listener` and `Executor` for you. When you use Phobos as a library in your own project, you need to set these components up yourself.
250
250
 
251
- First, call the method `configure` with the path of your configuration file
251
+ First, call the method `configure` with the path of your configuration file or with configuration settings hash.
252
252
 
253
253
  ```ruby
254
254
  Phobos.configure('config/phobos.yml')
255
255
  ```
256
+ or
257
+ ```ruby
258
+ Phobos.configure(kafka: { client_id: 'phobos' }, logger: { file: 'log/phobos.log' })
259
+ ```
256
260
 
257
261
  __Listener__ connects to Kafka and acts as your consumer. To create a listener you need a handler class, a topic, and a group id.
258
262
 
@@ -1,3 +1,3 @@
1
1
  module Phobos
2
- VERSION = '1.3.0'
2
+ VERSION = '1.4.0'
3
3
  end
data/lib/phobos.rb CHANGED
@@ -27,9 +27,9 @@ module Phobos
27
27
  attr_reader :config, :logger
28
28
  attr_accessor :silence_log
29
29
 
30
- def configure(yml_path)
30
+ def configure(configuration)
31
31
  ENV['RAILS_ENV'] = ENV['RACK_ENV'] ||= 'development'
32
- @config = DeepStruct.new(YAML.load(ERB.new(File.read(File.expand_path(yml_path))).result))
32
+ @config = DeepStruct.new(fetch_settings(configuration))
33
33
  @config.class.send(:define_method, :producer_hash) { Phobos.config.producer&.to_hash }
34
34
  @config.class.send(:define_method, :consumer_hash) { Phobos.config.consumer&.to_hash }
35
35
  configure_logger
@@ -73,5 +73,13 @@ module Phobos
73
73
  @logger = Logging.logger[self]
74
74
  @logger.appenders = appenders
75
75
  end
76
+
77
+ private
78
+
79
+ def fetch_settings(configuration)
80
+ return configuration.to_h if configuration.respond_to?(:to_h)
81
+
82
+ YAML.load(ERB.new(File.read(File.expand_path(configuration))).result)
83
+ end
76
84
  end
77
85
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: phobos
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Túlio Ornelas
@@ -13,7 +13,7 @@ authors:
13
13
  autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2017-06-15 00:00:00.000000000 Z
16
+ date: 2017-08-21 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: bundler