data_collector 0.63.0 → 0.65.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: 9006d40456c852cf21b98977606ed64c8211a40e9796e94bb7ec07c5837c1b03
4
- data.tar.gz: ab5172a04a592e5a319d95f9e6e4918eb3e6eb3f7783b2583a89428a5145efca
3
+ metadata.gz: 6bd31c29be4fc198e2361e4ecb9a756d28ab38500008e667405d8872666e4180
4
+ data.tar.gz: 610ff475aee7f65b853efbc9acb8e36d79455a7a82826663864dbfe1caaba1a5
5
5
  SHA512:
6
- metadata.gz: 6ff82dcd3e220c5b3ef6d5ffc6719f3c06e90b4aa71490feb0f07c0c4375f16bbddb0e7f80a3a3dd96870b85a018ccd4da091d7acf321141c85b2f9f77043f39
7
- data.tar.gz: c6d4c02d7c93fd4bb90813bcd20285a40dd781ba161e38770ab9ba627609c08ef11cd56bb8a6703030a1573ade7e6a7011e37068a97226ce334947980215d171
6
+ metadata.gz: 50f85f9b0a518698a4aade6604d723162239b7fa4c984f8003c7fd4c76cfd4ff61590299640467da9ebd3df9660a2ab06f20a4c9dd9b665f35cf1a36880aa0c6
7
+ data.tar.gz: d3d0a1684bafa65aff420932270d14688fa9dde69ed1954757ed3e4da382036eb89134e984a55bc7d2a4ee1aad49a652c001fe3932a60c5a86003260cfff7c07
data/README.md CHANGED
@@ -403,7 +403,15 @@ Engine directives:
403
403
  ### Config
404
404
 
405
405
  The config object points to a configuration file (default: "config.yml").
406
-
406
+ - Configuration is automatically reloaded when the file is modified
407
+ - All hash keys are converted to symbols (:key instead of "key")
408
+ - Writing values with []= immediately persists changes to the YAML file
409
+ - The class uses a singleton pattern - you cannot create instances with .new
410
+ - Environment variable substitution uses ${VAR_NAME} syntax in the YAML file
411
+
412
+ ```shell
413
+ export SECRET=my_secret
414
+ ```
407
415
  __Example__ config.yml
408
416
  ```yaml
409
417
  cache: "/tmp"
@@ -22,6 +22,7 @@ module DataCollector
22
22
  end
23
23
 
24
24
  def self.path
25
+ init if @config_file_path.empty?
25
26
  @config_file_path
26
27
  end
27
28
 
@@ -52,6 +53,16 @@ module DataCollector
52
53
  @config.keys
53
54
  end
54
55
 
56
+ def self.raw
57
+ init
58
+ @config
59
+ end
60
+
61
+ def self.dig(*args)
62
+ init
63
+ @config.dig(*args)
64
+ end
65
+
55
66
  def self.init
56
67
  @config_file_name = 'config.yml' if @config_file_name.nil?
57
68
  discover_config_file_path
@@ -66,6 +77,8 @@ module DataCollector
66
77
  end
67
78
 
68
79
  def self.discover_config_file_path
80
+ @config_file_name = ENV['CONFIG_FILE_NAME'] if ENV.key?('CONFIG_FILE_NAME')
81
+
69
82
  if @config_file_path.nil? || @config_file_path.empty?
70
83
  if ENV.key?('CONFIG_FILE_PATH')
71
84
  @config_file_path = ENV['CONFIG_FILE_PATH']
@@ -23,6 +23,8 @@ module DataCollector
23
23
  class Input
24
24
  attr_reader :raw
25
25
 
26
+ HTTP_TIMEOUT = 30 # seconds — connect + read + write
27
+
26
28
  def initialize
27
29
  @logger = Logger.new(STDOUT)
28
30
  end
@@ -104,18 +106,19 @@ module DataCollector
104
106
  HTTP.default_options = HTTP::Options.new(features: { logging: { logger: @logger } })
105
107
  end
106
108
 
107
- http = HTTP
109
+ timeout = options.fetch(:timeout, HTTP_TIMEOUT)
110
+ http = HTTP.timeout(connect: timeout, read: timeout, write: timeout)
108
111
 
109
112
  if options.key?(:user) && options.key?(:password)
110
113
  @logger.debug "Set Basic_auth"
111
114
  user = options[:user]
112
115
  password = options[:password]
113
- http = HTTP.basic_auth(user: user, pass: password)
116
+ http = http.basic_auth(user: user, pass: password)
114
117
  elsif options.key?(:bearer_token)
115
118
  @logger.debug "Set authorization bearer token"
116
119
  bearer = options[:bearer_token]
117
120
  bearer = "Bearer #{bearer}" unless bearer =~ /^Bearer /i
118
- http = HTTP.auth(bearer)
121
+ http = http.auth(bearer)
119
122
  end
120
123
 
121
124
  if options.key?(:cookies)
@@ -126,10 +126,6 @@ module DataCollector
126
126
  output_data.size == 1 &&
127
127
  not((output_data.first.is_a?(Array) || output_data.first.is_a?(Hash)))
128
128
  output_data = output_data.first
129
- # elsif output_data.is_a?(Array) &&
130
- # output_data.size == 1 &&
131
- # (output_data.first.is_a?(Array) || output_data.first.is_a?(Hash))
132
- # output_data = output_data.first
133
129
  end
134
130
 
135
131
  if options.with_indifferent_access.key?('_no_array_with_one_element') &&
@@ -1,4 +1,4 @@
1
1
  # encoding: utf-8
2
2
  module DataCollector
3
- VERSION = "0.63.0"
3
+ VERSION = "0.65.0"
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: data_collector
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.63.0
4
+ version: 0.65.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mehmet Celik
@@ -407,7 +407,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
407
407
  - !ruby/object:Gem::Version
408
408
  version: '0'
409
409
  requirements: []
410
- rubygems_version: 3.6.9
410
+ rubygems_version: 3.7.2
411
411
  specification_version: 4
412
412
  summary: ETL helper library
413
413
  test_files: []