qat-core 6.0.0 → 6.0.3

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: 4ce1a5221f932769e315474fe9d8c71b020859638e64b74bdad9a79ffe6cf0c4
4
- data.tar.gz: 1e68cfa6cfc7dcede5961ad413b4e24f3501a1e89afc8e6c4e165e1b9fcc36b5
3
+ metadata.gz: 26bc48dc55d9f38ee9d748f1021b91b65d99d84f21d6111d7cdcde6ee15202d3
4
+ data.tar.gz: 6cfe5374088db53a11ed39199d57ba706ad7be6cfff15c143a3c0abfb712bdc1
5
5
  SHA512:
6
- metadata.gz: 514f9bf0f5fa12268cd61d61f5dcfdf10143b362834b0e14e03d85fab24c2285c2572768d33bc5df4b7fd6e09502bf709299ca869de8a509b5ca4742d1f6ae88
7
- data.tar.gz: 93c74ce648bbd8e0c639e01ef1a4b4c747e707bcbdeba531929b7657a895234a428c028b30777e1cb5204e6a021cc36f58a7ddec337fd3f4f001fa45e249fb99
6
+ metadata.gz: 536dbe6eeaa841af533ab70f78765c87237a14930f89935c0fefd8c185a614c163ecd19f10f8eefd28df4714f81d1f03f9b7b0d290956340401fe02f8b1e6e45
7
+ data.tar.gz: 50f5968036b97d7cd7adee88513c174f440890c2a08985c7d95c1f2de911cbd12d8a7068020d9b22e8f5c082e70e8e06ec66ca7d20c5e23881691914aaa3a56e
@@ -6,6 +6,6 @@ module QAT
6
6
  # Namespace for QAT Core implementation
7
7
  class Core
8
8
  # Represents QAT's Core version
9
- VERSION = '6.0.0'
9
+ VERSION = '6.0.3'
10
10
  end
11
11
  end
@@ -4,7 +4,7 @@ module QAT
4
4
  class Time
5
5
  module Zone
6
6
  def get_local_tz
7
- TimeZone::Local.get
7
+ TimeZone::Local.get or ActiveSupport::TimeZone['UTC']
8
8
  end
9
9
 
10
10
  extend self
data/lib/qat/time.rb CHANGED
@@ -40,32 +40,32 @@ module QAT
40
40
  #@param method [String] method used for synchronization: +NTP+ or +SSH+.
41
41
  #@param opts [Hash] synchronization options
42
42
  #@return [ActiveSupport::TimeWithZone] Current time
43
- def synchronize(host, method=default_sync_method, opts={})
43
+ def synchronize(host, method = default_sync_method, opts = {})
44
44
  opts ||= {} # opts can be a *nil* when it comes from qat/cucumber
45
- log.info { "Synchronizing with host #{host} using #{method} method" }
45
+ log.info {"Synchronizing with host #{host} using #{method} method"}
46
46
  sync_meth = to_method_name method
47
47
  unless respond_to? sync_meth
48
- log.error { "No synchronize method #{method} defined!" }
48
+ log.error {"No synchronize method #{method} defined!"}
49
49
  raise NotImplementedError.new "No implementation of syncronization using the '#{method}' method"
50
50
  end
51
51
 
52
- host = nil if host.to_s.empty?
52
+ host = nil if host.to_s.empty?
53
53
  local_ips = Socket.ip_address_list.map &:ip_address
54
-
54
+ local_ips << '::1' unless local_ips.include? '::1'
55
55
  dns_timeout = (opts and (opts[:dns_timeout] || opts[:timeout])) || 15
56
56
 
57
57
  Timeout.timeout dns_timeout do
58
58
  if local_ips.include? Resolv.getaddress(host)
59
- log.info { 'Target host is localhost, returning' }
59
+ log.info {'Target host is localhost, returning'}
60
60
  return now
61
61
  end
62
62
  end
63
63
 
64
64
  time_point = self.method(sync_meth).call(log, host, opts)
65
65
  raise ArgumentError.new "Expected the result from #{sync_meth} to be a Time object" unless time_point.is_a? ::Time
66
- log.info { "Synchronizing to #{time_point.strftime '%F %T,%L %z'}" }
66
+ log.info {"Synchronizing to #{time_point.strftime '%F %T,%L %z'}"}
67
67
  Timecop.travel time_point
68
- log.info { "Done!" }
68
+ log.info {"Done!"}
69
69
  now
70
70
  end
71
71
 
@@ -83,7 +83,12 @@ module QAT
83
83
  #
84
84
  #@return [ActiveSupport::TimeWithZone] Current time zone.
85
85
  def zone
86
- self.zone = get_local_tz unless ::Time.zone
86
+ unless ::Time.zone
87
+ ::Time.zone = get_local_tz
88
+ unless ::Time.zone
89
+ ::Time.zone = ActiveSupport::TimeZone['UTC']
90
+ end
91
+ end
87
92
  ::Time.zone
88
93
  end
89
94
 
@@ -93,7 +98,14 @@ module QAT
93
98
  #@return [ActiveSupport::TimeWithZone]
94
99
  #@see zone
95
100
  def zone=(zone)
101
+ if zone.nil?
102
+ zone = ActiveSupport::TimeZone['UTC']
103
+ log.warn "Zone was nil change to UTC"
104
+ end
96
105
  ::Time.zone = zone
106
+ rescue ArgumentError
107
+ log.warn "Zone was nil change to UTC"
108
+ ::Time.zone = ActiveSupport::TimeZone['UTC']
97
109
  end
98
110
 
99
111
  # Returns the current time in the current time zone
@@ -118,6 +130,7 @@ module QAT
118
130
  end
119
131
 
120
132
  private
133
+
121
134
  # Converts a string to a valid method name
122
135
  #
123
136
  #@param meth [String] wannabe method string
@@ -133,7 +146,7 @@ end
133
146
 
134
147
  QAT::Time.sync_for_method 'NTP' do |_, host, opts|
135
148
  require 'net/ntp'
136
- port = opts[:port] || "ntp"
149
+ port = opts[:port] || "ntp"
137
150
  timeout = opts[:dns_timeout] || 3
138
151
  Net::NTP.get(host, port, timeout).time
139
152
  end
@@ -141,11 +154,11 @@ end
141
154
  QAT::Time.sync_for_method 'SSH' do |_, host, options|
142
155
  require 'net/ssh'
143
156
  ssh_opts = options.dup
144
- user = ssh_opts.delete :user
145
- command = ssh_opts.delete(:command) || 'date +%FT%T,%3N%z'
146
- ssh_opts.select! { |opt| Net::SSH::VALID_OPTIONS.include? opt }
157
+ user = ssh_opts.delete :user
158
+ command = ssh_opts.delete(:command) || 'date +%FT%T,%3N%z'
159
+ ssh_opts.select! {|opt| Net::SSH::VALID_OPTIONS.include? opt}
147
160
  ssh_opts[:non_interactive] = true if ssh_opts[:non_interactive].nil?
148
- result = ''
161
+ result = ''
149
162
  Net::SSH.start(host, user, ssh_opts) do |ssh|
150
163
  result = ssh.exec! command
151
164
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qat-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.0.0
4
+ version: 6.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - QAT
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-07-19 00:00:00.000000000 Z
11
+ date: 2019-11-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: qat-logger
@@ -267,10 +267,11 @@ files:
267
267
  - lib/qat/time/zone/windows/tz_data.xml
268
268
  - lib/qat/utils/hash.rb
269
269
  - lib/qat/utils/network.rb
270
- homepage: https://github.com/readiness-it/qat-core
270
+ homepage: https://www.readinessit.com
271
271
  licenses:
272
272
  - GPL-3.0
273
- metadata: {}
273
+ metadata:
274
+ source_code_uri: https://github.com/readiness-it/qat-core
274
275
  post_install_message:
275
276
  rdoc_options: []
276
277
  require_paths:
@@ -286,7 +287,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
286
287
  - !ruby/object:Gem::Version
287
288
  version: '0'
288
289
  requirements: []
289
- rubygems_version: 3.0.4
290
+ rubyforge_project:
291
+ rubygems_version: 2.7.7
290
292
  signing_key:
291
293
  specification_version: 4
292
294
  summary: QAT-Core is QAT's toolkit engine for automating tests.