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 +4 -4
- data/lib/train/platforms/detect/helpers/os_windows.rb +20 -2
- data/lib/train/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0f79287e10225a5c785d6f7da50b8526353c403ae6a02ae39876ba9c0db1b4c5
|
4
|
+
data.tar.gz: 417ad3e156ac170850a576e0800698ee38dc915bb00b6164ebc42b732c89010a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
|
data/lib/train/version.rb
CHANGED
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.
|
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
|
11
|
+
date: 2019-10-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|