kanrisuru 0.9.2 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/.github/CONTRIBUTING.md +9 -9
  3. data/.github/ISSUE_TEMPLATE/bug_report.md +7 -8
  4. data/.rspec +1 -1
  5. data/CHANGELOG.md +125 -96
  6. data/CODE_OF_CONDUCT.md +10 -10
  7. data/README.md +19 -90
  8. data/kanrisuru.gemspec +2 -1
  9. data/lib/kanrisuru/command.rb +7 -0
  10. data/lib/kanrisuru/core/archive.rb +13 -36
  11. data/lib/kanrisuru/core/disk.rb +0 -3
  12. data/lib/kanrisuru/core/dmi.rb +1 -1
  13. data/lib/kanrisuru/core/file.rb +4 -11
  14. data/lib/kanrisuru/core/find.rb +6 -11
  15. data/lib/kanrisuru/core/mount.rb +14 -15
  16. data/lib/kanrisuru/core/socket.rb +2 -1
  17. data/lib/kanrisuru/core/stream.rb +1 -2
  18. data/lib/kanrisuru/core/zypper.rb +6 -23
  19. data/lib/kanrisuru/os_package/collection.rb +58 -0
  20. data/lib/kanrisuru/os_package/define.rb +34 -0
  21. data/lib/kanrisuru/os_package/include.rb +163 -0
  22. data/lib/kanrisuru/os_package.rb +3 -245
  23. data/lib/kanrisuru/remote/cpu.rb +5 -1
  24. data/lib/kanrisuru/remote/env.rb +8 -0
  25. data/lib/kanrisuru/remote/fstab.rb +5 -5
  26. data/lib/kanrisuru/result.rb +5 -4
  27. data/lib/kanrisuru/util.rb +1 -1
  28. data/lib/kanrisuru/version.rb +1 -1
  29. data/spec/functional/core/apt_spec.rb +22 -30
  30. data/spec/functional/core/archive_spec.rb +170 -0
  31. data/spec/functional/core/find_spec.rb +94 -113
  32. data/spec/functional/core/mount_spec.rb +121 -0
  33. data/spec/functional/core/socket_spec.rb +23 -28
  34. data/spec/functional/core/stream_spec.rb +12 -12
  35. data/spec/functional/core/transfer_spec.rb +108 -131
  36. data/spec/functional/core/yum_spec.rb +58 -83
  37. data/spec/functional/remote/cluster_spec.rb +11 -2
  38. data/spec/functional/remote/cpu_spec.rb +104 -0
  39. data/spec/functional/remote/env_spec.rb +48 -0
  40. data/spec/helper/stub_network.rb +49 -14
  41. data/spec/helper/test_hosts.rb +11 -1
  42. data/spec/integration/core/apt_spec.rb +2 -3
  43. data/spec/integration/core/archive_spec.rb +8 -13
  44. data/spec/integration/core/disk_spec.rb +2 -3
  45. data/spec/integration/core/dmi_spec.rb +2 -3
  46. data/spec/integration/core/file_spec.rb +4 -14
  47. data/spec/integration/core/find_spec.rb +3 -3
  48. data/spec/integration/core/group_spec.rb +2 -3
  49. data/spec/integration/core/ip_spec.rb +2 -3
  50. data/spec/integration/core/path_spec.rb +2 -3
  51. data/spec/integration/core/socket_spec.rb +2 -4
  52. data/spec/integration/core/stat_spec.rb +2 -3
  53. data/spec/integration/core/stream_spec.rb +6 -9
  54. data/spec/integration/core/system_spec.rb +2 -4
  55. data/spec/integration/core/transfer_spec.rb +4 -9
  56. data/spec/integration/core/user_spec.rb +2 -4
  57. data/spec/integration/core/yum_spec.rb +2 -3
  58. data/spec/integration/core/zypper_spec.rb +5 -6
  59. data/spec/{functional → integration}/os_package_spec.rb +0 -0
  60. data/spec/integration/remote/cpu_spec.rb +2 -3
  61. data/spec/integration/remote/env_spec.rb +2 -3
  62. data/spec/integration/remote/fstab_spec.rb +2 -3
  63. data/spec/integration/remote/host_spec.rb +2 -3
  64. data/spec/integration/remote/memory_spec.rb +2 -2
  65. data/spec/integration/remote/os_spec.rb +2 -3
  66. data/spec/integration/remote/remote_file_spec.rb +9 -15
  67. data/spec/spec_helper.rb +12 -3
  68. data/spec/unit/command_spec.rb +49 -0
  69. data/spec/unit/core/find_spec.rb +1 -1
  70. data/spec/unit/core/yum_spec.rb +1 -1
  71. data/spec/unit/mode_spec.rb +33 -2
  72. data/spec/unit/remote/cluster_spec.rb +3 -1
  73. data/spec/unit/remote/cpu_spec.rb +1 -2
  74. data/spec/unit/remote/env_spec.rb +17 -0
  75. data/spec/unit/util_spec.rb +13 -0
  76. metadata +28 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 584b31f227df31d0a5e45ae8abd18a4a8f87f73622b78cf7a59b66878ac79d4b
4
- data.tar.gz: c0917335ccd0955398574ad61756604e6f3516fd2e73958da733b711c16a152a
3
+ metadata.gz: f1401e8534eead10f860fbe8c4bd90397571d391ff4581c74d8ae427e4c32afa
4
+ data.tar.gz: bbba84a50446bc323ff21980c65ef1a0ff14dc316b8f731da0ee55c914ea2160
5
5
  SHA512:
6
- metadata.gz: f950255db2459f0ead9452c026059723da0deca9e8688dc0efae3c11bf00f3ddc3787f246d99f3ab9cc3893b12915309d91ce2f35c3bd22b8c905a9f5d387387
7
- data.tar.gz: 105d7d7193a037f357e14b31cc7af353a494810287b2dd557861077c27ec83cb64be3e64d2b9f49104438d0c5fe233d79374256c1a098bec8a50de335c3b20ba
6
+ metadata.gz: 3f89283777add5671cbb00d7294c204911aa8591a00582c11c560df1091be1cb459afe94450d468b2f85c17df3883805fb1776b2f49ef85846bbc2664c49a10e
7
+ data.tar.gz: 653788aa5d5f84a4290b7462437ce1cdc42be954b834c0c2398a7704ac8b3b0346718fbb0b423ad1770579960c8b3a371c6f6fc4b5688dabb75c175e55ea26d3
@@ -2,16 +2,16 @@
2
2
  Thank you for your interest in contributing to the Kanrisuru project. We appreciate any volunteers that want to help improve, grow and sustain the Kanrisuru code base!
3
3
 
4
4
  ## Submitting a bug
5
- * Do not open up a GitHub issue if the bug is a security vulnerability with the Kanrisuru project, instead send an email to engineeering@avamia.com for any security realted issues.
6
- * Check if there's already an existing issue before submitting a [similar one](https://github.com/avamia/kanrisuru/issues).
7
- * If you can't find a similar issue [open a new one](https://github.com/avamia/kanrisuru/issues/new?assignees=&labels=&template=bug_report.md). Be sure to include a **title and clear description**, as much relevant information as possible, and a **code sample** or an **executable test case** demonstrating the expected behavior that is not occurring.
5
+ * Do not open up a GitHub issue if the bug is a security vulnerability with the Kanrisuru project, instead send an email to engineeering@avamia.com for any security realted issues.
6
+ * Check if there's already an existing issue before submitting a [similar one](https://github.com/avamia/kanrisuru/issues).
7
+ * If you can't find a similar issue [open a new one](https://github.com/avamia/kanrisuru/issues/new?assignees=&labels=&template=bug_report.md). Be sure to include a **title and clear description**, as much relevant information as possible, and a **code sample** or an **executable test case** demonstrating the expected behavior that is not occurring.
8
8
 
9
9
  ## Adding a core feature
10
- * We always welcome improving the core Kanrisuru project. If we are missing a core command available on most linux distros, this would be a place to add that type of functionality.
11
- * Other ideas like performance optimization, additional testing, and ease of use are great ways of improving the project.
12
- * If you want to create something outside of the core project, see the next section.
10
+ * We always welcome improving the core Kanrisuru project. If we are missing a core command available on most linux distros, this would be a place to add that type of functionality.
11
+ * Other ideas like performance optimization, additional testing, and ease of use are great ways of improving the project.
12
+ * If you want to create something outside of the core project, see the next section.
13
13
 
14
14
  ## Adding a new module
15
- * If you want to extent Kanrisuru beyond the underlying system code base or core module packages, the best way is to create a new gem, in the format of `kanrisuru-package`.
16
- * This helps keep the core Kanrisuru package from too much bloat.
17
- * See our developer module section to see how to build a new Kanrisuru module.
15
+ * If you want to extent Kanrisuru beyond the underlying system code base or core module packages, the best way is to create a new gem, in the format of `kanrisuru-package`.
16
+ * This helps keep the core Kanrisuru package from too much bloat.
17
+ * See our developer module section to see how to build a new Kanrisuru module.
@@ -12,10 +12,10 @@ A clear and concise description of what the bug is.
12
12
 
13
13
  **To Reproduce**
14
14
  Steps to reproduce the behavior:
15
- 1. Go to '...'
16
- 2. Click on '....'
17
- 3. Scroll down to '....'
18
- 4. See error
15
+ 1. Go to '...'
16
+ 2. Click on '....'
17
+ 3. Scroll down to '....'
18
+ 4. See error
19
19
 
20
20
  **Expected behavior**
21
21
  A clear and concise description of what you expected to happen.
@@ -24,10 +24,9 @@ A clear and concise description of what you expected to happen.
24
24
  If applicable, add screenshots to help explain your problem.
25
25
 
26
26
  **Desktop (please complete the following information):**
27
- - OS: [e.g. Ubuntu]
28
- - Version [e.g. 22]
29
- - Ruby version: [e.g 2.7.4]
30
-
27
+ - OS: [e.g. Ubuntu]
28
+ - Version [e.g. 22]
29
+ - Ruby version: [e.g 2.7.4]
31
30
 
32
31
  **Additional context**
33
32
  Add any other context about the problem here.
data/.rspec CHANGED
@@ -1,3 +1,3 @@
1
- --format documentation
1
+ --format progress
2
2
  --color
3
3
  --require spec_helper
data/CHANGELOG.md CHANGED
@@ -1,106 +1,136 @@
1
+ ## Kanrisuru 0.12.0 (December 05, 20201) ##
2
+ * Add functional test cases for `mount` command.
3
+ * Fix typos and command preperation for `mount` command.
4
+ * Refactor `os_package` module into smaller modules for `Kanrisuru::OsPackage::Collection`, `Kanrisuru::OsPackage::Define`, and `Kanrisuru::OsPackage::Include`.
5
+ * Add `append_array` to `command` class for easy string to array conversion for variable option passing.
6
+ * Cleanup bad coding styles.
7
+ * Add parallel testing support for long running integration tests on remote servers.
8
+ * Refactor specs to use variable spec_dir path for parallel testing on remote hosts with possible overwriting at the same time.
9
+
10
+ ## Kanrisuru 0.11.1 (December 04, 2021) ##
11
+ * Cleanup self-assignment branches
12
+ * Fix linting issues.
13
+
14
+ ## Kanrisuru 0.11.0 (December 04, 2021) ##
15
+ * Add codequality badge, cleanup code linting issues.
16
+ * Fix `fstab` issue with blkid device return type.
17
+ * Fix `find` spec with sudo permissions.
18
+ * Change `stub_network` result override to use `block.call` with a conditional check for indvidual command stubs.
19
+ * Add `architecture` method to `cpu`.
20
+ * Add functional test cases for `cpu` class.
21
+ * Add more unit test cases.
22
+
23
+ ## Kanrisuru 0.10.0 (December 03, 2021) ##
24
+ * Add `stub_command` and `unstub_command` to mock indvidual command results from a remote server.
25
+ * Add `count` and `delete` to `Kanrisuru::Remote::Env` class for managing environment variables.
26
+ * Add unit and functional test cases for `Kanrisuru::Remote::Env`.
27
+ * Add functional test cases for the `archive` command.
28
+ * Fix typo bugs in the `archive` command. Fix `--exclude` opt field in `archive` command.
29
+ * Add unit test cases for `Kanrisuru::Mode` class.
30
+
1
31
  ## Kanrisuru 0.9.2 (November 30, 2021) ##
2
- * Add unit test cases for all core commands.
3
- * Add unit test cases for `cluster` class.
4
- * Add codecov xml output for coverage badge.
32
+ * Add unit test cases for all core commands.
33
+ * Add unit test cases for `cluster` class.
34
+ * Add codecov xml output for coverage badge.
5
35
 
6
36
  ## Kanrisuru 0.9.1 (November 29, 2021) ##
7
- * Fix type on `address_sizes` for `Kanrisuru::Remote::Cpu` class.
8
- * Add unit test cases for the `cpu` class.
37
+ * Fix type on `address_sizes` for `Kanrisuru::Remote::Cpu` class.
38
+ * Add unit test cases for the `cpu` class.
9
39
 
10
40
  ## Kanrisuru 0.9.0 (November 23, 2021) ##
11
- * Add `delete` to `Kanrisuru::Remote::Cluster` class to allow removal of hosts from cluster.
12
- * Add functional test cases for remote cluster class.
41
+ * Add `delete` to `Kanrisuru::Remote::Cluster` class to allow removal of hosts from cluster.
42
+ * Add functional test cases for remote cluster class.
13
43
 
14
44
  ## Kanrisuru 0.8.23 (November 19, 2021) ##
15
- * Add functional test cases for `yum` command
16
- * Add stub by operating system method, with support for `ubuntu` and `centos` os types.
17
- * Fix `ArgumentError` typo in yum commands, `erase` and `remove`.
45
+ * Add functional test cases for `yum` command
46
+ * Add stub by operating system method, with support for `ubuntu` and `centos` os types.
47
+ * Fix `ArgumentError` typo in yum commands, `erase` and `remove`.
18
48
 
19
49
  ## Kanrisuru 0.8.22 (November 18, 2021) ##
20
- * Add functional test cases for `apt` command
50
+ * Add functional test cases for `apt` command
21
51
 
22
52
  ## Kanrisuru 0.8.21 (November 15, 2021) ##
23
- * Fix bug with `Kanrisuru::Mode` class, lookup table had incorrect value for execute only symbolic to numeric field.
53
+ * Fix bug with `Kanrisuru::Mode` class, lookup table had incorrect value for execute only symbolic to numeric field.
24
54
 
25
55
  ## Kanrisuru 0.8.20 (November 13, 2021) ##
26
- * Unstub network requests for full rspec test-suite run
56
+ * Unstub network requests for full rspec test-suite run
27
57
 
28
58
  ## Kanrisuru 0.8.19 (October 31, 2021) ##
29
- * Add functional test cases for `ss` command.
30
- * Enforce contraints on `family` parameter for `ss` command.
31
- * Deprecating `string_join_array` in favor of `array_join_string`. Both methods do the same thing, and the `array_join_string` has a better nameing interface; will be removed in the next major release.
32
- * Replace `string_join_array` method calls in `apt`, `transfer`, `yum`, and `zypper` with `array_join_string`.
59
+ * Add functional test cases for `ss` command.
60
+ * Enforce contraints on `family` parameter for `ss` command.
61
+ * Deprecating `string_join_array` in favor of `array_join_string`. Both methods do the same thing, and the `array_join_string` has a better nameing interface; will be removed in the next major release.
62
+ * Replace `string_join_array` method calls in `apt`, `transfer`, `yum`, and `zypper` with `array_join_string`.
33
63
 
34
64
  ## Kanrisuru 0.8.18 (October 19, 2021) ##
35
- * Add functional test cases for `find` commmand.
36
- * Add `regex_type` option for `find` command.
37
- * Fix bug with `size` option when using number in a string format, regex testing has been simplified on matching correctness for size with options like `100`, `+100`, `-100M` for comparitive fields.
65
+ * Add functional test cases for `find` commmand.
66
+ * Add `regex_type` option for `find` command.
67
+ * Fix bug with `size` option when using number in a string format, regex testing has been simplified on matching correctness for size with options like `100`, `+100`, `-100M` for comparitive fields.
38
68
 
39
69
  ## Kanrisuru 0.8.17 (October 16, 2021) ##
40
- * Add functional test cases for `transfer` module
41
- * Update wget command to accept hash for `headers` opt.
70
+ * Add functional test cases for `transfer` module
71
+ * Update wget command to accept hash for `headers` opt.
42
72
 
43
73
  ## Kanrisuru 0.8.16 (October 14, 2021) ##
44
- * Add functional test cases for `stream` and `path` modules
45
- * Create `expect_command` helper for quick testing on raw command result
74
+ * Add functional test cases for `stream` and `path` modules
75
+ * Create `expect_command` helper for quick testing on raw command result
46
76
 
47
77
  ## Kanrisuru 0.8.15 (October 12, 20201) ##
48
- * Move functional specs to integration. Anything that performs an actual network request will be under the integrations test.
49
- * Create a `StubNetwork` to quickly monkey patch the `Kanrisuru::Remote::Host` to simulate a `Net::SSH` channel request. Will add additional functionality for different simulations later on.
50
- * Start with testing the `stat` command as a functional test.
78
+ * Move functional specs to integration. Anything that performs an actual network request will be under the integrations test.
79
+ * Create a `StubNetwork` to quickly monkey patch the `Kanrisuru::Remote::Host` to simulate a `Net::SSH` channel request. Will add additional functionality for different simulations later on.
80
+ * Start with testing the `stat` command as a functional test.
51
81
 
52
82
  ## Kanrisuru 0.8.14 (October 8, 20201) ##
53
- * Update `Kanrisuru::Remote::Cluster` instantiation method to use array splat instead of passing array directly.
83
+ * Update `Kanrisuru::Remote::Cluster` instantiation method to use array splat instead of passing array directly.
54
84
 
55
85
  ## Kanrisuru 0.8.13 (October 4, 20201) ##
56
- * Fix `wc` command. Ensure result parsing is cast to integer values.
86
+ * Fix `wc` command. Ensure result parsing is cast to integer values.
57
87
 
58
88
  ## Kanrisuru 0.8.12 (October 4, 20201) ##
59
- * Refactor `rmdir` command to only work on empty directories.
89
+ * Refactor `rmdir` command to only work on empty directories.
60
90
 
61
91
  ## Kanrisuru 0.8.11 (October 1, 20201) ##
62
- * Allow `Kanrisuru::Mode` as mode type option in mkdir method.
92
+ * Allow `Kanrisuru::Mode` as mode type option in mkdir method.
63
93
 
64
94
  ## Kanrisuru 0.8.10 (August 24, 20201) ##
65
- * Fix bug with rspec test case.
95
+ * Fix bug with rspec test case.
66
96
 
67
97
  ## Kanrisuru 0.8.9 (August 24, 2021) ##
68
- * Fix spelling error exception `ArgumentError` in `Kanrisuru::Mode` class.
98
+ * Fix spelling error exception `ArgumentError` in `Kanrisuru::Mode` class.
69
99
 
70
100
  ## Kanrisuru 0.8.8 (August 21, 2021) ##
71
- * Add shorthand notation for tar command actions, such as `x` for `extract`, `t` for `list`, and `c` for `create`.
101
+ * Add shorthand notation for tar command actions, such as `x` for `extract`, `t` for `list`, and `c` for `create`.
72
102
 
73
103
  ## Kanrisuru 0.8.7 (August 21, 2021) ##
74
- * Fix `FileInfo` field for ls command. Was set to `memory_blocks`, but was incorrect, corrected this to `hard_links`.
104
+ * Fix `FileInfo` field for ls command. Was set to `memory_blocks`, but was incorrect, corrected this to `hard_links`.
75
105
 
76
106
  ## Kanrisuru 0.8.6 (August 21, 2021) ##
77
- * Add `minimum_io_size`, `physical_sector_size`, and `logical_sector_size` to the blkid low level disk probe for devices.
107
+ * Add `minimum_io_size`, `physical_sector_size`, and `logical_sector_size` to the blkid low level disk probe for devices.
78
108
 
79
109
  ## Kanrisuru 0.8.5 (August 20, 2021) ##
80
- * Add `summarize` option to `du` command. This will only output a total disk usage size for the entire directory versus disk usage for each file individually.
110
+ * Add `summarize` option to `du` command. This will only output a total disk usage size for the entire directory versus disk usage for each file individually.
81
111
 
82
112
  ## Kanrisuru 0.8.4 (August 20, 2021) ##
83
- * Convert `fsize` field to an `integer` for du disk module command.
113
+ * Convert `fsize` field to an `integer` for du disk module command.
84
114
 
85
115
  ## Kanrisuru 0.8.3 (August 20, 2021) ##
86
- * Fix bug with disk usage, `du` command by escaping the awk variables in the command.
87
- * Update `du` command to execute with shell user.
116
+ * Fix bug with disk usage, `du` command by escaping the awk variables in the command.
117
+ * Update `du` command to execute with shell user.
88
118
 
89
119
  ## Kanrisuru 0.8.2 (August 19, 2021) ##
90
- * Convert `major` and `minor` device field values to an `integer` in lsblk disk module.
120
+ * Convert `major` and `minor` device field values to an `integer` in lsblk disk module.
91
121
 
92
122
  ## Kanrisuru 0.8.1 (August 19, 2021) ##
93
- * Fix `nodeps` flag value for `lsblk` command in disk module.
123
+ * Fix `nodeps` flag value for `lsblk` command in disk module.
94
124
 
95
125
  ## Kanrisuru 0.8.0 (August 18, 2021) ##
96
- * Add last / lastb implementation in system core module.
126
+ * Add last / lastb implementation in system core module.
97
127
 
98
128
  ## Kanrisuru 0.7.3 (August 9, 2021) ##
99
- * Fixed bug with zypper remove package, where the package names weren't being added to the linux command.
100
- * Test case added to ensure package is removed.
129
+ * Fixed bug with zypper remove package, where the package names weren't being added to the linux command.
130
+ * Test case added to ensure package is removed.
101
131
 
102
132
  ## Kanrisuru 0.7.2 (August 9, 2021) ##
103
- * Fixed bug with the `os_method_cache` instance variable set in the namespaced instance of a host. This was causing collision issues inbetween host instances, where, hosts with the same aliased method name was getting overwritten (with a different OS), since the namespace instance variable existing on the host class definition wasn't getting reset inbetween host instantiations. Given that the `os_method_cache` is normally re-instantiated, this bug fix addresses this so that the `os_method_cache` is always defined on the host instance, ie:
133
+ * Fixed bug with the `os_method_cache` instance variable set in the namespaced instance of a host. This was causing collision issues inbetween host instances, where, hosts with the same aliased method name was getting overwritten (with a different OS), since the namespace instance variable existing on the host class definition wasn't getting reset inbetween host instantiations. Given that the `os_method_cache` is normally re-instantiated, this bug fix addresses this so that the `os_method_cache` is always defined on the host instance, ie:
104
134
 
105
135
  ```ruby
106
136
  host.instance_variable_get(:@os_method_cache)
@@ -109,101 +139,100 @@
109
139
  This is done instead of being saved on the namespace module. With the previous bug fix of using namespaced keys, there's no way for a method to be overwritten otherwise with a global `os_method_cache`.
110
140
 
111
141
  ## Kanrisuru 0.7.1 (August 8, 2021) ##
112
- * Fix bug with `os_include` when caching namespace unbound methods, use the namespace in the
142
+ * Fix bug with `os_include` when caching namespace unbound methods, use the namespace in the
113
143
  cache key to avoid any namespace collisions with the same method name, namely:
114
144
  ```ruby
115
145
  "#{namespace}.#{method_name}"
116
146
  ```
117
147
 
118
148
  ## Kanrisuru 0.7.0 (August 8, 2021) ##
119
- * Simplify `FileInfo` struct for return object of `ls` command.
120
- * Rename `size` to `fsize` for the `OpenFile` struct to avoid method naming conflicts of the struct class.
121
- * Allow `os_include` and `os_collection` to define multiple groupings of methods with the same namespace.
122
- * Add `clear` method for remote env class, to remove any session based env variables.
123
- * Add `to_s` method to result for quick analysis of string based return values.
124
- * Remove duplicate `numeric` method in the utils module.
149
+ * Simplify `FileInfo` struct for return object of `ls` command.
150
+ * Rename `size` to `fsize` for the `OpenFile` struct to avoid method naming conflicts of the struct class.
151
+ * Allow `os_include` and `os_collection` to define multiple groupings of methods with the same namespace.
152
+ * Add `clear` method for remote env class, to remove any session based env variables.
153
+ * Add `to_s` method to result for quick analysis of string based return values.
154
+ * Remove duplicate `numeric` method in the utils module.
125
155
 
126
156
  ## Kanrisuru 0.6.0 (August 1, 2021) ##
127
- * Add `lsof` implementation in system core module
128
- * Fix changelog formatting
129
- * Add changelog url to gemspec
157
+ * Add `lsof` implementation in system core module
158
+ * Fix changelog formatting
159
+ * Add changelog url to gemspec
130
160
 
131
161
  ## Kanrisuru 0.5.2 (July 30, 2021) ##
132
- * Add changelog documentation
133
- * Update documentation table with new tested core module
134
- * Deprecating `cpu_info` with replacement of `lscpu`. `cpu_info` will be removed in the next major release.
162
+ * Add changelog documentation
163
+ * Update documentation table with new tested core module
164
+ * Deprecating `cpu_info` with replacement of `lscpu`. `cpu_info` will be removed in the next major release.
135
165
 
136
166
  ## Kanrisuru 0.5.1 (July 29, 2021) ##
137
- * Unit test cases for core module structs, constants and types.
167
+ * Unit test cases for core module structs, constants and types.
138
168
 
139
169
  ## Kanrisuru 0.5.0 (July 29, 2021) ##
140
- * Add `zypper` package manager core module
141
- * Add `dmi` core module. Support for getting hardware information from virtual and physical machines.
142
- * Add only options for test_hosts to filter on which hosts to use for function style test cases. This is used within a test case and takes priority over command line `HOSTS=` and `EXCLUDE=` env variables.
143
- * Add additional bit conversion string handling in the util module, such as kib, mib, and gib.
144
- * Remove redudant namespacing in struct names, such as
170
+ * Add `zypper` package manager core module
171
+ * Add `dmi` core module. Support for getting hardware information from virtual and physical machines.
172
+ * Add only options for test_hosts to filter on which hosts to use for function style test cases. This is used within a test case and takes priority over command line `HOSTS=` and `EXCLUDE=` env variables.
173
+ * Add additional bit conversion string handling in the util module, such as kib, mib, and gib.
174
+ * Remove redudant namespacing in struct names, such as
145
175
  `Kanrisuru::Core::Yum::YumPackageOverview`, to `Kanrisuru::Core::Yum::PackageOverview`.
146
- * Fix backups test case for `cp` command with the correct filename.
147
- * Use 0755 as expected numeric mode for all OS functional tests in the `mkdir` test case.
148
- * Fix bug with `lscpu` regex match on cpus with more than 9 cores, ie `/cpu\d/` to `/cpu\d+/`
176
+ * Fix backups test case for `cp` command with the correct filename.
177
+ * Use 0755 as expected numeric mode for all OS functional tests in the `mkdir` test case.
178
+ * Fix bug with `lscpu` regex match on cpus with more than 9 cores, ie `/cpu\d/` to `/cpu\d+/`
149
179
 
150
180
 
151
181
  ## Kanrisuru 0.4.1 (July 26, 2021) ##
152
- * Add `kernel_statistics` to system core module.
182
+ * Add `kernel_statistics` to system core module.
153
183
 
154
184
  ## Kanrisuru 0.4.0 (July 25, 2021) ##
155
- * Update internal exit code of command from 0, to array of accpeted exit codes, with 0 being the default value.
156
- * Add `append_exit_code` to command, allowing additional exit codes to be considered true for `success?` return value.
157
- * Add `@port` to `Net::SSH.start` method
158
- * Fix test case with `host.os` return value of `opensuse_leap`.
159
- * Add `cpu_flags` method to `cpu` module
185
+ * Update internal exit code of command from 0, to array of accpeted exit codes, with 0 being the default value.
186
+ * Add `append_exit_code` to command, allowing additional exit codes to be considered true for `success?` return value.
187
+ * Add `@port` to `Net::SSH.start` method
188
+ * Fix test case with `host.os` return value of `opensuse_leap`.
189
+ * Add `cpu_flags` method to `cpu` module
160
190
 
161
191
  ## Kanrisuru 0.3.2 (July 23, 2021) ##
162
- * Fix typo from `key` to `signal` in hash fetch method.
192
+ * Fix typo from `key` to `signal` in hash fetch method.
163
193
 
164
194
  ## Kanrisuru 0.3.1 (July 22, 2021) ##
165
- * Add additional methods to `cpu` pulling from `lscpu` struct.
166
- * Fix `address_size` in `cpu` method call.
195
+ * Add additional methods to `cpu` pulling from `lscpu` struct.
196
+ * Fix `address_size` in `cpu` method call.
167
197
 
168
198
  ## Kanrisuru 0.3.0 (July 22, 2021) ##
169
- * Add `lscpu` system core module
170
- * Replace `cpu` module internal fetching of data from `cpu_info` to `lscpu` struct.
199
+ * Add `lscpu` system core module
200
+ * Replace `cpu` module internal fetching of data from `cpu_info` to `lscpu` struct.
171
201
 
172
202
  ## Kanrisuru 0.2.9 (July 20, 2021) ##
173
- * Fix fstab entry from `entry` to `entry[:entry]` in the `for_each`iteration.
203
+ * Fix fstab entry from `entry` to `entry[:entry]` in the `for_each`iteration.
174
204
 
175
205
  ## Kanrisuru 0.2.8 (July 20, 2021) ##
176
- * Update gem development and runtime depedencies with stricter depencies.
206
+ * Update gem development and runtime depedencies with stricter depencies.
177
207
 
178
208
  ## Kanrisuru 0.2.7 (July 18, 2021) ##
179
- * Set opensuse upstream to sles (Suse Enterprise Linux) in `os_family`
209
+ * Set opensuse upstream to sles (Suse Enterprise Linux) in `os_family`
180
210
 
181
211
  ## Kanrisuru 0.2.6 (July 17, 2021) ##
182
- * Force "-" to "\_" from `os-release` release name in `host.os` module.
212
+ * Force "-" to "\_" from `os-release` release name in `host.os` module.
183
213
 
184
214
  ## Kanrisuru 0.2.5 (July 16, 2021) ##
185
- * Update gem depedencies to non-zero values
186
- * Change summary and description fields for `apt`
187
- * Move `normalize_size` from `apt` core module, to
188
- `Kanrisuru::Util::Bits` class.
189
- * Add additional test cases for `apt` core module.
190
- * Add `-hi` to `who` command to explicility print out ip address for user.
191
- * Update `inode?` command to execute without shell user.
192
- * Add `yum` package manager core module
215
+ * Update gem depedencies to non-zero values.
216
+ * Change summary and description fields for `apt`.
217
+ * Move `normalize_size` from `apt` core module, to `Kanrisuru::Util::Bits` class.
218
+ * Add additional test cases for `apt` core module.
219
+ * Add `-hi` to `who` command to explicility print out ip address for user.
220
+ * Update `inode?` command to execute without shell user.
221
+ * Add `yum` package manager core module
193
222
 
194
223
  ## Kanrisuru 0.2.4 (July 10, 2021) ##
195
- * Fix error in `ip_rule` and `ip_address` sub modules with command typo.
224
+ * Fix error in `ip_rule` and `ip_address` sub modules with command typo.
196
225
 
197
226
  ## Kanrisuru 0.2.3 (July 07, 2021) ##
198
- * Add `apt` package manager core module
227
+ * Add `apt` package manager core module
199
228
 
200
229
  ## Kanrisuru 0.2.2 (June 16, 2021) ##
201
- * Fix `read_file_chunk` on checking bounds for start and end line values.
230
+ * Fix `read_file_chunk` on checking bounds for start and end line values.
202
231
 
203
232
  ## Kanrisuru 0.2.1 (June 16, 2021) ##
204
- * Add first working release on rubygems.org
233
+ * Add first working release on rubygems.org
205
234
 
206
235
  ## Kanrisuru 0.2.0 (June 16, 2021) [YANKED] ##
207
236
 
208
237
  ## Kanrisuru 0.1.0 (December 12, 2020) ##
209
- * Initialize repository, start working on project.
238
+ * Initialize repository, start working on project.
data/CODE_OF_CONDUCT.md CHANGED
@@ -14,21 +14,21 @@ orientation.
14
14
  Examples of behavior that contributes to creating a positive environment
15
15
  include:
16
16
 
17
- * Using welcoming and inclusive language
18
- * Being respectful of differing viewpoints and experiences
19
- * Gracefully accepting constructive criticism
20
- * Focusing on what is best for the community
21
- * Showing empathy towards other community members
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
22
 
23
23
  Examples of unacceptable behavior by participants include:
24
24
 
25
- * The use of sexualized language or imagery and unwelcome sexual attention or
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
26
  advances
27
- * Trolling, insulting/derogatory comments, and personal or political attacks
28
- * Public or private harassment
29
- * Publishing others' private information, such as a physical or electronic
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
30
  address, without explicit permission
31
- * Other conduct which could reasonably be considered inappropriate in a
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
32
  professional setting
33
33
 
34
34
  ## Our Responsibilities
data/README.md CHANGED
@@ -1,12 +1,20 @@
1
- [![Latest version](https://img.shields.io/gem/v/kanrisuru?style=flat-square)](https://rubygems.org/gems/kanrisuru) 
2
- [![Latest version](https://img.shields.io/github/license/avamia/kanrisuru)](https://github.com/avamia/kanrisuru/blob/main/LICENSE.txt) 
3
- ![GitHub repo size](https://img.shields.io/github/repo-size/avamia/kanrisuru) 
4
- ![Codecov](https://img.shields.io/codecov/c/gh/avamia/kanrisuru?token=2Q1BE106B2) 
5
-
6
1
  <p align='center'>
7
2
  <img src="https://s3.us-east-2.amazonaws.com/kanrisuru.com/kanrisuru-banner-02.png" width="600" />
8
3
  </p>
9
4
 
5
+ <p align="center">
6
+ <a href="https://rubygems.org/gems/kanrisuru">
7
+ <img src="https://img.shields.io/gem/v/kanrisuru?style=flat-square" alt="Latest version" />
8
+ </a>
9
+ <a href="https://github.com/avamia/kanrisuru/blob/main/LICENSE.txt">
10
+ <img src="https://img.shields.io/github/license/avamia/kanrisuru" alt="Latest version" />
11
+ </a>
12
+ <img src="https://img.shields.io/github/repo-size/avamia/kanrisuru" alt="GitHub repo size" />
13
+ <img src="https://img.shields.io/codecov/c/gh/avamia/kanrisuru?token=2Q1BE106B2" alt="Codecov" />
14
+ <img src="https://img.shields.io/codacy/grade/9e839eb160bc445ea4e81b64cef22b27" alt="Codacy grade" />
15
+ <img src="https://img.shields.io/codeclimate/maintainability/avamia/kanrisuru" alt="Code Climate maintainability" />
16
+ </p>
17
+
10
18
  # Kanrisuru
11
19
 
12
20
  Kanrisuru (manage) helps you remotely control infrastructure using Ruby. This is done over SSH. I'm working on building up some basic functionality to help quickly provision, deploy and manage a single host or cluster of hosts.
@@ -27,14 +35,17 @@ gem 'kanrisuru'
27
35
 
28
36
  And then execute:
29
37
 
30
- $ bundle install
38
+ ```bash
39
+ $ bundle install
40
+ ```
31
41
 
32
42
  Or install it yourself as:
33
43
 
34
- $ gem install kanrisuru
44
+ ```bash
45
+ $ gem install kanrisuru
46
+ ```
35
47
 
36
48
  ## Usage
37
-
38
49
  Run basic commands you would have access to while running on a remote host or on a cluster of hosts.
39
50
 
40
51
  ### Host
@@ -78,88 +89,6 @@ cluster = Kanrisuru::Remote::Cluster.new(host, {host: 'host2', username: 'alice'
78
89
  cluster.execute('uname') #=> {host: 'host1', result: 'Linux'}, {host: 'host2', result: 'Linux'}
79
90
  ```
80
91
 
81
- ## Methods and Testing
82
-
83
- | Description | Ruby | Shell | Module | Man | Debian | Ubuntu | Fedora | Centos | RHEL | openSUSE | SLES |
84
- |---------------------------------------|------------------|--------------------|--------|--------------------------------------|--------|--------|--------|--------|------|----------|------|
85
- | **System** | | | | | | | | | | | |
86
- | Get CPU Info | cpu_info | lscpu | core | https://linux.die.net/man/1/lscpu | [x] | [x] | [x] | [x] | [x] | [x] | [x] |
87
- | Get CPU architecture | lscpu | lscpu | core | https://linux.die.net/man/1/lscpu | [x] | [x] | [x] | [x] | [x] | [x] | [x] |
88
- | Get kernel stastics | kernel_statistics | cat /proc/stat | core | | [x] | [x] | [x] | [x] | [x] | [x] | [x] |
89
- | Get hardware BIOS info | dmi | dmidecode | core | https://linux.die.net/man/8/dmidecode | [x] | [x] | [x] | [x] | [x] | [x] | [x] |
90
- | Get open file details for processes | lsof | lsof | core | https://linux.die.net/man/8/lsof | [x] | [x] | [x] | [x] | [x] | [x] | [x] |
91
- | Get Load Average | load_average | cat /proc/load_avg | core | | [x] | [x] | [x] | [x] | [x] | [x] | [x] |
92
- | Get RAM Available | free | cat /proc/meminfo | core | | [x] | [x] | [x] | [x] | [x] | [x] | [x] |
93
- | Get list of processes | ps | ps | core | https://linux.die.net/man/1/ps | [x] | [x] | [x] | [x] | [x] | [x] | [x] |
94
- | Get Env vars | load_env | env | core | | [x] | [x] | [x] | [x] | [x] | [x] | [x] |
95
- | Kill process | kill | kill | core | https://linux.die.net/man/1/kill | [x] | [x] | [x] | [x] | [x] | [x] | [x] |
96
- | Get uptime of system | uptime | cat /proc/uptime | core | https://linux.die.net/man/1/uptime | [x] | [x] | [x] | [x] | [x] | [x] | [x] |
97
- | Get who's logged in | w | w | core | https://linux.die.net/man/1/w | [x] | [x] | [x] | [x] | [x] | [x] | [x] |
98
- | Reboot machine | reboot | shutdown | core | https://linux.die.net/man/8/reboot | [x] | [x] | [x] | [x] | [x] | [x] | [x] |
99
- | Poweroff machine | poweroff | shutdown | core | https://linux.die.net/man/8/shutdown | [x] | [x] | [x] | [x] | [x] | [x] | [x] |
100
- | **Disk** | | | | | | | | | | | |
101
- | Get Disk Space | df | df | core | https://linux.die.net/man/1/df | [x] | [x] | [x] | [x] | [x] | [x] | [x] |
102
- | Get Disk Usage | du | du | core | https://linux.die.net/man/1/du | [x] | [x] | [x] | [x] | [x] | [x] | [x] |
103
- | List block devices | lsblk | lsblk | core | https://linux.die.net/man/8/lsblk | [x] | [x] | [x] | [x] | [x] | [x] | [x] |
104
- | Get block device attributes | blkid | blikd | core | https://linux.die.net/man/8/blkid | [x] | [x] | [x] | [x] | [x] | [x] | [x] |
105
- | **Mount** | | | | | | | | | | | |
106
- | Mount a filesystem | mount | mount | core | https://linux.die.net/man/8/mount | | | | | | | |
107
- | Unmount a filesystem | umount | umount | core | https://linux.die.net/man/8/umount | | | | | | | |
108
- | **Group** | | | | | | | | | | | |
109
- | Get Group Id | get_gid | getent group | core | https://linux.die.net/man/1/getent | [x] | [x] | [x] | [x] | [x] | [x] | [x] |
110
- | Get Group | get_group | grep /etc/group | core | | [x] | [x] | [x] | [x] | [x] | [x] | [x] |
111
- | Create Group | create_group | groupadd | core | https://linux.die.net/man/8/groupadd | [x] | [x] | [x] | [x] | [x] | [x] | [x] |
112
- | Update Group | update_group | groupmod | core | https://linux.die.net/man/8/groupmod | [x] | [x] | [x] | [x] | [x] | [x] | [x] |
113
- | Delete Group | delete_group | groupdel | core | https://linux.die.net/man/8/groupdel | [x] | [x] | [x] | [x] | [x] | [x] | [x] |
114
- | **User** | | | | | | | | | | | |
115
- | Get User Id | get_uid | id -u | core | https://linux.die.net/man/1/id | [x] | [x] | [x] | [x] | [x] | [x] | [x] |
116
- | Get User | get_user | id | core | https://linux.die.net/man/1/id | [x] | [x] | [x] | [x] | [x] | [x] | [x] |
117
- | Create User | create_user | useradd | core | https://linux.die.net/man/8/useradd | [x] | [x] | [x] | [x] | [x] | [x] | [x] |
118
- | Update User | update_user | usermod | core | https://linux.die.net/man/8/usermod | [x] | [x] | [x] | [x] | [x] | [x] | [x] |
119
- | Delete User | delete_user | userdel | core | https://linux.die.net/man/8/userdel | [x] | [x] | [x] | [x] | [x] | [x] | [x] |
120
- | **Path** | | | | | | | | | | | |
121
- | List files and directories | ls | ls | core | https://linux.die.net/man/1/ls | [x] | [x] | [x] | [x] | [x] | [x] | [x] |
122
- | Get Current Dir | pwd | pwd | core | https://linux.die.net/man/1/pwd | [x] | [x] | [x] | [x] | [x] | [x] | [x] |
123
- | Get Current User | whoami | whoami | core | https://linux.die.net/man/1/whoami | [x] | [x] | [x] | [x] | [x] | [x] | [x] |
124
- | Get Full Path of Shell Command | which | which | core | https://linux.die.net/man/1/which | [x] | [x] | [x] | [x] | [x] | [x] | [x] |
125
- | Real Path | realpath | realpath | core | https://linux.die.net/man/1/realpath | [x] | [x] | [x] | [x] | [x] | [x] | [x] |
126
- | Read link | readlink | readlink | core | https://linux.die.net/man/1/readlink | [x] | [x] | [x] | [x] | [x] | [x] | [x] |
127
- | Change Dir | cd | cd | core | | [x] | [x] | [x] | [x] | [x] | [x] | [x] |
128
- | **File** | | | | | | | | | | | |
129
- | "Find file, dir, special file device" | find | find | core | https://linux.die.net/man/1/find | [x] | [x] | [x] | [x] | [x] | [x] | [x] |
130
- | Stat file info | stat | stat | core | https://linux.die.net/man/1/stat | [x] | [x] | [x] | [x] | [x] | [x] | [x] |
131
- | Change Permission of file / folder | chmod | chmod | core | https://linux.die.net/man/1/chmod | [x] | [x] | [x] | [x] | [x] | [x] | [x] |
132
- | Change Ownership of file / folder | chown | chown | core | https://linux.die.net/man/1/chown | [x] | [x] | [x] | [x] | [x] | [x] | [x] |
133
- | Hard Link File | ln | ln | core | https://linux.die.net/man/1/ln | [x] | [x] | [x] | [x] | [x] | [x] | [x] |
134
- | Soft Link File / Dir | ln_s | ln | core | https://linux.die.net/man/1/ln | [x] | [x] | [x] | [x] | [x] | [x] | [x] |
135
- | Create Directory | mkdir | mkdir | core | https://linux.die.net/man/1/mkdir | [x] | [x] | [x] | [x] | [x] | [x] | [x] |
136
- | Remove file / directory | rm | rm | core | https://linux.die.net/man/1/rm | [x] | [x] | [x] | [x] | [x] | [x] | [x] |
137
- | Remove Directory | rmdir | rm | core | https://linux.die.net/man/1/rm | [x] | [x] | [x] | [x] | [x] | [x] | [x] |
138
- | Touch File | touch | touch | core | https://linux.die.net/man/1/touch | [x] | [x] | [x] | [x] | [x] | [x] | [x] |
139
- | Copy file / directory | cp | cp | core | https://linux.die.net/man/1/cp | [x] | [x] | [x] | [x] | [x] | [x] | [x] |
140
- | Move file / directory | mv | mv | core | https://linux.die.net/man/1/mv | [x] | [x] | [x] | [x] | [x] | [x] | [x] |
141
- | "Get file line, word, and char count" | wc | wc | core | https://linux.die.net/man/1/wc | [x] | [x] | [x] | [x] | [x] | [x] | [x] |
142
- | **Stream** | | | | | | | | | | | |
143
- | Get content from beginning of file | head | head | core | https://linux.die.net/man/1/head | [x] | [x] | [x] | [x] | [x] | [x] | [x] |
144
- | Get content from end of file | tail | tail | core | https://linux.die.net/man/1/tail | [x] | [x] | [x] | [x] | [x] | [x] | [x] |
145
- | Read a chunk from a file by lines | reach_file_chunk | tail and head | core | | [x] | [x] | [x] | [x] | [x] | [x] | [x] |
146
- | Echo to stdout or to file | echo | echo | core | https://linux.die.net/man/1/echo | [x] | [x] | [x] | [x] | [x] | [x] | [x] |
147
- | Get all content from a file | cat | cat | core | https://linux.die.net/man/1/cat | [x] | [x] | [x] | [x] | [x] | [x] | [x] |
148
- | Sed | sed | sed | core | https://linux.die.net/man/1/sed | [x] | [x] | [x] | [x] | [x] | [x] | [x] |
149
- | **Archive** | | | | | | | | | | | |
150
- | Tar Files | tar | tar | core | https://linux.die.net/man/1/tar | [x] | [x] | [x] | [x] | [x] | [x] | [x] |
151
- | **Network** | | | | | | | | | | | |
152
- | Manage network devices | ip | ip | core | https://linux.die.net/man/8/ip | [x] | [x] | [x] | [x] | [x] | [x] | [x] |
153
- | Get Socket Details | ss | ss | core | https://linux.die.net/man/8/ss | [x] | [x] | [x] | [x] | [x] | [x] | [x] |
154
- | **Transfer** | | | | | | | | | | | |
155
- | Upload to remote server | upload | scp | core | https://linux.die.net/man/1/scp | [x] | [x] | [x] | [x] | [x] | [x] | [x] |
156
- | Download from remote server | download | scp | core | https://linux.die.net/man/1/scp | [x] | [x] | [x] | [x] | [x] | [x] | [x] |
157
- | Wget | wget | wget | core | https://linux.die.net/man/1/wget | [x] | [x] | [x] | [x] | [x] | [x] | [x] |
158
- | **Packages** | | | | | | | | | | | |
159
- | Apt | apt | apt | core | https://linux.die.net/man/1/apt | [x] | [x] | | | | | |
160
- | Yum | yum | yum | core | https://linux.die.net/man/1/yum | | | [x] | [x] | [x] | | |
161
- | Zypper | zypper | zypper | core | https://en.opensuse.org/SDB:Zypper_manual | | | | | | [x] | [x] |
162
-
163
92
  ## Development
164
93
 
165
94
  After checking out the repo, run `bin/setup` to install dependencies.
data/kanrisuru.gemspec CHANGED
@@ -9,11 +9,12 @@ Gem::Specification.new do |gem|
9
9
  gem.email = 'ryan@avamia.com'
10
10
  gem.license = 'MIT'
11
11
  gem.summary = 'Manage remote servers over ssh with ruby.'
12
- gem.description = 'Kanrisuru helps manage remote servers with objected oriented ruby. Results come back as structured data, parsed, prepared and ready .'
12
+ gem.description = 'Kanrisuru helps manage remote servers with objected oriented ruby. Results come back as structured data, parsed, prepared and ready.'
13
13
  gem.homepage = 'https://github.com/avamia/kanrisuru'
14
14
 
15
15
  gem.required_ruby_version = '>= 2.5.0'
16
16
 
17
+ gem.add_development_dependency 'parallel_tests', '~> 3.7'
17
18
  gem.add_development_dependency 'rspec', '~> 3.10'
18
19
  gem.add_development_dependency 'rubocop', '~> 1.12'
19
20
  gem.add_development_dependency 'rubocop-rspec', '~> 2.2'
@@ -84,6 +84,13 @@ module Kanrisuru
84
84
  append_value("| #{value}")
85
85
  end
86
86
 
87
+ def append_array(value)
88
+ return unless Kanrisuru::Util.present?(value)
89
+
90
+ value = [value] if value.instance_of?(String)
91
+ append_value(value.join(' '))
92
+ end
93
+
87
94
  def append_value(value)
88
95
  @raw_command = "#{@raw_command} #{value}"
89
96
  end