du_pretty 1.0.0 → 1.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ce0aca2585c229b53a15e07c61b9094f84043283a5b2c04039ca725159114221
4
- data.tar.gz: cfca7a497467e073a785d08a4202226b9912aec36718e3d5e67649e6a01e03c2
3
+ metadata.gz: 137d8bb9256e03a3eaca29f905a6a4acdbeb10339073ae166d2c5fd493b78258
4
+ data.tar.gz: 4de639c8fe1a5916f780f4f35f01e0912aa3ed8ad8d8bd15a21e0d9b220a43df
5
5
  SHA512:
6
- metadata.gz: 6ba1550a280b5e941f02178b57a2177486ea4fc4393ad8e7c648a5442179a4a0dc9da03307b05cdb6e2840e40f1e37ecee20a3269e5baee4648925e9ecf170ec
7
- data.tar.gz: 8c245f9484adf87550ee85dfbcfb6c4bbafbde923c7ce299446497d45423efacfa9e942e4d04896c16580b8b44718dde98f1774f162ecab426b3cf1531d67295
6
+ metadata.gz: c6f257d7ee71f32777544fc1211f19ea36ed9a41bfc1a3e15db5bc99cc3c2e1c765874a31fe04418795c29632473e20846d78c406f13c5eeaae899f64120faa0
7
+ data.tar.gz: bf69a945663420dc05e6aadcd5856e457e3b9e92faa7173518f912b5c6ecc2cc7904114400b799bf494fdcc3f969167ceb80914b3f379dc2a6061a96f68b265d
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- du_pretty (1.0.0)
4
+ du_pretty (1.0.1)
5
5
  colorize (~> 0.8.1)
6
6
  thor (~> 0.20.0)
7
7
 
data/README.md CHANGED
@@ -5,9 +5,9 @@
5
5
  [![Maintainability](https://api.codeclimate.com/v1/badges/2cc73b7dea6a066b6f9b/maintainability)](https://codeclimate.com/github/nullnull/du_pretty/maintainability)
6
6
  [![Test Coverage](https://api.codeclimate.com/v1/badges/2cc73b7dea6a066b6f9b/test_coverage)](https://codeclimate.com/github/nullnull/du_pretty/test_coverage)
7
7
 
8
- Show pretty print of `du` results.
8
+ Show pretty print of `du` outputs.
9
9
 
10
- [![Image from Gyazo](https://i.gyazo.com/c364be05ccbfcef881028a1e7e491e56.png)](https://gyazo.com/c364be05ccbfcef881028a1e7e491e56)
10
+ [![Image from Gyazo](https://i.gyazo.com/75f461882b3d0ba01dce40c79de543dd.png)](https://gyazo.com/75f461882b3d0ba01dce40c79de543dd)
11
11
 
12
12
  ## Installation
13
13
  ```sh
@@ -19,19 +19,29 @@ $ gem install 'du_pretty'
19
19
  $ du_pretty <path>
20
20
 
21
21
  # specify max depth
22
- $ du_pretty -d 2 <path>
22
+ $ du_pretty <path> -d 2
23
23
 
24
24
  # Filter results of `du` by its file's size
25
- $ du_pretty --size 10M <path>
25
+ $ du_pretty <path> --size 10M
26
+ ```
27
+
28
+ [![Image from Gyazo](https://i.gyazo.com/e3668cda06afde799fee8d8cf16abaa2.png)](https://gyazo.com/e3668cda06afde799fee8d8cf16abaa2)
26
29
 
30
+
31
+ ```sh
27
32
  # Show results sorted by the file's size
28
- $ du_pretty --sort <path>
33
+ $ du_pretty <path> --sort
34
+ ```
35
+
36
+ [![Image from Gyazo](https://i.gyazo.com/d8ddc6c2a12a80bf7d07eaf9d63aa0b0.png)](https://gyazo.com/d8ddc6c2a12a80bf7d07eaf9d63aa0b0)
29
37
 
38
+ ```sh
30
39
  # help
31
40
  $ du_pretty --help
32
41
  ```
33
42
 
34
43
 
44
+
35
45
  ## Development
36
46
  ```sh
37
47
  # run
@@ -73,25 +73,27 @@ module DuPretty
73
73
  end
74
74
 
75
75
  def pretty_byte
76
- mb = @kbyte / 1024
76
+ mb = @kbyte * 1.0 / 1024
77
77
  gb = mb / 1024
78
- if gb.positive?
78
+ byte_format = ->(x) { x.to_i >= 10 ? x.to_i : x.round(1) }
79
+ f = ->(value, unit, color) { "#{byte_format.call(value)}#{unit} (#{percentage})".send(color) }
80
+ if gb >= 1.0
79
81
  if gb > 10
80
- "#{gb}GB (#{percentage})".red
82
+ f.call(gb, 'GB', :red)
81
83
  else
82
- "#{gb}GB (#{percentage})".light_red
84
+ f.call(gb, 'GB', :light_red)
83
85
  end
84
- elsif mb.positive?
86
+ elsif mb >= 1.0
85
87
  if mb > 500
86
- "#{mb}MB (#{percentage})".yellow
88
+ f.call(mb, 'MB', :yellow)
87
89
  else
88
- "#{mb}MB (#{percentage})".light_yellow
90
+ f.call(mb, 'MB', :light_yellow)
89
91
  end
90
92
  else
91
93
  if @kbyte > 500
92
- "#{@kbyte}KB (#{percentage})".green
94
+ f.call(@kbyte, 'KB', :green)
93
95
  else
94
- "#{@kbyte}KB (#{percentage})".light_green
96
+ f.call(@kbyte, 'KB', :light_green)
95
97
  end
96
98
  end
97
99
  end
@@ -1,3 +1,3 @@
1
1
  module DuPretty
2
- VERSION = '1.0.0'.freeze
2
+ VERSION = '1.0.1'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: du_pretty
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Katsuma Narisawa
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-09-04 00:00:00.000000000 Z
11
+ date: 2018-09-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler