img-lint 0.0.12 → 0.0.13

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
  SHA1:
3
- metadata.gz: 6cf50c5e2e6d1df21d7d3a185ce614779ec25754
4
- data.tar.gz: 9fa79b54735ef29baf629ca2ad65be98265f4a3f
3
+ metadata.gz: 9cef312bda480bd565a3fa0129f7e0a2bdb5acba
4
+ data.tar.gz: a6bb76b6693cf0e87d0a3071ba08c825a5103e17
5
5
  SHA512:
6
- metadata.gz: ac14a3b290a8f67cde73748c0dbe95637a4e97dc7a32dd33ff0b5c3b71d8c5fd5279b339cd5bb2b9678da2215bd223ce5ec473f57f7ed869d834d0ecf8dcfd81
7
- data.tar.gz: b44b63f86d212701dd0f682a13634255ddaee87f73ad556d593ddf256de31559a198d226e7ff93a543aa4366a64ffbc835db8c33cd2725e1f840fbe426d8e2cb
6
+ metadata.gz: 6cfd16d63dc42a9702de342c553a4b0d5c557b0a4a9faaf715871fc78c34f6409feee37ab655db6a8d075b54ea5fe8474225bbb58fc582b416c08ebb38aef369
7
+ data.tar.gz: 583aaa380ec3aa287f09af1b442e76a4f74d227f484661537d658007a7d435e96e34501b098847ef368850c40ec8b1a79cd6d8e09ebe95ee039ececd8a8c3a19
@@ -18,7 +18,7 @@ else
18
18
  options = {}
19
19
  OptionParser.new do |opts|
20
20
  def unindent(s)
21
- s.gsub(/^#{s.scan(/^[ \t]+(?=\S)/).min}/, '')
21
+ s.gsub(/^#{s.scan(/^[ \t]+(?=\S)/).min}/, "")
22
22
  end
23
23
 
24
24
  opts.banner = unindent(<<-TEXT)
@@ -28,8 +28,12 @@ module IMGLint
28
28
 
29
29
  puts "No images found in #{path}" if verbose && images.empty?
30
30
 
31
- images.select do |file|
32
- !excluded_file?(file) && File.new(file).size > config["max_file_size"] * 1024
31
+ images.each_with_object({}) do |file, o|
32
+ image_size = File.new(file).size / 1024
33
+
34
+ if !excluded_file?(file) && image_size > config["max_file_size"]
35
+ o[file] = image_size
36
+ end
33
37
  end
34
38
  end
35
39
 
@@ -54,15 +58,13 @@ module IMGLint
54
58
 
55
59
  puts "Suspicious images:"
56
60
 
57
- fat_images = fat_images.inject({}) do |hash, image|
58
- hash[image] = File.new(image).size / 1024
59
- hash
60
- end
61
+ longest_image_path = fat_images.keys.max { |k| k.size }.size
62
+ longest_file_size = fat_images.values.max { |v| v.to_s.size }.size
61
63
 
62
64
  fat_images.sort_by(&:last).reverse.each do |image, file_size|
63
65
  image = image.sub(Dir.pwd, "") if Dir.pwd == path
64
66
 
65
- puts [image, "#{file_size}Kb"].join("\t")
67
+ puts [image.ljust(longest_image_path), "#{file_size}Kb".rjust(longest_file_size)].join("\t")
66
68
  end
67
69
  end
68
70
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module IMGLint
4
- VERSION = "0.0.12".freeze
4
+ VERSION = "0.0.13".freeze
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: img-lint
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.12
4
+ version: 0.0.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anatoli Makarevich