kanrisuru 0.8.11 → 0.8.12

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5aa4c218e69710bd9ce035eca337448c240efc8e9b3e505dc1d70c4dea3e3190
4
- data.tar.gz: 488db0a56c43a223031ef657f21413aa0852f6edd2afb68b0c5f5eac97d81cd3
3
+ metadata.gz: 96b168459e76c64aa511a58fc43d0d777d5d783874e47a24c373dd6da2ef3ff4
4
+ data.tar.gz: 461c0236448253694f369cfc1b7757f61aeb0a4e0af3841cea62b6297d862c14
5
5
  SHA512:
6
- metadata.gz: b8c45c70ddfdfedb3dcad6698e9f1228ff1ce05aa222972f29e5979e33ef85dc7227dbe8532a50755a61342fec067fdde7303dfd4cba5048de9d44d4f6a27f65
7
- data.tar.gz: d417cbc907dd714ffc2385e13f6547b5fd0f42bd5e3f5c83531ace728e355a19a12d2156f4f7cb52b51d608984fe65966f0d287e72655c4088f4b24299d3afc3
6
+ metadata.gz: 4d8b47306256c698e30c7950fc18a59551fb156b14bc6e077df323a27832af8125f567213ec066ec1c8e5f7295411a0a113823ef4a6c97df0bbf5a6d753fc851
7
+ data.tar.gz: 5152a07e2d3580c4de9fb477d36c8de6f1d3fae3a6e234a6c3a80318524cb8ae6fefaebd984501f63b3b5de79350c2d9b53eac92b133453aebd1c47ba4323619
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
+ ## Kanrisuru 0.8.12 (October 3, 20201)
2
+ * Refactor `rmdir` command to only work on empty directories.
3
+
1
4
  ## Kanrisuru 0.8.11 (October 1, 20201)
2
- * Allow `Kanrisuru::Mode` as mode option in mkdir method.
5
+ * Allow `Kanrisuru::Mode` as mode type option in mkdir method.
3
6
 
4
7
  ## Kanrisuru 0.8.10 (August 24, 20201)
5
8
  * Fix bug with rspec test case.
@@ -206,10 +206,19 @@ module Kanrisuru
206
206
  Kanrisuru::Result.new(command)
207
207
  end
208
208
 
209
- def rmdir(path)
210
- return false unless dir?(path)
209
+ def rmdir(paths, opts = {})
210
+ paths = [paths] if paths.instance_of?(String)
211
+ paths.each do |path|
212
+ raise ArgumentError, "Can't delete root path" if path == '/' || realpath(path).path == '/'
213
+ end
211
214
 
212
- rm(path, force: true, recursive: true)
215
+ command = Kanrisuru::Command.new("rmdir #{paths.join(' ')}")
216
+ command.append_flag('--ignore-fail-on-non-empty', opts[:silent])
217
+ command.append_flag('--parents', opts[:parents])
218
+
219
+ execute_shell(command)
220
+
221
+ Kanrisuru::Result.new(command)
213
222
  end
214
223
 
215
224
  def mkdir(path, opts = {})
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Kanrisuru
4
- VERSION = '0.8.11'
4
+ VERSION = '0.8.12'
5
5
  end
@@ -40,8 +40,8 @@ RSpec.describe Kanrisuru::Core::File do
40
40
  keys: [host_json['ssh_key']]
41
41
  )
42
42
 
43
- host.rmdir("#{host_json['home']}/.kanrisuru_spec_files")
44
- host.rmdir("#{host_json['home']}/extract-tar-files") if host.dir?("#{host_json['home']}/extract-tar-files")
43
+ host.rm("#{host_json['home']}/.kanrisuru_spec_files", force: true, recursive: true)
44
+ host.rm("#{host_json['home']}/extract-tar-files", force: true, recursive: true) if host.dir?("#{host_json['home']}/extract-tar-files")
45
45
  host.disconnect
46
46
  end
47
47
 
@@ -322,6 +322,27 @@ RSpec.describe Kanrisuru::Core::File do
322
322
  expect(host.empty_file?(path)).to eq(false)
323
323
  end
324
324
 
325
+ it 'removes directories' do
326
+ result = host.mkdir("#{spec_dir}/directory/1", silent: true)
327
+ expect(result).to be_success
328
+
329
+ result = host.mkdir("#{spec_dir}/directory/2", silent: true)
330
+ expect(result).to be_success
331
+
332
+ result = host.mkdir("#{spec_dir}/directory/3", silent: true)
333
+ expect(result).to be_success
334
+
335
+ result = host.rmdir(["#{spec_dir}/directory/1", "#{spec_dir}/directory/2"])
336
+ expect(result).to be_success
337
+
338
+ ## Can't delete non empty dir
339
+ result = host.rmdir("#{spec_dir}/directory")
340
+ expect(result).to be_failure
341
+
342
+ result = host.rmdir("#{spec_dir}/directory/3")
343
+ expect(result).to be_success
344
+ end
345
+
325
346
  it 'counts a file' do
326
347
  result = host.wc('/etc/hosts')
327
348
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kanrisuru
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.11
4
+ version: 0.8.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Mammina
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-10-01 00:00:00.000000000 Z
11
+ date: 2021-10-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec