kickin_ristretto 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/Gemfile.lock +9 -0
- data/README.md +7 -0
- data/kickin_ristretto.gemspec +3 -0
- data/lib/kickin_ristretto/version.rb +1 -1
- data/lib/kickin_ristretto.rb +46 -4
- data/lib/tasks/ristretto.rake +11 -1
- metadata +30 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c2dc8a2b3c5b3f58c71bfce23744f376ac4627b5
|
4
|
+
data.tar.gz: e46d12fe4411b1469347ce40d50d1ce636fd338f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b71aff0c6bdcf3c1a5fc23333d85ffbf81875225c7672d9a53d872a52cc2aa7e3ad6412c6ff0e30d15c87c84ab9556388c11574e9fa92f96ca18e74d3f96fd76
|
7
|
+
data.tar.gz: 069b472f1087c59ad351eac865a09a2c5d9883d243f6bfd515f0090d9fe0558fa379c5391d82c4ae4063cb1a934a687c5e6d3a835e3668a8b6b76984d5d1d349
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
@@ -2,11 +2,19 @@ PATH
|
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
4
|
kickin_ristretto (0.1.0)
|
5
|
+
prawn (~> 2.2.2)
|
6
|
+
prawn-table (~> 0.2.2)
|
5
7
|
|
6
8
|
GEM
|
7
9
|
remote: https://rubygems.org/
|
8
10
|
specs:
|
9
11
|
diff-lcs (1.3)
|
12
|
+
pdf-core (0.7.0)
|
13
|
+
prawn (2.2.2)
|
14
|
+
pdf-core (~> 0.7.0)
|
15
|
+
ttfunk (~> 1.5)
|
16
|
+
prawn-table (0.2.2)
|
17
|
+
prawn (>= 1.3.0, < 3.0.0)
|
10
18
|
rake (10.5.0)
|
11
19
|
rspec (3.7.0)
|
12
20
|
rspec-core (~> 3.7.0)
|
@@ -21,6 +29,7 @@ GEM
|
|
21
29
|
diff-lcs (>= 1.2.0, < 2.0)
|
22
30
|
rspec-support (~> 3.7.0)
|
23
31
|
rspec-support (3.7.1)
|
32
|
+
ttfunk (1.5.1)
|
24
33
|
|
25
34
|
PLATFORMS
|
26
35
|
ruby
|
data/README.md
CHANGED
@@ -22,6 +22,8 @@ Or install it yourself as:
|
|
22
22
|
## Usage
|
23
23
|
|
24
24
|
$ rake kickin_ristretto:analyze
|
25
|
+
|
26
|
+
$ rake kickin_ristretto:image_audit_report
|
25
27
|
|
26
28
|
## Development
|
27
29
|
|
@@ -44,3 +46,8 @@ Everyone interacting in the KickinRistretto project’s codebases, issue tracker
|
|
44
46
|
## Sponsors
|
45
47
|
|
46
48
|
This project is sponsored by [KickinEspresso](https://kickinespresso.com/?utm_source=github&utm_medium=sponsor&utm_campaign=opensource)
|
49
|
+
|
50
|
+
|
51
|
+
## Build
|
52
|
+
|
53
|
+
gem build kickin_ristretto.gemspec
|
data/kickin_ristretto.gemspec
CHANGED
@@ -35,4 +35,7 @@ Gem::Specification.new do |spec|
|
|
35
35
|
spec.add_development_dependency "bundler", "~> 1.16"
|
36
36
|
spec.add_development_dependency "rake", "~> 10.0"
|
37
37
|
spec.add_development_dependency "rspec", "~> 3.0"
|
38
|
+
spec.add_dependency('prawn', '~> 2.2.2')
|
39
|
+
spec.add_dependency('prawn-table', '~> 0.2.2')
|
40
|
+
|
38
41
|
end
|
data/lib/kickin_ristretto.rb
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'kickin_ristretto/version'
|
4
|
+
require 'prawn'
|
5
|
+
require 'prawn/table'
|
6
|
+
#require 'prawn-table'
|
4
7
|
|
5
8
|
module KickinRistretto
|
6
9
|
if defined?(Rails)
|
@@ -16,10 +19,10 @@ module KickinRistretto
|
|
16
19
|
end
|
17
20
|
end
|
18
21
|
|
19
|
-
# Search the
|
20
|
-
|
21
|
-
|
22
|
-
images =
|
22
|
+
# Search through all images in the project and check to see if they are referenced somewhere
|
23
|
+
# If they are not referenced, prompt to delete them
|
24
|
+
def clean_non_referenced_images(image_directory = 'app/assets/images')
|
25
|
+
images = search_directory(image_directory)
|
23
26
|
legacy_images = collect_none_referenced_images(images)
|
24
27
|
puts "\n Is this what you want to happen? [Y/N]"
|
25
28
|
answer = STDIN.gets.chomp
|
@@ -31,6 +34,40 @@ module KickinRistretto
|
|
31
34
|
end
|
32
35
|
end
|
33
36
|
|
37
|
+
|
38
|
+
# Produce a PDF report listing all the images in the website
|
39
|
+
def image_audit_report(image_directory = 'app/assets/images')
|
40
|
+
images = search_directory(image_directory)
|
41
|
+
#filtered_images = get_all_images_by_type(images)['.gif', '.png', '.jpg', '.jpeg', '.JPG', '.JPEG']
|
42
|
+
filtered_images = get_all_images_by_type(images).values_at('.png', '.jpg', '.jpeg', '.JPG', '.JPEG').flatten
|
43
|
+
filtered_images = filtered_images.reject { |v| v.nil? }
|
44
|
+
|
45
|
+
Prawn::Document.generate("image_audit_report.pdf") do
|
46
|
+
text "Image Audit Report"
|
47
|
+
|
48
|
+
data = [["File Path", "Image"]]
|
49
|
+
filtered_images.each do |image|
|
50
|
+
# puts image
|
51
|
+
# text image
|
52
|
+
# image image
|
53
|
+
data += [[image, {image: image, :fit => [400, 400]}]]
|
54
|
+
end
|
55
|
+
|
56
|
+
|
57
|
+
#data += [["..."]] * 30
|
58
|
+
table(data, :header => true)
|
59
|
+
|
60
|
+
#image "#{Prawn::DATADIR}/images/pigs.jpg"
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
# Search the Directories for images
|
65
|
+
# Returns a list of files with fullpath
|
66
|
+
def search_directory(image_directory = 'app/assets/images')
|
67
|
+
image_directory_regex = "#{image_directory}/**/*"
|
68
|
+
Dir[image_directory_regex].select{ |e| File.file? e }
|
69
|
+
end
|
70
|
+
|
34
71
|
# Returns a list of images with paths that are not referenced in the rails project
|
35
72
|
def collect_none_referenced_images(images)
|
36
73
|
legacy_images = []
|
@@ -48,4 +85,9 @@ module KickinRistretto
|
|
48
85
|
image_files.each {|image_file| File.delete(image_file) if File.exist?(image_file)}
|
49
86
|
end
|
50
87
|
|
88
|
+
def get_all_images_by_type(files)
|
89
|
+
files.group_by{ |f| File.extname(f) }
|
90
|
+
end
|
91
|
+
|
92
|
+
|
51
93
|
end
|
data/lib/tasks/ristretto.rake
CHANGED
@@ -4,6 +4,16 @@ namespace :kickin_ristretto do
|
|
4
4
|
desc "Perform Used Analysis "
|
5
5
|
task :analyze do
|
6
6
|
puts "do the analysis"
|
7
|
-
KickinRistretto.
|
7
|
+
KickinRistretto.clean_non_referenced_images
|
8
8
|
end
|
9
|
+
|
10
|
+
|
11
|
+
desc "Image Audit Report"
|
12
|
+
task :image_audit_report do
|
13
|
+
puts "Performing Image Audit Report"
|
14
|
+
KickinRistretto.image_audit_report
|
15
|
+
puts "Completed Image Audit Report"
|
16
|
+
end
|
17
|
+
|
18
|
+
#image "#{Prawn::DATADIR}/images/pigs.jpg"
|
9
19
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kickin_ristretto
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- KickinEspresso
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-11-
|
11
|
+
date: 2018-11-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,6 +52,34 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: prawn
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 2.2.2
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 2.2.2
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: prawn-table
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.2.2
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.2.2
|
55
83
|
description: Rake tasks that check a rails project for unused assets
|
56
84
|
email:
|
57
85
|
- chris@kickinespresso.com
|