pi_customizer 0.4.0.pre.alpha → 0.5.0.pre.alpha

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.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +0 -1
  3. data/CODE_OF_CONDUCT.md +1 -1
  4. data/README.md +55 -20
  5. data/Rakefile +6 -5
  6. data/docs/concept.md +0 -18
  7. data/docs/incubation.md +3 -14
  8. data/pi_build_modifier/Gemfile.lock +50 -0
  9. data/pi_build_modifier/lib/pi_build_modifier.rb +4 -7
  10. data/pi_build_modifier/lib/pi_build_modifier/modify/configs.rb +335 -0
  11. data/pi_build_modifier/lib/pi_build_modifier/modify/modifiers.rb +281 -0
  12. data/pi_build_modifier/lib/pi_build_modifier/{locale → modify}/templates/00-debconf.erb +1 -1
  13. data/pi_build_modifier/lib/pi_build_modifier/{boot-files → modify}/templates/07-resize-init.diff.erb +1 -1
  14. data/pi_build_modifier/lib/pi_build_modifier/{net-tweaks → modify}/templates/wpa_supplicant.conf.erb +1 -1
  15. data/pi_build_modifier/lib/pi_build_modifier/{config → utils}/logex.rb +5 -1
  16. data/pi_build_modifier/lib/pi_build_modifier/version.rb +1 -1
  17. data/pi_build_modifier/spec/pi_build_modifier/modify/modify_spec.rb +306 -0
  18. data/pi_build_modifier/spec/pi_build_modifier_spec.rb +3 -3
  19. data/pi_build_modifier/spec/spec_helper.rb +1 -0
  20. data/pi_customizer/Gemfile.lock +47 -0
  21. data/pi_customizer/lib/pi_customizer.rb +15 -9
  22. data/pi_customizer/lib/pi_customizer/build/builder/build_executor.rb +12 -24
  23. data/pi_customizer/lib/pi_customizer/build/builder/builder.rb +17 -13
  24. data/pi_customizer/{spec/pi_customizer/environment/environment_builder_factory_spec.rb → lib/pi_customizer/build/config/build_config.rb} +27 -18
  25. data/pi_customizer/lib/pi_customizer/build/{workspace → config}/local_workspace.rb +8 -8
  26. data/pi_customizer/lib/pi_customizer/build/{workspace → config}/remote_workspace.rb +1 -1
  27. data/pi_customizer/lib/pi_customizer/build/environment/docker/docker.rb +1 -1
  28. data/pi_customizer/lib/pi_customizer/build/environment/environment.rb +1 -1
  29. data/pi_customizer/lib/pi_customizer/build/{builder/start_prepare_execute_builder.rb → environment/environment_factory.rb} +27 -16
  30. data/pi_customizer/lib/pi_customizer/build/environment/vagrant/templates/Vagrantfile.erb +2 -2
  31. data/pi_customizer/lib/pi_customizer/build/environment/vagrant/vagrant.rb +3 -8
  32. data/pi_customizer/lib/pi_customizer/build/environment/vagrant/vagrant_file.rb +3 -3
  33. data/pi_customizer/lib/pi_customizer/version.rb +1 -1
  34. data/pi_customizer/lib/pi_customizer/write/image_writer.rb +3 -2
  35. data/pi_customizer/spec/pi_customizer/build/builder/builder_spec.rb +122 -0
  36. data/pi_customizer/spec/pi_customizer/{environment/aws_spec.rb → build/config/build_config_spec.rb} +20 -25
  37. data/pi_customizer/spec/pi_customizer/{workspace/local_workspace_spec.rb → build/config/local_workspace_config_spec.rb} +10 -10
  38. data/pi_customizer/spec/pi_customizer/{workspace → build/config}/remote_workspace_spec.rb +2 -2
  39. data/pi_customizer/spec/pi_customizer/{environment/vagrant/vagrant_spec.rb → build/environment/environment_builder_factory_spec.rb} +17 -13
  40. data/pi_customizer/spec/pi_customizer/{environment → build/environment}/environment_spec.rb +1 -1
  41. data/pi_customizer/spec/pi_customizer/{environment → build/environment}/vagrant/vagrant_file_spec.rb +7 -7
  42. data/pi_customizer/spec/pi_customizer/build/environment/vagrant/vagrant_spec.rb +80 -0
  43. data/pi_customizer/spec/pi_customizer_spec.rb +19 -14
  44. data/pi_customizer/spec/spec_helper.rb +21 -0
  45. data/version.rb +1 -1
  46. metadata +23 -42
  47. data/Vagrantfile +0 -27
  48. data/pi_build_modifier/.gitignore +0 -12
  49. data/pi_build_modifier/lib/pi_build_modifier/boot-files/boot.rb +0 -64
  50. data/pi_build_modifier/lib/pi_build_modifier/locale/locale_debconf.rb +0 -66
  51. data/pi_build_modifier/lib/pi_build_modifier/modifier/erb_mapper.rb +0 -72
  52. data/pi_build_modifier/lib/pi_build_modifier/modifier/mapper.rb +0 -49
  53. data/pi_build_modifier/lib/pi_build_modifier/modifier/pi_modifier.rb +0 -81
  54. data/pi_build_modifier/lib/pi_build_modifier/modifier_task.rb +0 -79
  55. data/pi_build_modifier/lib/pi_build_modifier/net-tweaks/wifi_network.rb +0 -124
  56. data/pi_build_modifier/lib/pi_build_modifier/sys_tweaks/run_modifier.rb +0 -63
  57. data/pi_build_modifier/lib/pi_build_modifier/sys_tweaks/ssh.rb +0 -61
  58. data/pi_build_modifier/lib/pi_build_modifier/sys_tweaks/templates/ssh.sh.erb +0 -8
  59. data/pi_build_modifier/lib/pi_build_modifier/system/system_type.rb +0 -84
  60. data/pi_build_modifier/spec/pi_build_modifier/boot/boot_spec.rb +0 -103
  61. data/pi_build_modifier/spec/pi_build_modifier/locale/locale_spec.rb +0 -87
  62. data/pi_build_modifier/spec/pi_build_modifier/modifier/mapper_spec.rb +0 -105
  63. data/pi_build_modifier/spec/pi_build_modifier/modifier/modifier_spec.rb +0 -83
  64. data/pi_build_modifier/spec/pi_build_modifier/modifier_task_spec.rb +0 -63
  65. data/pi_build_modifier/spec/pi_build_modifier/net-tweaks/wifi_network_spec.rb +0 -91
  66. data/pi_build_modifier/spec/pi_build_modifier/sys_tweaks/run_modifier_spec.rb +0 -74
  67. data/pi_build_modifier/spec/pi_build_modifier/sys_tweaks/ssh_spec.rb +0 -73
  68. data/pi_build_modifier/spec/pi_build_modifier/system/system_spec.rb +0 -66
  69. data/pi_customizer/lib/pi_customizer/build/builder/prepare_start_execute_builder.rb +0 -43
  70. data/pi_customizer/lib/pi_customizer/build/environment/aws/aws.rb +0 -76
  71. data/pi_customizer/lib/pi_customizer/build/environment/environment_builder_factory.rb +0 -81
  72. data/pi_customizer/spec/pi_customizer/builder/build_executor_spec.rb +0 -64
@@ -1,83 +0,0 @@
1
- # Copyright (c) 2017-2019 Beate Ottenwälder
2
- #
3
- # Permission is hereby granted, free of charge, to any person obtaining a copy
4
- # of this software and associated documentation files (the "Software"), to deal
5
- # in the Software without restriction, including without limitation the rights
6
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- # copies of the Software, and to permit persons to whom the Software is
8
- # furnished to do so, subject to the following conditions:
9
- #
10
- # The above copyright notice and this permission notice shall be included in all
11
- # copies or substantial portions of the Software.
12
- #
13
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
- # SOFTWARE.
20
-
21
- require_relative '../../spec_helper'
22
- require 'rspec'
23
- require 'fileutils'
24
- require 'pi_build_modifier/modifier/pi_modifier'
25
- require 'pi_build_modifier/modifier/mapper'
26
-
27
-
28
- module PiBuildModifier
29
- RSpec.describe PiModifier do
30
-
31
- let(:tmp_json_config) {'tmp_config.json'}
32
-
33
- before do
34
- File.open(tmp_json_config, 'w') {|file| file.write('{"a":1,"b":2}')}
35
- end
36
-
37
- after do
38
- FileUtils.rm(tmp_json_config)
39
- end
40
-
41
- it 'only accepts mappers that are a class Mapper' do
42
- #Given
43
- pi_modifier = PiModifier.new
44
-
45
- #When #Then
46
- expect{ pi_modifier.with_mapper(nil) }.to raise_error
47
-
48
- end
49
-
50
- it 'performs a modification task on a mapper object with the specification given in a json configuration' do
51
-
52
- #Given
53
- pi_modifier = PiModifier.new
54
- test_sum_component = TestSumComponent.new(nil)
55
-
56
- #When
57
- pi_modifier.with_json_configuration(tmp_json_config)
58
- pi_modifier.with_mapper(test_sum_component)
59
- pi_modifier.modify
60
-
61
- #Then
62
- expect(test_sum_component.a).to equal 1
63
- expect(test_sum_component.b).to equal 2
64
- expect(test_sum_component.sum).to equal 3
65
-
66
- end
67
- end
68
-
69
- class TestSumComponent < Mapper
70
- attr_accessor :a, :b, :sum
71
-
72
- def map(json_data)
73
- @a = json_data['a']
74
- @b = json_data['b']
75
- end
76
-
77
- def modify
78
- @sum = @a + @b
79
- end
80
-
81
- end
82
-
83
- end
@@ -1,63 +0,0 @@
1
- # Copyright (c) 2017-2019 Beate Ottenwälder
2
- #
3
- # Permission is hereby granted, free of charge, to any person obtaining a copy
4
- # of this software and associated documentation files (the "Software"), to deal
5
- # in the Software without restriction, including without limitation the rights
6
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- # copies of the Software, and to permit persons to whom the Software is
8
- # furnished to do so, subject to the following conditions:
9
- #
10
- # The above copyright notice and this permission notice shall be included in all
11
- # copies or substantial portions of the Software.
12
- #
13
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
- # SOFTWARE.
20
-
21
- require_relative '../spec_helper'
22
- require 'rspec'
23
- require 'fileutils'
24
- require 'pi_build_modifier/modifier/pi_modifier'
25
- require 'pi_build_modifier/modifier_task'
26
-
27
-
28
- module PiBuildModifier
29
- RSpec.describe Task::Modifier do
30
-
31
- let(:json_config) {File.dirname(__FILE__) + '/../fixtures/config.json'}
32
- let(:workspace) {File.dirname(__FILE__) + '/' + 'tmp_workspace'}
33
-
34
- before do
35
- FileUtils::mkdir_p workspace
36
- end
37
-
38
- after do
39
- FileUtils.rm_rf workspace
40
- end
41
-
42
- it 'registers all default mappers' do
43
- #Given
44
- pi_modifier = PiModifier.new
45
- #When
46
- Task::Modifier.new(json_config, workspace, pi_modifier)
47
- #Then
48
- expect(pi_modifier.mappers.size).to be >= 1
49
- end
50
-
51
- it 'when the modification task is executed, modifications are made to the workspace directory' do
52
- #Given
53
- pi_modifier_task = Task::Modifier.new(json_config, workspace)
54
-
55
- #When
56
- pi_modifier_task.execute
57
-
58
- #Then
59
- expect(Dir["#{workspace}/**/*"].length).to be > 0
60
- end
61
- end
62
-
63
- end
@@ -1,91 +0,0 @@
1
- # Copyright (c) 2017-2019 Beate Ottenwälder
2
- #
3
- # Permission is hereby granted, free of charge, to any person obtaining a copy
4
- # of this software and associated documentation files (the "Software"), to deal
5
- # in the Software without restriction, including without limitation the rights
6
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- # copies of the Software, and to permit persons to whom the Software is
8
- # furnished to do so, subject to the following conditions:
9
- #
10
- # The above copyright notice and this permission notice shall be included in all
11
- # copies or substantial portions of the Software.
12
- #
13
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
- # SOFTWARE.
20
-
21
- require_relative '../../spec_helper'
22
- require 'rspec'
23
- require 'fileutils'
24
- require 'pi_build_modifier/net-tweaks/wifi_network'
25
- require 'pi_build_modifier/modifier/erb_mapper'
26
- require 'pi_build_modifier/modifier/pi_modifier'
27
-
28
-
29
- RSpec.describe PiBuildModifier::WPASupplicant do
30
-
31
- let(:empty_json_config) {'config_empty.json'}
32
- let(:json_config) {'config_full.json'}
33
- let(:workspace) {File.dirname(__FILE__) + '/workspace'}
34
-
35
- before do
36
- FileUtils.mkdir_p workspace
37
- File.open(empty_json_config, 'w') {|file| file.write('{}')}
38
- File.open(json_config, 'w') {|file| file.write(' {"wifi" : {
39
- "wpa_country" : "DE_test",
40
- "networks": [
41
- {
42
- "ssid": "test_wpsk",
43
- "wpsk": "test_wpsk"
44
- }
45
- ]
46
- }
47
- }
48
- ')}
49
- end
50
-
51
- after do
52
- FileUtils.rm(empty_json_config)
53
- FileUtils.rm(json_config)
54
- FileUtils.rm_rf workspace
55
- end
56
-
57
- it 'should create a default wpa_supplicant.config when no change is specified in the json configuration file' do
58
-
59
- #Given
60
- modifier = PiBuildModifier::PiModifier.new
61
- wpa_supplicant = PiBuildModifier::WPASupplicant.new
62
- mapper = PiBuildModifier::ERBMapper.new(wpa_supplicant, workspace)
63
-
64
- #When
65
- modifier.with_json_configuration(empty_json_config)
66
- modifier.with_mapper(mapper)
67
- modifier.modify
68
-
69
- #Then
70
- expect(Pathname.new(workspace + '/' + wpa_supplicant.relative_output_path)).to be_file
71
- end
72
-
73
- it 'should create a wpa_supplicant.config with all changes that are specified in the json configuration file' do
74
-
75
- #Given
76
- modifier = PiBuildModifier::PiModifier.new
77
- wpa_supplicant = PiBuildModifier::WPASupplicant.new
78
- mapper = wpa_supplicant.mapper(workspace)
79
-
80
- #When
81
- modifier.with_json_configuration(json_config)
82
- modifier.with_mapper(mapper)
83
- modifier.modify
84
-
85
- #Then
86
- wpa_supplicant_file = File.read(workspace + '/' + wpa_supplicant.relative_output_path)
87
- expect(wpa_supplicant_file).to match(/network/)
88
- end
89
-
90
- end
91
-
@@ -1,74 +0,0 @@
1
- # Copyright (c) 2017-2019 Beate Ottenwälder
2
- #
3
- # Permission is hereby granted, free of charge, to any person obtaining a copy
4
- # of this software and associated documentation files (the "Software"), to deal
5
- # in the Software without restriction, including without limitation the rights
6
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- # copies of the Software, and to permit persons to whom the Software is
8
- # furnished to do so, subject to the following conditions:
9
- #
10
- # The above copyright notice and this permission notice shall be included in all
11
- # copies or substantial portions of the Software.
12
- #
13
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
- # SOFTWARE.
20
-
21
- require_relative '../../spec_helper'
22
- require 'rspec'
23
- require 'fileutils'
24
- require 'pi_build_modifier/sys_tweaks/run_modifier'
25
- require 'pi_build_modifier/modifier/pi_modifier'
26
- require 'pi_build_modifier/modifier/mapper'
27
-
28
- RSpec.describe PiBuildModifier::RunModifier do
29
-
30
- let(:workspace) {File.dirname(__FILE__) + '/workspace'}
31
-
32
- before do
33
- FileUtils.mkdir_p workspace
34
- end
35
-
36
- after do
37
- FileUtils.rm_rf workspace
38
- end
39
-
40
- it 'should be of type Mapper' do
41
- expect(PiBuildModifier::RunModifier.new).to be_a PiBuildModifier::Mapper
42
- end
43
-
44
- it 'should append lines to the 01-run.sh file' do
45
-
46
- #Given
47
- modifier = PiBuildModifier::RunModifier.new.mapper(workspace)
48
- FileUtils.mkdir_p File.dirname(workspace + '/' + modifier.relative_output_path)
49
- FileUtils.touch(workspace + '/' + modifier.relative_output_path)
50
- modifier.append(Class.new do
51
- def append_line
52
- '1'
53
- end
54
- end.new
55
- )
56
- modifier.append(Class.new do
57
- def append_line
58
- '2'
59
- end
60
- end.new
61
- )
62
-
63
-
64
- #When
65
- modifier.modify
66
-
67
- #Then
68
- expect(Pathname.new(workspace + '/' + modifier.relative_output_path)).to be_file
69
- expect(IO.read(Pathname.new(workspace + '/' + modifier.relative_output_path))).to match(/\nsource #{workspace}\/1\nsource #{workspace}\/2\n/)
70
-
71
- end
72
-
73
- end
74
-
@@ -1,73 +0,0 @@
1
- # Copyright (c) 2017-2019 Beate Ottenwälder
2
- #
3
- # Permission is hereby granted, free of charge, to any person obtaining a copy
4
- # of this software and associated documentation files (the "Software"), to deal
5
- # in the Software without restriction, including without limitation the rights
6
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- # copies of the Software, and to permit persons to whom the Software is
8
- # furnished to do so, subject to the following conditions:
9
- #
10
- # The above copyright notice and this permission notice shall be included in all
11
- # copies or substantial portions of the Software.
12
- #
13
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
- # SOFTWARE.
20
-
21
- require_relative '../../spec_helper'
22
- require 'rspec'
23
- require 'fileutils'
24
- require 'pi_build_modifier/sys_tweaks/ssh'
25
- require 'pi_build_modifier/sys_tweaks/run_modifier'
26
- require 'pi_build_modifier/modifier/erb_mapper'
27
- require 'pi_build_modifier/modifier/pi_modifier'
28
-
29
-
30
- RSpec.describe PiBuildModifier::Ssh do
31
-
32
- let(:empty_json_config) {'config_empty.json'}
33
- let(:workspace) {File.dirname(__FILE__) + '/workspace'}
34
-
35
- before do
36
- File.open(empty_json_config, 'w') {|file| file.write('{}')}
37
- FileUtils.mkdir_p workspace
38
- end
39
-
40
- after do
41
- FileUtils.rm(empty_json_config)
42
- FileUtils.rm_rf workspace
43
- end
44
-
45
- it 'does not accept an invalid config' do
46
- #Given
47
- modifier = PiBuildModifier::PiModifier.new
48
- ssh = PiBuildModifier::Ssh.new
49
- mapper = ssh.mapper(workspace)
50
-
51
- #When
52
- modifier.with_json_configuration('cfg')
53
- modifier.with_mapper(mapper)
54
-
55
- expect{ modifier.modify }.to raise_error()
56
- end
57
-
58
- it 'should create a default ssh.sh file' do
59
- #Given
60
- modifier = PiBuildModifier::PiModifier.new
61
- ssh = PiBuildModifier::Ssh.new
62
- mapper = ssh.mapper(workspace)
63
-
64
- #When
65
- modifier.with_json_configuration(empty_json_config)
66
- modifier.with_mapper(mapper)
67
- modifier.modify
68
-
69
- #Then
70
- expect(Pathname.new(workspace + '/' + ssh.relative_output_path)).to be_file
71
- end
72
- end
73
-
@@ -1,66 +0,0 @@
1
- # Copyright (c) 2017-2019 Beate Ottenwälder
2
- #
3
- # Permission is hereby granted, free of charge, to any person obtaining a copy
4
- # of this software and associated documentation files (the "Software"), to deal
5
- # in the Software without restriction, including without limitation the rights
6
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- # copies of the Software, and to permit persons to whom the Software is
8
- # furnished to do so, subject to the following conditions:
9
- #
10
- # The above copyright notice and this permission notice shall be included in all
11
- # copies or substantial portions of the Software.
12
- #
13
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
- # SOFTWARE.
20
-
21
- require_relative '../../spec_helper'
22
- require 'rspec'
23
- require 'fileutils'
24
- require 'pi_build_modifier/system/system_type'
25
- require 'pi_build_modifier/modifier/mapper'
26
-
27
- RSpec.describe PiBuildModifier::System do
28
-
29
- EXPECTED_SYSTEM_NAME = 'chiipi_test'
30
- EXPECTED_SYSTEM_TYPE = 'lite'
31
- let(:config) {{'system' => {'name' => EXPECTED_SYSTEM_NAME, 'type' => EXPECTED_SYSTEM_TYPE}}}
32
- let(:workspace) {"#{File.dirname(__FILE__)}/workspace"}
33
-
34
-
35
- after(:each) do
36
- FileUtils.rm_rf(workspace) if Dir.exist?(workspace)
37
- end
38
-
39
-
40
- it 'should map the name and type given in a hash to corresponding members' do
41
- #Given
42
- system = PiBuildModifier::System.new.mapper(workspace)
43
-
44
- #When
45
- system.map(config)
46
-
47
- #Then
48
- expect(system.name).to eq(EXPECTED_SYSTEM_NAME)
49
- expect(system.type).to eq(EXPECTED_SYSTEM_TYPE)
50
- end
51
-
52
- it 'should map the name and type to variables' do
53
- #Given
54
- system = PiBuildModifier::System.new.mapper(workspace)
55
-
56
- #When
57
- system.map(config)
58
- system.modify
59
-
60
- #Then
61
- %w(/config /stage3/SKIP /stage4/SKIP /stage5/SKIP).each do |file|
62
- expect(Pathname.new(workspace + file)).to be_file
63
- end
64
- end
65
-
66
- end