kanrisuru 0.10.0 → 0.12.1
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/.github/CONTRIBUTING.md +9 -9
- data/.github/ISSUE_TEMPLATE/bug_report.md +7 -8
- data/.rspec +1 -1
- data/CHANGELOG.md +127 -102
- data/CODE_OF_CONDUCT.md +10 -10
- data/README.md +19 -90
- data/kanrisuru.gemspec +2 -1
- data/lib/kanrisuru/command.rb +7 -0
- data/lib/kanrisuru/core/archive.rb +11 -35
- data/lib/kanrisuru/core/disk.rb +0 -3
- data/lib/kanrisuru/core/dmi.rb +1 -1
- data/lib/kanrisuru/core/file.rb +4 -11
- data/lib/kanrisuru/core/find.rb +6 -11
- data/lib/kanrisuru/core/mount.rb +14 -15
- data/lib/kanrisuru/core/socket.rb +2 -1
- data/lib/kanrisuru/core/stream.rb +1 -2
- data/lib/kanrisuru/core/zypper.rb +6 -23
- data/lib/kanrisuru/os_package/collection.rb +58 -0
- data/lib/kanrisuru/os_package/define.rb +34 -0
- data/lib/kanrisuru/os_package/include.rb +163 -0
- data/lib/kanrisuru/os_package.rb +3 -245
- data/lib/kanrisuru/remote/cpu.rb +5 -1
- data/lib/kanrisuru/remote/fstab.rb +5 -5
- data/lib/kanrisuru/result.rb +5 -4
- data/lib/kanrisuru/util.rb +1 -1
- data/lib/kanrisuru/version.rb +1 -1
- data/spec/functional/core/apt_spec.rb +22 -30
- data/spec/functional/core/archive_spec.rb +96 -120
- data/spec/functional/core/find_spec.rb +94 -113
- data/spec/functional/core/mount_spec.rb +121 -0
- data/spec/functional/core/socket_spec.rb +23 -28
- data/spec/functional/core/stream_spec.rb +12 -12
- data/spec/functional/core/transfer_spec.rb +108 -131
- data/spec/functional/core/yum_spec.rb +58 -83
- data/spec/functional/remote/cluster_spec.rb +11 -2
- data/spec/functional/remote/cpu_spec.rb +104 -0
- data/spec/functional/remote/env_spec.rb +3 -5
- data/spec/helper/stub_network.rb +35 -16
- data/spec/helper/test_hosts.rb +11 -1
- data/spec/integration/core/apt_spec.rb +2 -3
- data/spec/integration/core/archive_spec.rb +8 -13
- data/spec/integration/core/disk_spec.rb +2 -3
- data/spec/integration/core/dmi_spec.rb +2 -3
- data/spec/integration/core/file_spec.rb +4 -14
- data/spec/integration/core/find_spec.rb +3 -3
- data/spec/integration/core/group_spec.rb +2 -3
- data/spec/integration/core/ip_spec.rb +2 -3
- data/spec/integration/core/path_spec.rb +2 -3
- data/spec/integration/core/socket_spec.rb +2 -4
- data/spec/integration/core/stat_spec.rb +2 -3
- data/spec/integration/core/stream_spec.rb +6 -9
- data/spec/integration/core/system_spec.rb +2 -4
- data/spec/integration/core/transfer_spec.rb +4 -9
- data/spec/integration/core/user_spec.rb +2 -4
- data/spec/integration/core/yum_spec.rb +2 -3
- data/spec/integration/core/zypper_spec.rb +5 -6
- data/spec/integration/remote/cpu_spec.rb +2 -3
- data/spec/integration/remote/env_spec.rb +2 -3
- data/spec/integration/remote/fstab_spec.rb +2 -3
- data/spec/integration/remote/host_spec.rb +2 -3
- data/spec/integration/remote/memory_spec.rb +2 -2
- data/spec/integration/remote/os_spec.rb +2 -3
- data/spec/integration/remote/remote_file_spec.rb +9 -15
- data/spec/spec_helper.rb +12 -3
- data/spec/unit/command_spec.rb +19 -1
- data/spec/unit/core/find_spec.rb +1 -1
- data/spec/unit/core/yum_spec.rb +1 -1
- data/spec/unit/mode_spec.rb +2 -2
- data/spec/unit/remote/cluster_spec.rb +3 -1
- data/spec/unit/remote/cpu_spec.rb +1 -2
- data/spec/unit/remote/env_spec.rb +1 -3
- data/spec/unit/util_spec.rb +13 -0
- metadata +23 -4
| @@ -23,45 +23,40 @@ RSpec.describe Kanrisuru::Core::Socket do | |
| 23 23 | 
             
                expect_command(host.ss, 'ss -a -m')
         | 
| 24 24 |  | 
| 25 25 | 
             
                expect_command(host.ss(
         | 
| 26 | 
            -
             | 
| 27 | 
            -
             | 
| 28 | 
            -
             | 
| 29 | 
            -
             | 
| 30 | 
            -
             | 
| 31 | 
            -
             | 
| 32 | 
            -
             | 
| 33 | 
            -
                )
         | 
| 26 | 
            +
                                 numeric: true,
         | 
| 27 | 
            +
                                 tcp: true,
         | 
| 28 | 
            +
                                 udp: true,
         | 
| 29 | 
            +
                                 unix: true,
         | 
| 30 | 
            +
                                 raw: true
         | 
| 31 | 
            +
                               ),
         | 
| 32 | 
            +
                               'ss -a -m -n -t -u -x -w')
         | 
| 34 33 |  | 
| 35 34 | 
             
                expect_command(host.ss(
         | 
| 36 | 
            -
             | 
| 37 | 
            -
             | 
| 38 | 
            -
             | 
| 39 | 
            -
                )
         | 
| 35 | 
            +
                                 family: 'inet'
         | 
| 36 | 
            +
                               ),
         | 
| 37 | 
            +
                               'ss -a -m -f inet')
         | 
| 40 38 |  | 
| 41 | 
            -
                expect  | 
| 39 | 
            +
                expect do
         | 
| 42 40 | 
             
                  host.ss(family: 'inet5')
         | 
| 43 | 
            -
                 | 
| 41 | 
            +
                end.to raise_error(ArgumentError)
         | 
| 44 42 |  | 
| 45 43 | 
             
                expect_command(host.ss(
         | 
| 46 | 
            -
             | 
| 47 | 
            -
             | 
| 48 | 
            -
             | 
| 49 | 
            -
                )
         | 
| 44 | 
            +
                                 state: 'established'
         | 
| 45 | 
            +
                               ),
         | 
| 46 | 
            +
                               'ss -a -m state established')
         | 
| 50 47 |  | 
| 51 48 | 
             
                expect_command(host.ss(
         | 
| 52 | 
            -
             | 
| 53 | 
            -
             | 
| 54 | 
            -
             | 
| 55 | 
            -
                )
         | 
| 49 | 
            +
                                 state: 'connected'
         | 
| 50 | 
            +
                               ),
         | 
| 51 | 
            +
                               'ss -a -m state connected')
         | 
| 56 52 |  | 
| 57 | 
            -
                expect  | 
| 53 | 
            +
                expect do
         | 
| 58 54 | 
             
                  host.ss(state: 'test')
         | 
| 59 | 
            -
                 | 
| 55 | 
            +
                end.to raise_error(ArgumentError)
         | 
| 60 56 |  | 
| 61 57 | 
             
                expect_command(host.ss(
         | 
| 62 | 
            -
             | 
| 63 | 
            -
             | 
| 64 | 
            -
             | 
| 65 | 
            -
                )
         | 
| 58 | 
            +
                                 expression: "'( dport = :ssh or sport = :ssh )'"
         | 
| 59 | 
            +
                               ),
         | 
| 60 | 
            +
                               "ss -a -m '( dport = :ssh or sport = :ssh )'")
         | 
| 66 61 | 
             
              end
         | 
| 67 62 | 
             
            end
         | 
| @@ -85,30 +85,30 @@ RSpec.describe Kanrisuru::Core::Stream do | |
| 85 85 | 
             
                expect_command(host.echo('Hello\\n world', backslash: true), "echo -e 'Hello\\n world'")
         | 
| 86 86 |  | 
| 87 87 | 
             
                expect_command(host.echo('Hello world', new_file: '~/file1.txt', mode: 'write'),
         | 
| 88 | 
            -
             | 
| 89 | 
            -
             | 
| 88 | 
            +
                               "echo 'Hello world' > ~/file1.txt")
         | 
| 89 | 
            +
             | 
| 90 90 | 
             
                expect_command(host.echo('Goodbye', new_file: '~/file1.txt', mode: 'append'),
         | 
| 91 | 
            -
             | 
| 91 | 
            +
                               "echo 'Goodbye' >> ~/file1.txt")
         | 
| 92 92 | 
             
              end
         | 
| 93 93 |  | 
| 94 94 | 
             
              it 'prepares cat command' do
         | 
| 95 95 | 
             
                expect_command(host.cat('/etc/group'), 'cat /etc/group')
         | 
| 96 96 | 
             
                expect_command(host.cat('/etc/group', show_all: true), 'cat -A /etc/group')
         | 
| 97 97 | 
             
                expect_command(host.cat('/etc/group',
         | 
| 98 | 
            -
             | 
| 99 | 
            -
             | 
| 100 | 
            -
             | 
| 101 | 
            -
             | 
| 102 | 
            -
             | 
| 103 | 
            -
             | 
| 98 | 
            +
                                        show_tabs: true,
         | 
| 99 | 
            +
                                        number: true,
         | 
| 100 | 
            +
                                        squeeze_blank: true,
         | 
| 101 | 
            +
                                        show_nonprinting: true,
         | 
| 102 | 
            +
                                        show_ends: true,
         | 
| 103 | 
            +
                                        number_nonblank: true), 'cat -T -n -s -v -E -b /etc/group')
         | 
| 104 104 |  | 
| 105 105 | 
             
                expect_command(host.cat(['~/file1.txt', '~/file2.txt', '~/file3.txt']),
         | 
| 106 | 
            -
             | 
| 106 | 
            +
                               'cat ~/file1.txt ~/file2.txt ~/file3.txt')
         | 
| 107 107 |  | 
| 108 108 | 
             
                expect_command(host.cat(['~/file1.txt', '~/file2.txt', '~/file3.txt'], mode: 'write', new_file: 'combined.txt'),
         | 
| 109 | 
            -
             | 
| 109 | 
            +
                               'cat ~/file1.txt ~/file2.txt ~/file3.txt > combined.txt')
         | 
| 110 110 |  | 
| 111 111 | 
             
                expect_command(host.cat(['~/file1.txt', '~/file2.txt', '~/file3.txt'], mode: 'append', new_file: 'combined.txt'),
         | 
| 112 | 
            -
             | 
| 112 | 
            +
                               'cat ~/file1.txt ~/file2.txt ~/file3.txt >> combined.txt')
         | 
| 113 113 | 
             
              end
         | 
| 114 114 | 
             
            end
         | 
| @@ -14,7 +14,7 @@ RSpec.describe Kanrisuru::Core::Stat do | |
| 14 14 | 
             
              let(:host) do
         | 
| 15 15 | 
             
                Kanrisuru::Remote::Host.new(
         | 
| 16 16 | 
             
                  host: 'localhost',
         | 
| 17 | 
            -
                  username: 'ubuntu', | 
| 17 | 
            +
                  username: 'ubuntu',
         | 
| 18 18 | 
             
                  keys: ['id_rsa']
         | 
| 19 19 | 
             
                )
         | 
| 20 20 | 
             
              end
         | 
| @@ -23,165 +23,142 @@ RSpec.describe Kanrisuru::Core::Stat do | |
| 23 23 | 
             
                url = 'https://rubygems.org'
         | 
| 24 24 |  | 
| 25 25 | 
             
                expect_command(host.wget(url),
         | 
| 26 | 
            -
             | 
| 27 | 
            -
                )
         | 
| 26 | 
            +
                               "wget #{url}")
         | 
| 28 27 |  | 
| 29 28 | 
             
                ## Output options
         | 
| 30 | 
            -
                expect_command(host.wget(url, | 
| 31 | 
            -
             | 
| 32 | 
            -
             | 
| 33 | 
            -
                )
         | 
| 29 | 
            +
                expect_command(host.wget(url,
         | 
| 30 | 
            +
                                         quiet: true, verbose: false, log_file: '/var/log/wget.log'),
         | 
| 31 | 
            +
                               "wget --quiet --no-verbose --output-file /var/log/wget.log #{url}")
         | 
| 34 32 |  | 
| 35 | 
            -
                expect_command(host.wget(url, | 
| 36 | 
            -
             | 
| 37 | 
            -
             | 
| 38 | 
            -
                )
         | 
| 33 | 
            +
                expect_command(host.wget(url,
         | 
| 34 | 
            +
                                         verbose: true, append_log_file: '/var/log/wget.log'),
         | 
| 35 | 
            +
                               "wget --verbose --append-output /var/log/wget.log #{url}")
         | 
| 39 36 |  | 
| 40 37 | 
             
                ## Download options
         | 
| 41 38 | 
             
                expect_command(host.wget(url,
         | 
| 42 | 
            -
             | 
| 43 | 
            -
             | 
| 44 | 
            -
             | 
| 45 | 
            -
             | 
| 46 | 
            -
             | 
| 47 | 
            -
             | 
| 48 | 
            -
             | 
| 49 | 
            -
             | 
| 50 | 
            -
             | 
| 51 | 
            -
             | 
| 52 | 
            -
             | 
| 53 | 
            -
             | 
| 54 | 
            -
             | 
| 55 | 
            -
             | 
| 56 | 
            -
             | 
| 57 | 
            -
                  "wget --bind-address 0.0.0.0 --tries 3 --output-document /home/ubuntu/index.html --no-clobber --timeout 30 --dns-timeout 60 --connect-timeout 60 --read-timeout 15 --limit-rate 120k --wait 5 --waitretry 15 --random-wait --no-proxy --no-dns-cache https://rubygems.org"
         | 
| 58 | 
            -
                )
         | 
| 39 | 
            +
                                         bind_address: '0.0.0.0',
         | 
| 40 | 
            +
                                         retries: 3,
         | 
| 41 | 
            +
                                         output_document: '/home/ubuntu/index.html',
         | 
| 42 | 
            +
                                         no_clobber: true,
         | 
| 43 | 
            +
                                         timeout: 30,
         | 
| 44 | 
            +
                                         dns_timeout: 60,
         | 
| 45 | 
            +
                                         connect_timeout: 60,
         | 
| 46 | 
            +
                                         read_timeout: 15,
         | 
| 47 | 
            +
                                         limit_rate: '120k',
         | 
| 48 | 
            +
                                         wait: 5,
         | 
| 49 | 
            +
                                         waitretry: 15,
         | 
| 50 | 
            +
                                         random_wait: true,
         | 
| 51 | 
            +
                                         no_proxy: true,
         | 
| 52 | 
            +
                                         no_dns_cache: true),
         | 
| 53 | 
            +
                               'wget --bind-address 0.0.0.0 --tries 3 --output-document /home/ubuntu/index.html --no-clobber --timeout 30 --dns-timeout 60 --connect-timeout 60 --read-timeout 15 --limit-rate 120k --wait 5 --waitretry 15 --random-wait --no-proxy --no-dns-cache https://rubygems.org')
         | 
| 59 54 |  | 
| 60 55 | 
             
                ## Other Options
         | 
| 61 56 | 
             
                expect_command(host.wget(url,
         | 
| 62 | 
            -
             | 
| 63 | 
            -
             | 
| 64 | 
            -
             | 
| 65 | 
            -
             | 
| 66 | 
            -
             | 
| 67 | 
            -
             | 
| 68 | 
            -
             | 
| 69 | 
            -
             | 
| 70 | 
            -
                  "wget --quota inf --restrict-file-names unix,ascii,lowercase,uppercase --inet4-only --retry-connrefused --user admin --password admin --no-iri #{url}"
         | 
| 71 | 
            -
                )
         | 
| 57 | 
            +
                                         quota: 'inf',
         | 
| 58 | 
            +
                                         family: 'inet',
         | 
| 59 | 
            +
                                         restrict_file_names: %w[unix ascii lowercase uppercase],
         | 
| 60 | 
            +
                                         retry_connrefused: true,
         | 
| 61 | 
            +
                                         user: 'admin',
         | 
| 62 | 
            +
                                         password: 'admin',
         | 
| 63 | 
            +
                                         no_iri: true),
         | 
| 64 | 
            +
                               "wget --quota inf --restrict-file-names unix,ascii,lowercase,uppercase --inet4-only --retry-connrefused --user admin --password admin --no-iri #{url}")
         | 
| 72 65 |  | 
| 73 66 | 
             
                ## Directories
         | 
| 74 67 | 
             
                expect_command(host.wget(url,
         | 
| 75 | 
            -
             | 
| 76 | 
            -
             | 
| 77 | 
            -
             | 
| 78 | 
            -
             | 
| 79 | 
            -
             | 
| 80 | 
            -
                "wget --no-directories --no-host-directories --cut-dirs 3 --directory-prefix ~/downloads/ #{url}"
         | 
| 81 | 
            -
                )
         | 
| 68 | 
            +
                                         no_directories: true,
         | 
| 69 | 
            +
                                         no_host_directories: true,
         | 
| 70 | 
            +
                                         cut_dirs: 3,
         | 
| 71 | 
            +
                                         directory_prefix: '~/downloads/'),
         | 
| 72 | 
            +
                               "wget --no-directories --no-host-directories --cut-dirs 3 --directory-prefix ~/downloads/ #{url}")
         | 
| 82 73 |  | 
| 83 74 | 
             
                ## HTTP
         | 
| 84 75 | 
             
                expect_command(host.wget(url,
         | 
| 85 | 
            -
             | 
| 86 | 
            -
             | 
| 87 | 
            -
             | 
| 88 | 
            -
             | 
| 89 | 
            -
             | 
| 90 | 
            -
             | 
| 91 | 
            -
             | 
| 92 | 
            -
             | 
| 93 | 
            -
             | 
| 94 | 
            -
             | 
| 95 | 
            -
             | 
| 96 | 
            -
             | 
| 97 | 
            -
             | 
| 98 | 
            -
             | 
| 99 | 
            -
             | 
| 100 | 
            -
             | 
| 101 | 
            -
             | 
| 102 | 
            -
                  "wget --default-page index.html --adjust-extension --http-user admin --http-password admin --load-cookies ~/cookies.txt --save-cookies ~/cookies.txt --no-cache --keep-session-cookies --ignore-length --max-redirect 5 --proxy-user admin --proxy-password 12345678 --header 'Accept-Language: hr' --header 'Authorization: Bearer 1234' #{url}"
         | 
| 103 | 
            -
                )
         | 
| 76 | 
            +
                                         default_page: 'index.html',
         | 
| 77 | 
            +
                                         adjust_extension: true,
         | 
| 78 | 
            +
                                         http_user: 'admin',
         | 
| 79 | 
            +
                                         http_password: 'admin',
         | 
| 80 | 
            +
                                         load_cookies: '~/cookies.txt',
         | 
| 81 | 
            +
                                         save_cookies: '~/cookies.txt',
         | 
| 82 | 
            +
                                         no_cache: true,
         | 
| 83 | 
            +
                                         keep_session_cookies: true,
         | 
| 84 | 
            +
                                         ignore_length: true,
         | 
| 85 | 
            +
                                         headers: {
         | 
| 86 | 
            +
                                           'Accept-Language' => 'hr',
         | 
| 87 | 
            +
                                           'Authorization' => 'Bearer 1234'
         | 
| 88 | 
            +
                                         },
         | 
| 89 | 
            +
                                         max_redirect: 5,
         | 
| 90 | 
            +
                                         proxy_user: 'admin',
         | 
| 91 | 
            +
                                         proxy_password: '12345678'),
         | 
| 92 | 
            +
                               "wget --default-page index.html --adjust-extension --http-user admin --http-password admin --load-cookies ~/cookies.txt --save-cookies ~/cookies.txt --no-cache --keep-session-cookies --ignore-length --max-redirect 5 --proxy-user admin --proxy-password 12345678 --header 'Accept-Language: hr' --header 'Authorization: Bearer 1234' #{url}")
         | 
| 104 93 |  | 
| 105 94 | 
             
                expect_command(host.wget(url,
         | 
| 106 | 
            -
             | 
| 107 | 
            -
             | 
| 108 | 
            -
             | 
| 109 | 
            -
             | 
| 110 | 
            -
             | 
| 111 | 
            -
             | 
| 112 | 
            -
             | 
| 113 | 
            -
             | 
| 114 | 
            -
                 | 
| 115 | 
            -
             | 
| 116 | 
            -
                expect {
         | 
| 95 | 
            +
                                         post_data: {
         | 
| 96 | 
            +
                                           url: 'https://example.com?param=123'
         | 
| 97 | 
            +
                                         },
         | 
| 98 | 
            +
                                         content_disposition: true,
         | 
| 99 | 
            +
                                         secure_protocol: 'SSLv3',
         | 
| 100 | 
            +
                                         no_check_certificate: true),
         | 
| 101 | 
            +
                               "wget --post-data url=https%3A%2F%2Fexample.com%3Fparam%3D123 --content-disposition --secure-protocol SSLv3 --no-check-certificate #{url}")
         | 
| 102 | 
            +
             | 
| 103 | 
            +
                expect do
         | 
| 117 104 | 
             
                  host.wget(url, secure_protocol: 'SSL')
         | 
| 118 | 
            -
                 | 
| 105 | 
            +
                end.to raise_error(ArgumentError)
         | 
| 119 106 |  | 
| 120 107 | 
             
                expect_command(host.wget(url,
         | 
| 121 | 
            -
             | 
| 122 | 
            -
             | 
| 123 | 
            -
             | 
| 124 | 
            -
             | 
| 125 | 
            -
             | 
| 126 | 
            -
             | 
| 127 | 
            -
             | 
| 128 | 
            -
                  "wget --certificate ~/cert.pem --certificate-type PEM --private-key ~/key.pem --private-key-type PEM --ca-certificate ~/ca.pem --random-file ~/random #{url}"
         | 
| 129 | 
            -
                )
         | 
| 108 | 
            +
                                         certificate: '~/cert.pem',
         | 
| 109 | 
            +
                                         certificate_type: 'PEM',
         | 
| 110 | 
            +
                                         private_key: '~/key.pem',
         | 
| 111 | 
            +
                                         private_key_type: 'PEM',
         | 
| 112 | 
            +
                                         ca_certificate: '~/ca.pem',
         | 
| 113 | 
            +
                                         random_file: '~/random'),
         | 
| 114 | 
            +
                               "wget --certificate ~/cert.pem --certificate-type PEM --private-key ~/key.pem --private-key-type PEM --ca-certificate ~/ca.pem --random-file ~/random #{url}")
         | 
| 130 115 |  | 
| 131 116 | 
             
                expect_command(host.wget(url,
         | 
| 132 | 
            -
             | 
| 133 | 
            -
             | 
| 134 | 
            -
             | 
| 135 | 
            -
             | 
| 136 | 
            -
             | 
| 137 | 
            -
             | 
| 138 | 
            -
             | 
| 139 | 
            -
                  "wget --certificate ~/cert.pem --certificate-type PEM --private-key ~/key.pem --private-key-type PEM --ca-certificate ~/ca.pem --random-file ~/random #{url}"
         | 
| 140 | 
            -
                )
         | 
| 117 | 
            +
                                         certificate: '~/cert.pem',
         | 
| 118 | 
            +
                                         certificate_type: 'PEM',
         | 
| 119 | 
            +
                                         private_key: '~/key.pem',
         | 
| 120 | 
            +
                                         private_key_type: 'PEM',
         | 
| 121 | 
            +
                                         ca_certificate: '~/ca.pem',
         | 
| 122 | 
            +
                                         random_file: '~/random'),
         | 
| 123 | 
            +
                               "wget --certificate ~/cert.pem --certificate-type PEM --private-key ~/key.pem --private-key-type PEM --ca-certificate ~/ca.pem --random-file ~/random #{url}")
         | 
| 141 124 |  | 
| 142 125 | 
             
                ## FTP
         | 
| 143 | 
            -
                expect_command(host.wget(url, | 
| 144 | 
            -
             | 
| 145 | 
            -
             | 
| 146 | 
            -
             | 
| 147 | 
            -
             | 
| 148 | 
            -
             | 
| 149 | 
            -
             | 
| 150 | 
            -
             | 
| 151 | 
            -
                  "wget --ftp-user admin --ftp-password 12345678 --no-remove-listing --no-glob --no-passive-ftp --retr-symlinks #{url}"
         | 
| 152 | 
            -
                )
         | 
| 126 | 
            +
                expect_command(host.wget(url,
         | 
| 127 | 
            +
                                         ftp_user: 'admin',
         | 
| 128 | 
            +
                                         ftp_password: '12345678',
         | 
| 129 | 
            +
                                         no_remove_listing: true,
         | 
| 130 | 
            +
                                         no_glob: true,
         | 
| 131 | 
            +
                                         no_passive_ftp: true,
         | 
| 132 | 
            +
                                         retr_symlinks: true),
         | 
| 133 | 
            +
                               "wget --ftp-user admin --ftp-password 12345678 --no-remove-listing --no-glob --no-passive-ftp --retr-symlinks #{url}")
         | 
| 153 134 |  | 
| 154 135 | 
             
                ## Recursive Retrieval
         | 
| 155 136 | 
             
                expect_command(host.wget(url,
         | 
| 156 | 
            -
             | 
| 157 | 
            -
             | 
| 158 | 
            -
             | 
| 159 | 
            -
             | 
| 160 | 
            -
             | 
| 161 | 
            -
             | 
| 162 | 
            -
             | 
| 163 | 
            -
             | 
| 164 | 
            -
             | 
| 165 | 
            -
                  "wget --recursive --level 10 --delete-after --convert-links --backup-converted --mirror --page-requisites --strict-comments #{url}"
         | 
| 166 | 
            -
                )
         | 
| 137 | 
            +
                                         recursive: true,
         | 
| 138 | 
            +
                                         depth: 10,
         | 
| 139 | 
            +
                                         delete_after: true,
         | 
| 140 | 
            +
                                         convert_links: true,
         | 
| 141 | 
            +
                                         backup_converted: true,
         | 
| 142 | 
            +
                                         mirror: true,
         | 
| 143 | 
            +
                                         page_requisites: true,
         | 
| 144 | 
            +
                                         strict_comments: true),
         | 
| 145 | 
            +
                               "wget --recursive --level 10 --delete-after --convert-links --backup-converted --mirror --page-requisites --strict-comments #{url}")
         | 
| 167 146 |  | 
| 168 147 | 
             
                ## Recursive Accept/Reject
         | 
| 169 148 | 
             
                expect_command(host.wget(url,
         | 
| 170 | 
            -
             | 
| 171 | 
            -
             | 
| 172 | 
            -
             | 
| 173 | 
            -
             | 
| 174 | 
            -
             | 
| 175 | 
            -
             | 
| 176 | 
            -
             | 
| 177 | 
            -
             | 
| 178 | 
            -
             | 
| 179 | 
            -
             | 
| 180 | 
            -
             | 
| 181 | 
            -
             | 
| 182 | 
            -
             | 
| 183 | 
            -
             | 
| 184 | 
            -
                  "wget --accept .txt,.html --reject .csv --domains example.com --exclude-domains hackernews.com --follow-tags a,div,span --ignore-tags area,link --include-directories /gems --exclude-directories /releases --follow-ftp --ignore-case --span-hosts --relative --no-parent #{url}"
         | 
| 185 | 
            -
                )
         | 
| 149 | 
            +
                                         accept_list: ['.txt', '.html'],
         | 
| 150 | 
            +
                                         reject_list: ['.csv'],
         | 
| 151 | 
            +
                                         domain_list: ['example.com'],
         | 
| 152 | 
            +
                                         exclude_domain_list: ['hackernews.com'],
         | 
| 153 | 
            +
                                         follow_tags: %w[a div span],
         | 
| 154 | 
            +
                                         ignore_tags: %w[area link],
         | 
| 155 | 
            +
                                         include_directories: ['/gems'],
         | 
| 156 | 
            +
                                         exclude_directories: ['/releases'],
         | 
| 157 | 
            +
                                         follow_ftp: true,
         | 
| 158 | 
            +
                                         ignore_case: true,
         | 
| 159 | 
            +
                                         span_hosts: true,
         | 
| 160 | 
            +
                                         relative: true,
         | 
| 161 | 
            +
                                         no_parent: true),
         | 
| 162 | 
            +
                               "wget --accept .txt,.html --reject .csv --domains example.com --exclude-domains hackernews.com --follow-tags a,div,span --ignore-tags area,link --include-directories /gems --exclude-directories /releases --follow-ftp --ignore-case --span-hosts --relative --no-parent #{url}")
         | 
| 186 163 | 
             
              end
         | 
| 187 164 | 
             
            end
         | 
| @@ -20,117 +20,94 @@ RSpec.describe Kanrisuru::Core::Yum do | |
| 20 20 | 
             
              end
         | 
| 21 21 |  | 
| 22 22 | 
             
              it 'prepares yum install command' do
         | 
| 23 | 
            -
                expect_command(host.yum('install', packages: 'nginx'), | 
| 24 | 
            -
             | 
| 25 | 
            -
                )
         | 
| 23 | 
            +
                expect_command(host.yum('install', packages: 'nginx'),
         | 
| 24 | 
            +
                               'yum install -y nginx')
         | 
| 26 25 |  | 
| 27 | 
            -
                expect_command(host.yum('install', packages: [ | 
| 28 | 
            -
             | 
| 29 | 
            -
                )
         | 
| 26 | 
            +
                expect_command(host.yum('install', packages: %w[nginx apache2]),
         | 
| 27 | 
            +
                               'yum install -y nginx apache2')
         | 
| 30 28 | 
             
              end
         | 
| 31 29 |  | 
| 32 30 | 
             
              it 'prepares yum localinstall command' do
         | 
| 33 | 
            -
                expect_command(host.yum('localinstall', repos: 'foo.rpm'), | 
| 34 | 
            -
             | 
| 35 | 
            -
                )
         | 
| 31 | 
            +
                expect_command(host.yum('localinstall', repos: 'foo.rpm'),
         | 
| 32 | 
            +
                               'yum localinstall -y foo.rpm')
         | 
| 36 33 |  | 
| 37 | 
            -
                expect_command(host.yum('localinstall', | 
| 38 | 
            -
             | 
| 39 | 
            -
             | 
| 40 | 
            -
             | 
| 41 | 
            -
                  'yum localinstall --disablerepo=* -y foo.rpm bar.rpm baz.rpm'
         | 
| 42 | 
            -
                )
         | 
| 34 | 
            +
                expect_command(host.yum('localinstall',
         | 
| 35 | 
            +
                                        repos: ['foo.rpm', 'bar.rpm', 'baz.rpm'],
         | 
| 36 | 
            +
                                        disable_repo: '*'),
         | 
| 37 | 
            +
                               'yum localinstall --disablerepo=* -y foo.rpm bar.rpm baz.rpm')
         | 
| 43 38 | 
             
              end
         | 
| 44 39 |  | 
| 45 40 | 
             
              it 'prepares yum list command' do
         | 
| 46 | 
            -
                expect_command(host.yum('list'), | 
| 47 | 
            -
             | 
| 48 | 
            -
                )
         | 
| 41 | 
            +
                expect_command(host.yum('list'),
         | 
| 42 | 
            +
                               "yum list | tr '\\n' '#' | sed -e 's/# / /g' | tr '#' '\\n'")
         | 
| 49 43 |  | 
| 50 44 | 
             
                expect_command(host.yum('list', all: true, query: 'ruby*'),
         | 
| 51 | 
            -
             | 
| 52 | 
            -
             | 
| 53 | 
            -
             | 
| 54 | 
            -
             | 
| 55 | 
            -
             | 
| 56 | 
            -
             | 
| 57 | 
            -
             | 
| 58 | 
            -
             | 
| 59 | 
            -
             | 
| 60 | 
            -
             | 
| 61 | 
            -
                  ),
         | 
| 62 | 
            -
                  "yum list --disablerepo=* available updates installed extras obsoletes | tr '\\n' '#' | sed -e 's/# / /g' | tr '#' '\\n'"
         | 
| 63 | 
            -
                )
         | 
| 45 | 
            +
                               "yum list all ruby* | tr '\\n' '#' | sed -e 's/# / /g' | tr '#' '\\n'")
         | 
| 46 | 
            +
             | 
| 47 | 
            +
                expect_command(host.yum('list',
         | 
| 48 | 
            +
                                        available: true,
         | 
| 49 | 
            +
                                        updates: true,
         | 
| 50 | 
            +
                                        installed: true,
         | 
| 51 | 
            +
                                        extras: true,
         | 
| 52 | 
            +
                                        obsoletes: true,
         | 
| 53 | 
            +
                                        disable_repo: '*'),
         | 
| 54 | 
            +
                               "yum list --disablerepo=* available updates installed extras obsoletes | tr '\\n' '#' | sed -e 's/# / /g' | tr '#' '\\n'")
         | 
| 64 55 | 
             
              end
         | 
| 65 56 |  | 
| 66 57 | 
             
              it 'prepares yum search command' do
         | 
| 67 | 
            -
                expect_command(host.yum('search', | 
| 68 | 
            -
             | 
| 69 | 
            -
             | 
| 70 | 
            -
                  "yum search redis | tr '\\n' '#' | sed -e 's/# / /g' | tr '#' '\\n'"
         | 
| 71 | 
            -
                )
         | 
| 58 | 
            +
                expect_command(host.yum('search',
         | 
| 59 | 
            +
                                        packages: 'redis'),
         | 
| 60 | 
            +
                               "yum search redis | tr '\\n' '#' | sed -e 's/# / /g' | tr '#' '\\n'")
         | 
| 72 61 |  | 
| 73 62 | 
             
                expect_command(host.yum('search',
         | 
| 74 | 
            -
             | 
| 75 | 
            -
             | 
| 76 | 
            -
             | 
| 77 | 
            -
                  "yum search all package1 package2 package3 | tr '\\n' '#' | sed -e 's/# / /g' | tr '#' '\\n'"
         | 
| 78 | 
            -
                )
         | 
| 63 | 
            +
                                        packages: %w[package1 package2 package3],
         | 
| 64 | 
            +
                                        all: true),
         | 
| 65 | 
            +
                               "yum search all package1 package2 package3 | tr '\\n' '#' | sed -e 's/# / /g' | tr '#' '\\n'")
         | 
| 79 66 | 
             
              end
         | 
| 80 67 |  | 
| 81 68 | 
             
              it 'prepares yum info command' do
         | 
| 82 | 
            -
                expect_command(host.yum('info', | 
| 83 | 
            -
             | 
| 84 | 
            -
             | 
| 85 | 
            -
             | 
| 86 | 
            -
                 | 
| 87 | 
            -
             | 
| 88 | 
            -
             | 
| 89 | 
            -
             | 
| 90 | 
            -
                    installed: true
         | 
| 91 | 
            -
                  ),
         | 
| 92 | 
            -
                  "yum info --quiet installed package1 package2 package3"
         | 
| 93 | 
            -
                )
         | 
| 69 | 
            +
                expect_command(host.yum('info',
         | 
| 70 | 
            +
                                        packages: 'redis'),
         | 
| 71 | 
            +
                               'yum info --quiet redis')
         | 
| 72 | 
            +
             | 
| 73 | 
            +
                expect_command(host.yum('info',
         | 
| 74 | 
            +
                                        packages: %w[package1 package2 package3],
         | 
| 75 | 
            +
                                        installed: true),
         | 
| 76 | 
            +
                               'yum info --quiet installed package1 package2 package3')
         | 
| 94 77 | 
             
              end
         | 
| 95 78 |  | 
| 96 79 | 
             
              it 'prepares yum repolist command' do
         | 
| 97 80 | 
             
                expect_command(host.yum('repolist'),
         | 
| 98 | 
            -
             | 
| 99 | 
            -
                )
         | 
| 81 | 
            +
                               'yum repolist --verbose')
         | 
| 100 82 |  | 
| 101 83 | 
             
                expect_command(host.yum('repolist', repos: 'repo1'),
         | 
| 102 | 
            -
             | 
| 103 | 
            -
                )
         | 
| 84 | 
            +
                               'yum repolist --verbose repo1')
         | 
| 104 85 |  | 
| 105 | 
            -
                expect_command(host.yum('repolist', repos: [ | 
| 106 | 
            -
             | 
| 107 | 
            -
                )
         | 
| 86 | 
            +
                expect_command(host.yum('repolist', repos: %w[repo1 repo2 repo3]),
         | 
| 87 | 
            +
                               'yum repolist --verbose repo1 repo2 repo3')
         | 
| 108 88 | 
             
              end
         | 
| 109 89 |  | 
| 110 90 | 
             
              it 'prepares yum clean command' do
         | 
| 111 91 | 
             
                expect_command(host.yum('clean'), 'yum clean')
         | 
| 112 92 | 
             
                expect_command(host.yum('clean', all: true), 'yum clean all')
         | 
| 113 | 
            -
                expect_command(host.yum('clean', | 
| 114 | 
            -
             | 
| 115 | 
            -
             | 
| 116 | 
            -
             | 
| 117 | 
            -
             | 
| 118 | 
            -
             | 
| 119 | 
            -
             | 
| 120 | 
            -
             | 
| 121 | 
            -
             | 
| 122 | 
            -
                )
         | 
| 123 | 
            -
              end 
         | 
| 93 | 
            +
                expect_command(host.yum('clean',
         | 
| 94 | 
            +
                                        dbcache: true,
         | 
| 95 | 
            +
                                        expire_cache: true,
         | 
| 96 | 
            +
                                        metadata: true,
         | 
| 97 | 
            +
                                        packages: true,
         | 
| 98 | 
            +
                                        headers: true,
         | 
| 99 | 
            +
                                        rpmdb: true),
         | 
| 100 | 
            +
                               'yum clean dbcache expire-cache metadata packages headers rpmdb')
         | 
| 101 | 
            +
              end
         | 
| 124 102 |  | 
| 125 103 | 
             
              it 'prepares yum remove command' do
         | 
| 126 | 
            -
                expect_command(host.yum('remove', packages: 'gcc'), 'yum remove -y gcc') | 
| 127 | 
            -
                expect_command(host.yum('remove', packages: [ | 
| 128 | 
            -
             | 
| 129 | 
            -
                )
         | 
| 104 | 
            +
                expect_command(host.yum('remove', packages: 'gcc'), 'yum remove -y gcc')
         | 
| 105 | 
            +
                expect_command(host.yum('remove', packages: %w[p1 p2 p3]),
         | 
| 106 | 
            +
                               'yum remove -y p1 p2 p3')
         | 
| 130 107 |  | 
| 131 | 
            -
                expect  | 
| 108 | 
            +
                expect do
         | 
| 132 109 | 
             
                  host.yum('remove', packages: 'yum')
         | 
| 133 | 
            -
                 | 
| 110 | 
            +
                end.to raise_error(ArgumentError)
         | 
| 134 111 | 
             
              end
         | 
| 135 112 |  | 
| 136 113 | 
             
              it 'prepares yum autoremove command' do
         | 
| @@ -139,13 +116,12 @@ RSpec.describe Kanrisuru::Core::Yum do | |
| 139 116 |  | 
| 140 117 | 
             
              it 'prepares yum erase command' do
         | 
| 141 118 | 
             
                expect_command(host.yum('erase', packages: 'gcc'), 'yum erase -y gcc')
         | 
| 142 | 
            -
                expect_command(host.yum('erase', packages: [ | 
| 143 | 
            -
             | 
| 144 | 
            -
                )
         | 
| 119 | 
            +
                expect_command(host.yum('erase', packages: %w[p1 p2 p3]),
         | 
| 120 | 
            +
                               'yum erase -y p1 p2 p3')
         | 
| 145 121 |  | 
| 146 | 
            -
                expect  | 
| 122 | 
            +
                expect do
         | 
| 147 123 | 
             
                  host.yum('erase', packages: 'yum')
         | 
| 148 | 
            -
                 | 
| 124 | 
            +
                end.to raise_error(ArgumentError)
         | 
| 149 125 | 
             
              end
         | 
| 150 126 |  | 
| 151 127 | 
             
              it 'prepares yum update command' do
         | 
| @@ -155,5 +131,4 @@ RSpec.describe Kanrisuru::Core::Yum do | |
| 155 131 | 
             
              it 'prepares yum upgrade command' do
         | 
| 156 132 | 
             
                expect_command(host.yum('upgrade'), 'yum upgrade -y')
         | 
| 157 133 | 
             
              end
         | 
| 158 | 
            -
             | 
| 159 134 | 
             
            end
         | 
| @@ -28,7 +28,7 @@ RSpec.describe Kanrisuru::Remote::Cluster do | |
| 28 28 | 
             
              end
         | 
| 29 29 |  | 
| 30 30 | 
             
              it 'adds host to a cluster' do
         | 
| 31 | 
            -
                cluster =  | 
| 31 | 
            +
                cluster = described_class.new(host1)
         | 
| 32 32 | 
             
                expect(cluster.hosts.length).to eq(1)
         | 
| 33 33 | 
             
                expect(cluster.count).to eq(1)
         | 
| 34 34 | 
             
                expect(cluster[host1.host]).to eq(host1)
         | 
| @@ -42,8 +42,17 @@ RSpec.describe Kanrisuru::Remote::Cluster do | |
| 42 42 | 
             
                expect(cluster.hosts).to include(host2)
         | 
| 43 43 | 
             
              end
         | 
| 44 44 |  | 
| 45 | 
            +
              it 'fails to add host to a cluster' do
         | 
| 46 | 
            +
                cluster = described_class.new
         | 
| 47 | 
            +
                expect { cluster << 1 }.to raise_error(ArgumentError)
         | 
| 48 | 
            +
                expect { cluster << 'hello' }.to raise_error(ArgumentError)
         | 
| 49 | 
            +
                expect { cluster << ['host'] }.to raise_error(ArgumentError)
         | 
| 50 | 
            +
             | 
| 51 | 
            +
                expect(cluster.count).to eq(0)
         | 
| 52 | 
            +
              end
         | 
| 53 | 
            +
             | 
| 45 54 | 
             
              it 'removes a host from a cluster' do
         | 
| 46 | 
            -
                cluster =  | 
| 55 | 
            +
                cluster = described_class.new(host1, host2)
         | 
| 47 56 | 
             
                expect(cluster.count).to eq(2)
         | 
| 48 57 |  | 
| 49 58 | 
             
                cluster.delete(host2)
         |