train 3.1.3 → 3.1.4

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: 822b69fa9ee45bff40a62fcce80d792e4605d86d7f55511c289b0bfff86f1d11
4
- data.tar.gz: 2052e5189271479302b9079fafb1ed2b612fe02d876a5e35dd468f407ad62270
3
+ metadata.gz: 0f79287e10225a5c785d6f7da50b8526353c403ae6a02ae39876ba9c0db1b4c5
4
+ data.tar.gz: 417ad3e156ac170850a576e0800698ee38dc915bb00b6164ebc42b732c89010a
5
5
  SHA512:
6
- metadata.gz: 52685bfaa63eb3db6db5c36477c2fad2b272264064f30a6da0c5e59ae419d328a392eaa96bc42a1e2c573cfa86e88ba4a0661d97bb39af21c3fdfd8494cb36c6
7
- data.tar.gz: b30555ac34ee0fcb74ea05e77db4a78a8570424f8d5843911be532f8cd656bb52813b3e11ba5eed404e2d040a817ba2875cb0a78f919d1513ad733e7ab603863
6
+ metadata.gz: 9d0c0fd94a2c1f380ffca4ca64f91ff7a757e29a6abe4ba3fb5569d59df5497b9034529a9f4f85b57f718c8812282b2483b4790c13df3b6fb4215063c663b9e1
7
+ data.tar.gz: 7285fab00c1390dd47a770d0d3c5a8ab5373d681154648efc6df6762ff9abe7092542f15ea7d0455e09879d039eddb8a1478f7d2dfadb280eaac6288df3aaddb
@@ -1,8 +1,13 @@
1
1
  module Train::Platforms::Detect::Helpers
2
2
  module Windows
3
3
  def detect_windows
4
+ check_cmd || check_powershell
5
+ end
6
+
7
+ def check_cmd
4
8
  # try to detect windows, use cmd.exe to also support Microsoft OpenSSH
5
9
  res = @backend.run_command("cmd.exe /c ver")
10
+
6
11
  return false if (res.exit_status != 0) || res.stdout.empty?
7
12
 
8
13
  # if the ver contains `Windows`, we know its a Windows system
@@ -13,16 +18,29 @@ module Train::Platforms::Detect::Helpers
13
18
 
14
19
  # try to extract release from eg. `Microsoft Windows [Version 6.3.9600]`
15
20
  release = /\[(?<name>.*)\]/.match(version)
16
- unless release[:name].nil?
21
+ if release[:name]
17
22
  # release is 6.3.9600 now
18
23
  @platform[:release] = release[:name].downcase.gsub("version", "").strip
19
24
  # fallback, if we are not able to extract the name from wmic later
20
25
  @platform[:name] = "Windows #{@platform[:release]}"
21
26
  end
22
27
 
23
- # try to use wmic, but lets keep it optional
24
28
  read_wmic
29
+ true
30
+ end
25
31
 
32
+ def check_powershell
33
+ command = @backend.run_command(
34
+ "Get-WmiObject Win32_OperatingSystem | Select Caption,Version | ConvertTo-Json"
35
+ )
36
+ return false if (command.exit_status != 0) || command.stdout.empty?
37
+
38
+ payload = JSON.parse(command.stdout)
39
+ @platform[:family] = "windows"
40
+ @platform[:release] = payload["Version"]
41
+ @platform[:name] = payload["Caption"]
42
+
43
+ read_wmic
26
44
  true
27
45
  end
28
46
 
@@ -3,5 +3,5 @@
3
3
  # Author:: Dominik Richter (<dominik.richter@gmail.com>)
4
4
 
5
5
  module Train
6
- VERSION = "3.1.3".freeze
6
+ VERSION = "3.1.4".freeze
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: train
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.3
4
+ version: 3.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dominik Richter
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-09-30 00:00:00.000000000 Z
11
+ date: 2019-10-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json