kanrisuru 0.8.9 → 0.8.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -0
- data/lib/kanrisuru/core/file.rb +24 -5
- data/lib/kanrisuru/version.rb +1 -1
- data/spec/functional/core/file_spec.rb +34 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f2465d4419a5fa15bc4ec736c6064e48386be6e130d4a934404b8a1b0f7eaaa0
|
4
|
+
data.tar.gz: 5441c0ae297aad2fdc7f08686eca97585793f747aaf92b32339da66c4343f3cf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 328fdfb44f1d0b18f4bd1fb49ab54779fb464e3f8948a8600f2d2e5cdddfe8ac351fa4499ee0f981a8f12fd262bf1d7757f71d721dafbf447834c8d6ff17ac6f
|
7
|
+
data.tar.gz: 20c59fd7d9e2e57e356beecf55809c3cbb009fe5d0e8b5692088731ed6bac3665e1e88f6e162d6cda1b7874e8a9a30e30ef52a6c5572cdfbd33f4328ee402eda
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
## Kanrisuru 0.8.13 (October 4, 20201)
|
2
|
+
* Fix `wc` command. Ensure result parsing is cast to integer values.
|
3
|
+
|
4
|
+
## Kanrisuru 0.8.12 (October 4, 20201)
|
5
|
+
* Refactor `rmdir` command to only work on empty directories.
|
6
|
+
|
7
|
+
## Kanrisuru 0.8.11 (October 1, 20201)
|
8
|
+
* Allow `Kanrisuru::Mode` as mode type option in mkdir method.
|
9
|
+
|
10
|
+
## Kanrisuru 0.8.10 (August 24, 20201)
|
11
|
+
* Fix bug with rspec test case.
|
12
|
+
|
1
13
|
## Kanrisuru 0.8.9 (August 24, 2021)
|
2
14
|
* Fix spelling error exception `ArgumentError` in `Kanrisuru::Mode` class.
|
3
15
|
|
data/lib/kanrisuru/core/file.rb
CHANGED
@@ -206,10 +206,19 @@ module Kanrisuru
|
|
206
206
|
Kanrisuru::Result.new(command)
|
207
207
|
end
|
208
208
|
|
209
|
-
def rmdir(
|
210
|
-
|
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
|
214
|
+
|
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)
|
211
220
|
|
212
|
-
|
221
|
+
Kanrisuru::Result.new(command)
|
213
222
|
end
|
214
223
|
|
215
224
|
def mkdir(path, opts = {})
|
@@ -219,7 +228,17 @@ module Kanrisuru
|
|
219
228
|
|
220
229
|
command = Kanrisuru::Command.new("mkdir #{path}")
|
221
230
|
command.append_flag('-p', opts[:silent])
|
222
|
-
|
231
|
+
|
232
|
+
if Kanrisuru::Util.present?(opts[:mode])
|
233
|
+
mode = opts[:mode]
|
234
|
+
if mode.instance_of?(Kanrisuru::Mode)
|
235
|
+
mode = mode.numeric
|
236
|
+
elsif mode.instance_of?(String) && (mode.include?(',') || /[=+-]/.match(mode))
|
237
|
+
mode = Kanrisuru::Mode.new(mode).numeric
|
238
|
+
end
|
239
|
+
|
240
|
+
command.append_arg('-m', mode)
|
241
|
+
end
|
223
242
|
|
224
243
|
execute_shell(command)
|
225
244
|
|
@@ -313,7 +332,7 @@ module Kanrisuru
|
|
313
332
|
execute_shell(command)
|
314
333
|
|
315
334
|
Kanrisuru::Result.new(command) do |cmd|
|
316
|
-
items = cmd.
|
335
|
+
items = cmd.to_s.split
|
317
336
|
FileCount.new(items[0].to_i, items[1].to_i, items[2].to_i)
|
318
337
|
end
|
319
338
|
end
|
data/lib/kanrisuru/version.rb
CHANGED
@@ -40,8 +40,8 @@ RSpec.describe Kanrisuru::Core::File do
|
|
40
40
|
keys: [host_json['ssh_key']]
|
41
41
|
)
|
42
42
|
|
43
|
-
host.
|
44
|
-
host.
|
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
|
|
@@ -69,7 +69,7 @@ RSpec.describe Kanrisuru::Core::File do
|
|
69
69
|
expect(mode.to_i).to eq(0o744)
|
70
70
|
|
71
71
|
expect {
|
72
|
-
host.chmod(path, 600)
|
72
|
+
host.chmod(path, 600)
|
73
73
|
}.to raise_error(ArgumentError)
|
74
74
|
end
|
75
75
|
|
@@ -322,16 +322,44 @@ 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
|
|
328
349
|
expect(result.success?).to eq(true)
|
329
350
|
expect(result).to respond_to(:lines, :words, :characters)
|
330
351
|
|
331
|
-
|
332
|
-
|
352
|
+
## Need to remap data including newline chars to get byte size
|
353
|
+
data = host.cat('/etc/hosts').command.raw_result
|
354
|
+
doc = data.map(&:lines).flatten
|
355
|
+
|
356
|
+
lines = doc.length
|
357
|
+
words = doc.map(&:split).flatten
|
358
|
+
chars = doc.map(&:length).flatten
|
333
359
|
|
334
|
-
expect(lines).to eq(
|
360
|
+
expect(result.lines).to eq(doc.length)
|
361
|
+
expect(result.words).to eq(words.length)
|
362
|
+
expect(result.characters).to eq(chars.sum)
|
335
363
|
end
|
336
364
|
end
|
337
365
|
end
|
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.
|
4
|
+
version: 0.8.13
|
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-
|
11
|
+
date: 2021-10-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|