train 1.4.35 → 1.4.37

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: 893a9b5ce2710681b1d4bd795661244d5a7148bbd4ec265b607fc4241394e999
4
- data.tar.gz: 0500f6af3195b846c025afb818ad939cbf9592e28002a6093c0ced0e75851604
3
+ metadata.gz: 2ce75bd50237ced9c7c0c00176b234c15d8f19f1a2e8be7e540552c0ce215ad4
4
+ data.tar.gz: 1ededc00e30dbbc3aeb955d317b864d798e45aa73dbbc96e65ad0fd6075ff453
5
5
  SHA512:
6
- metadata.gz: f5bfe0c9737ad2db256d5e7b9434afa0eb8013e47417bfe2d9feaf858c8518f06592f3eab7081d47beb64847c0f876727fd83935cac5eeb2f804a142112d8ed0
7
- data.tar.gz: 2da5c3b0c40fb01b7f999cc56a2f5f0c0c15afc5db513f6574421197dbe5ec26d2ab7f69f13d2107f785421a89d80fefb35aeee3d26747d3f7bc0e8bbc93f521
6
+ metadata.gz: 242b6ec10cce928d6c4f99da4a1f362e13050fc92a9bcf7571d768da760dd78f348329167efb14e77b74bb03b1ba5fddbd13f5ab6a09d81b6c972dd038cce33a
7
+ data.tar.gz: 6e21cd50aa5fb11e25398878a1ed6386e7e9068cd008c6f9fb1919616cc623d641bf51d1c0340b2d73f70425869771448b2e865b459e7537d836586f6d0d5a32
@@ -1,27 +1,33 @@
1
- <!-- latest_release 1.4.35 -->
2
- ## [v1.4.35](https://github.com/inspec/train/tree/v1.4.35) (2018-08-23)
1
+ <!-- latest_release 1.4.37 -->
2
+ ## [v1.4.37](https://github.com/inspec/train/tree/v1.4.37) (2018-09-13)
3
3
 
4
4
  #### Merged Pull Requests
5
- - Adds connection to Graph RBAC API [#327](https://github.com/inspec/train/pull/327) ([r-fennell](https://github.com/r-fennell))
5
+ - Add a export method for platforms [#347](https://github.com/inspec/train/pull/347) ([jquick](https://github.com/jquick))
6
6
  <!-- latest_release -->
7
7
 
8
- <!-- release_rollup since=1.4.31 -->
9
- ### Changes since 1.4.31 release
8
+ <!-- release_rollup since=1.4.35 -->
9
+ ### Changes since 1.4.35 release
10
10
 
11
11
  #### Merged Pull Requests
12
- - Adds connection to Graph RBAC API [#327](https://github.com/inspec/train/pull/327) ([r-fennell](https://github.com/r-fennell)) <!-- 1.4.35 -->
13
- - Fixes failing test when you have a cred file [#343](https://github.com/inspec/train/pull/343) ([dmccown](https://github.com/dmccown)) <!-- 1.4.34 -->
14
- - Modify Cisco UUID detection to use processor ID [#342](https://github.com/inspec/train/pull/342) ([jerryaldrichiii](https://github.com/jerryaldrichiii)) <!-- 1.4.33 -->
15
- - Ensure unique_identifier returns something meaningful for service acc… [#338](https://github.com/inspec/train/pull/338) ([skpaterson](https://github.com/skpaterson)) <!-- 1.4.32 -->
12
+ - Add a export method for platforms [#347](https://github.com/inspec/train/pull/347) ([jquick](https://github.com/jquick)) <!-- 1.4.37 -->
13
+ - Rescues SystemCallError instead of Errno [#346](https://github.com/inspec/train/pull/346) ([dmccown](https://github.com/dmccown)) <!-- 1.4.36 -->
16
14
  <!-- release_rollup -->
17
15
 
18
16
  <!-- latest_stable_release -->
17
+ ## [v1.4.35](https://github.com/inspec/train/tree/v1.4.35) (2018-08-23)
18
+
19
+ #### Merged Pull Requests
20
+ - Ensure unique_identifier returns something meaningful for service acc… [#338](https://github.com/inspec/train/pull/338) ([skpaterson](https://github.com/skpaterson))
21
+ - Modify Cisco UUID detection to use processor ID [#342](https://github.com/inspec/train/pull/342) ([jerryaldrichiii](https://github.com/jerryaldrichiii))
22
+ - Fixes failing test when you have a cred file [#343](https://github.com/inspec/train/pull/343) ([dmccown](https://github.com/dmccown))
23
+ - Adds connection to Graph RBAC API [#327](https://github.com/inspec/train/pull/327) ([r-fennell](https://github.com/r-fennell))
24
+ <!-- latest_stable_release -->
25
+
19
26
  ## [v1.4.31](https://github.com/inspec/train/tree/v1.4.31) (2018-08-17)
20
27
 
21
28
  #### Merged Pull Requests
22
29
  - Fixes an issue where the credential file was nil [#337](https://github.com/inspec/train/pull/337) ([dmccown](https://github.com/dmccown))
23
30
  - Enable using rubygems as plugins [#335](https://github.com/inspec/train/pull/335) ([clintoncwolfe](https://github.com/clintoncwolfe))
24
- <!-- latest_stable_release -->
25
31
 
26
32
  ## [v1.4.29](https://github.com/inspec/train/tree/v1.4.29) (2018-08-15)
27
33
 
@@ -24,6 +24,12 @@ module Train::Platforms
24
24
  def families
25
25
  @families ||= {}
26
26
  end
27
+
28
+ # Clear all platform settings. Only used for testing.
29
+ def __reset
30
+ @list = {}
31
+ @families = {}
32
+ end
27
33
  end
28
34
 
29
35
  # Create or update a platform
@@ -81,4 +87,16 @@ module Train::Platforms
81
87
  print_children(obj, pad + 2) if defined?(obj.children) && !obj.children.nil?
82
88
  end
83
89
  end
90
+
91
+ def self.export
92
+ export = []
93
+ list.each do |name, platform|
94
+ platform.find_family_hierarchy
95
+ export << {
96
+ name: name,
97
+ families: platform.family_hierarchy,
98
+ }
99
+ end
100
+ export.sort_by { |platform| platform[:name] }
101
+ end
84
102
  end
@@ -22,6 +22,14 @@ module Train::Platforms
22
22
  @families.collect { |k, _v| k.name }
23
23
  end
24
24
 
25
+ def find_family_hierarchy(platform = self)
26
+ families = platform.families.each_with_object([]) do |(k, _v), memo|
27
+ memo << k.name
28
+ memo << find_family_hierarchy(k) unless k.families.empty?
29
+ end
30
+ @family_hierarchy = families.flatten
31
+ end
32
+
25
33
  def family
26
34
  @platform[:family] || @family_hierarchy[0]
27
35
  end
@@ -81,20 +81,13 @@ class Train::Plugins::Transport
81
81
  plat = Train::Platforms.name(name)
82
82
  plat.backend = self
83
83
  plat.platform = platform_details unless platform_details.nil?
84
- plat.family_hierarchy = family_hierarchy(plat).flatten
84
+ plat.find_family_hierarchy
85
85
  plat.add_platform_methods
86
86
  plat
87
87
  end
88
88
 
89
89
  alias direct_platform force_platform!
90
90
 
91
- def family_hierarchy(plat)
92
- plat.families.each_with_object([]) do |(k, _v), memo|
93
- memo << k.name
94
- memo << family_hierarchy(k) unless k.families.empty?
95
- end
96
- end
97
-
98
91
  # Get information on the operating system which this transport connects to.
99
92
  #
100
93
  # @return [Platform] system information
@@ -164,7 +164,7 @@ module Train::Transports
164
164
  begin
165
165
  TCPSocket.new('localhost', port).close
166
166
  true
167
- rescue Errno::ECONNREFUSED, Errno::EHOSTUNREACH
167
+ rescue SystemCallError
168
168
  false
169
169
  end
170
170
  end
@@ -77,7 +77,7 @@ class Train::Transports::Mock
77
77
  value = { name: 'mock', family: 'mock', release: 'unknown', arch: 'unknown' }.merge(value)
78
78
 
79
79
  platform = Train::Platforms.name(value[:name])
80
- platform.family_hierarchy = family_hierarchy(platform).flatten
80
+ platform.find_family_hierarchy
81
81
  platform.platform = value
82
82
  platform.add_platform_methods
83
83
  @platform = platform
@@ -3,5 +3,5 @@
3
3
  # Author:: Dominik Richter (<dominik.richter@gmail.com>)
4
4
 
5
5
  module Train
6
- VERSION = '1.4.35'.freeze
6
+ VERSION = '1.4.37'.freeze
7
7
  end
@@ -61,6 +61,12 @@ describe 'platform' do
61
61
  plat.families.values[0].must_equal({ arch: '= x86_64' })
62
62
  end
63
63
 
64
+ it 'finds family hierarchy' do
65
+ plat = Train::Platforms.name('linux')
66
+ plat.find_family_hierarchy
67
+ plat.family_hierarchy.must_equal ['linux', 'unix', 'os']
68
+ end
69
+
64
70
  it 'return direct families' do
65
71
  plat = mock_platform_family('mock')
66
72
  plat.in_family('mock2')
@@ -39,4 +39,14 @@ describe 'platforms' do
39
39
  top = Train::Platforms.top_platforms
40
40
  top.count.must_equal(1)
41
41
  end
42
+
43
+ it 'return platforms export with data' do
44
+ Train::Platforms.__reset
45
+ Train::Platforms::Detect::Specifications::OS.load
46
+ export = Train::Platforms.export
47
+ export.size.must_be :>, 10
48
+ export[0][:name].must_equal 'aix'
49
+ expected_families = ['aix', 'unix', 'os']
50
+ export[0][:families].must_equal expected_families
51
+ end
42
52
  end
@@ -72,12 +72,6 @@ describe 'v1 Connection Plugin' do
72
72
  plat[:release].must_equal aws_version
73
73
  end
74
74
 
75
- it 'provides family hierarchy' do
76
- plat = Train::Platforms.name('linux')
77
- family = connection.family_hierarchy(plat)
78
- family.flatten.must_equal ['linux', 'unix', 'os']
79
- end
80
-
81
75
  it 'must use the user-provided logger' do
82
76
  l = rand
83
77
  cls.new({logger: l})
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: 1.4.35
4
+ version: 1.4.37
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dominik Richter
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-08-23 00:00:00.000000000 Z
11
+ date: 2018-09-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json