diskman 1.0.7 → 1.0.8

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: 938bb0e7e84ca51b0d0b8da9f86897021bbcd66a1b057a5c66839fd6c20d422b
4
- data.tar.gz: dc7ae8ad6a1748c2303fced0954baa2a1fc25334e70d487d817e00076cd5f461
3
+ metadata.gz: 6b601bff2adbe81099f2b8c279a9757a99d0afc8b62fbec38a8cff8140fb7b1f
4
+ data.tar.gz: 12579cdae49bf6a812e0a415ab7bc273f0106dee52880e2a2850c4f1ea9ad680
5
5
  SHA512:
6
- metadata.gz: 01ac80d9354794fa4e853f0a7be432bdb5533ecfe102266144d60ccc3c4ed947f28a04b6a9c28a2c44d82df6dc8e16c30393285dd9f2c03e8ac089daabf2e5f0
7
- data.tar.gz: f5f257c4330f155af16dd94a08a20e3a15528d7de5de2c36190e46df4e4e363debe08120a50a312ba0641798007295fe1e28b96c6405b831892007af3d5bd1e1
6
+ metadata.gz: 99c8eeb4df39180d09418c9b8707df8bb1413aaa4c6ec55a2f058a66ce017e1a2a51b12254a7461dbfc2215aa0138995fdcd7b179f7987116eed8826bd938ab5
7
+ data.tar.gz: 05051535ce5c6007a5e6372e7c779b73b48e6ea920a16e7876533063b0d9ed754a21f2a1e1f5ace6b015eb01654230f78ec18e8e2684c4d13237f3790aa7947b
data/bin/diskman CHANGED
@@ -1,9 +1,9 @@
1
1
  #!/usr/bin/env ruby
2
2
  require_relative '../lib/diskman'
3
- include Diskman
4
-
5
3
  require 'docopt'
6
4
 
5
+ include Diskman # rubocop:disable Style/MixinUsage
6
+
7
7
  class Main
8
8
  def initialize(opts)
9
9
  @opts = opts
@@ -37,7 +37,7 @@ class Main
37
37
  elsif params.fdisk
38
38
  Command::Fdisk.new.run
39
39
  end
40
- rescue Interrupt => e
40
+ rescue Interrupt # rubocop:disable Lint/SuppressedException
41
41
  end
42
42
  end
43
43
 
@@ -55,7 +55,7 @@ EOF
55
55
 
56
56
  begin
57
57
  Main.run(Docopt.docopt(usage))
58
- rescue Docopt::Exit => e
58
+ rescue Docopt::Exit
59
59
  puts usage
60
60
  exit 2
61
61
  end
@@ -30,7 +30,7 @@ module Diskman
30
30
  puts
31
31
 
32
32
  @items.each_with_index do |device, i|
33
- puts "%6d. %s" % [i + 1, device]
33
+ puts '%6d. %s' % [i + 1, device]
34
34
  end
35
35
 
36
36
  puts
@@ -3,7 +3,7 @@ module Command
3
3
  def run
4
4
  root_device = RootDevice.choose
5
5
  cmd = root_device.get_fdisk_command
6
- System.exec! cmd, safe: false
6
+ System.exec!(cmd, safe: false)
7
7
  end
8
8
  end
9
9
  end
@@ -22,7 +22,7 @@ module Command
22
22
  puts "Device: #{device.to_s.yellow}"
23
23
  puts "Command: #{cmd.yellow}"
24
24
 
25
- System.exec! cmd
25
+ System.exec!(cmd)
26
26
  end
27
27
  end
28
28
  end
@@ -1,7 +1,7 @@
1
1
  module Command
2
2
  class Write
3
3
  def run(file:)
4
- if !File.exists?(file)
4
+ if !File.exist?(file)
5
5
  puts ('Unable to read ' + file).red
6
6
  raise Interrupt
7
7
  end
@@ -10,13 +10,13 @@ module Command
10
10
  device = device.choose_with_partitions
11
11
 
12
12
  size = File.size(file)
13
- cmd = device.get_write_command(file, size)
13
+ cmd = device.get_write_command(file)
14
14
 
15
15
  puts "File: #{file.yellow} (#{System.bytes2human(size)})"
16
16
  puts "Device: #{device.to_s.yellow}"
17
17
  puts "Command: #{cmd.yellow}"
18
18
 
19
- System.exec! cmd
19
+ System.exec!(cmd)
20
20
  end
21
21
  end
22
22
  end
@@ -16,7 +16,7 @@ module Diskman
16
16
  'sudo mkfs.%s %s' % [fs, @path]
17
17
  end
18
18
 
19
- def get_write_command(path, bytes)
19
+ def get_write_command(path)
20
20
  dd = 'sudo dd if="%s" of="%s" bs=%dK status=progress'
21
21
  dd % [path, @path, 4096]
22
22
  end
@@ -27,8 +27,8 @@ module Diskman
27
27
 
28
28
  private
29
29
 
30
- def <=>(o)
31
- @path <=> o.path
30
+ def <=>(other)
31
+ @path <=> other.path
32
32
  end
33
33
  end
34
34
  end
@@ -35,7 +35,7 @@ module Diskman
35
35
  private
36
36
 
37
37
  def get_with_partitions
38
- Dir[@path + '*'].sort.map do |file|
38
+ Dir[@path + '*'].map do |file|
39
39
  file =~ %r[/dev/(.*)] && Device.new($1)
40
40
  end.sort
41
41
  end
@@ -45,7 +45,7 @@ module Diskman
45
45
  end
46
46
 
47
47
  def get_prop(name)
48
- file = "/sys/class/block/%s/%s" % [@name, name]
48
+ file = '/sys/class/block/%s/%s' % [@name, name]
49
49
  File.read(file).strip.gsub(/\s+/, ' ')
50
50
  end
51
51
 
@@ -15,7 +15,7 @@ module Diskman
15
15
  Confirmer.check! if safe
16
16
  prepare_sudo_session! if sudo
17
17
  puts
18
- exec cmd
18
+ exec(cmd)
19
19
  end
20
20
 
21
21
  # Convert bytes into a human-friendly representation.
@@ -26,7 +26,7 @@ module Diskman
26
26
  # advertised.
27
27
  k = 1000
28
28
 
29
- suffixes = ['T', 'G', 'M', 'K', 'B']
29
+ suffixes = %w[T G M K B]
30
30
 
31
31
  suffixes.each_with_index do |suffix, i|
32
32
  threshold = k ** (suffixes.length - i - 1)
@@ -1,3 +1,3 @@
1
1
  module Diskman
2
- VERSION = '1.0.7'
2
+ VERSION = '1.0.8'
3
3
  end
data/lib/diskman.rb CHANGED
@@ -5,7 +5,7 @@ require 'ostruct'
5
5
 
6
6
  module Diskman
7
7
  def self.root_dir
8
- File.expand_path('../..', __FILE__)
8
+ File.expand_path('..', __dir__)
9
9
  end
10
10
  end
11
11
 
metadata CHANGED
@@ -1,71 +1,71 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: diskman
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.7
4
+ version: 1.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - crdx
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-10-05 00:00:00.000000000 Z
11
+ date: 2021-10-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: require_all
14
+ name: colorize
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '3.0'
19
+ version: 0.8.1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '3.0'
26
+ version: 0.8.1
27
27
  - !ruby/object:Gem::Dependency
28
- name: colorize
28
+ name: docopt
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 0.8.1
33
+ version: 0.6.1
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 0.8.1
40
+ version: 0.6.1
41
41
  - !ruby/object:Gem::Dependency
42
- name: docopt
42
+ name: require_all
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 0.6.1
47
+ version: '3.0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 0.6.1
54
+ version: '3.0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: simplecov
56
+ name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 0.21.0
61
+ version: '13.0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 0.21.0
68
+ version: '13.0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -81,19 +81,19 @@ dependencies:
81
81
  - !ruby/object:Gem::Version
82
82
  version: '3.8'
83
83
  - !ruby/object:Gem::Dependency
84
- name: rake
84
+ name: simplecov
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '13.0'
89
+ version: 0.21.0
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '13.0'
96
+ version: 0.21.0
97
97
  description:
98
98
  email:
99
99
  executables:
@@ -125,7 +125,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
125
125
  requirements:
126
126
  - - ">="
127
127
  - !ruby/object:Gem::Version
128
- version: '0'
128
+ version: '3.0'
129
129
  required_rubygems_version: !ruby/object:Gem::Requirement
130
130
  requirements:
131
131
  - - ">="