cleanup_vendor 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/Gemfile.lock +7 -5
- data/cleanup_vendor.gemspec +1 -1
- data/exe/cleanup_vendor +5 -10
- data/lib/cleanup_vendor.rb +10 -47
- data/lib/cleanup_vendor/path.rb +34 -0
- data/lib/cleanup_vendor/version.rb +1 -1
- data/lib/defaults.yml +27 -53
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 24cac3d82b1d43e2442215768b8537b1f09f6a5fbaf5ddcd2d7ff9956ed363c1
|
4
|
+
data.tar.gz: 229cec236efa8bc3a7b8bf1bbe2fc5e1c974168aceec2420b386656f731de1b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ed7a4eefbed3e5b8682fcf0181a47778d6292d40827ad5441820080a6c9a64c16a32798adcad3b71b316fa7cf3bc7f29d56ddd5a972ae35cca446209dbb41765
|
7
|
+
data.tar.gz: 7ac1613c439b7dcf2d44a5b782612fbceb55e77702077dc30e79372094c9194e703c60fc6cc430e87083b8d6d62a384f68dbbd627b23845d7ac151d1c3f2be35
|
data/.travis.yml
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
cleanup_vendor (0.
|
4
|
+
cleanup_vendor (0.4.0)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
@@ -13,6 +13,7 @@ GEM
|
|
13
13
|
docile (1.3.2)
|
14
14
|
gem-release (2.1.1)
|
15
15
|
jaro_winkler (1.5.4)
|
16
|
+
json (2.3.0)
|
16
17
|
method_source (0.9.2)
|
17
18
|
parallel (1.19.1)
|
18
19
|
parser (2.7.0.4)
|
@@ -50,10 +51,11 @@ GEM
|
|
50
51
|
ruby-progressbar (~> 1.7)
|
51
52
|
unicode-display_width (>= 1.4.0, < 1.7)
|
52
53
|
ruby-progressbar (1.10.1)
|
53
|
-
simplecov (0.
|
54
|
+
simplecov (0.17.1)
|
54
55
|
docile (~> 1.1)
|
55
|
-
|
56
|
-
|
56
|
+
json (>= 1.8, < 3)
|
57
|
+
simplecov-html (~> 0.10.0)
|
58
|
+
simplecov-html (0.10.2)
|
57
59
|
unicode-display_width (1.6.1)
|
58
60
|
yard (0.9.24)
|
59
61
|
|
@@ -68,7 +70,7 @@ DEPENDENCIES
|
|
68
70
|
pry-doc (~> 1.0)
|
69
71
|
rspec (~> 3.0)
|
70
72
|
rubocop (~> 0.80.1)
|
71
|
-
simplecov (~> 0.
|
73
|
+
simplecov (~> 0.17.1)
|
72
74
|
|
73
75
|
BUNDLED WITH
|
74
76
|
1.17.3
|
data/cleanup_vendor.gemspec
CHANGED
@@ -29,5 +29,5 @@ Gem::Specification.new do |spec|
|
|
29
29
|
spec.add_development_dependency 'pry-doc', '~> 1.0'
|
30
30
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
31
31
|
spec.add_development_dependency 'rubocop', '~> 0.80.1'
|
32
|
-
spec.add_development_dependency 'simplecov', '~> 0.
|
32
|
+
spec.add_development_dependency 'simplecov', '~> 0.17.1'
|
33
33
|
end
|
data/exe/cleanup_vendor
CHANGED
@@ -29,19 +29,14 @@ opt_parser = OptionParser.new do |opts|
|
|
29
29
|
options[:summary] = s
|
30
30
|
end
|
31
31
|
|
32
|
-
opts.on('-d', '--directory
|
32
|
+
opts.on('-d', '--directory PATTERN', 'Match on directory') do |pattern|
|
33
33
|
options[:directories] ||= []
|
34
|
-
options[:directories] <<
|
34
|
+
options[:directories] << pattern
|
35
35
|
end
|
36
36
|
|
37
|
-
opts.on('-
|
38
|
-
options[:
|
39
|
-
options[:
|
40
|
-
end
|
41
|
-
|
42
|
-
opts.on('-f', '--file FILE', 'Match on these filenames') do |file|
|
43
|
-
options[:filenames] ||= []
|
44
|
-
options[:filenames] << file
|
37
|
+
opts.on('-f', '--extension PATTERN', 'Match on file') do |pattern|
|
38
|
+
options[:files] ||= []
|
39
|
+
options[:files] << pattern
|
45
40
|
end
|
46
41
|
|
47
42
|
opts.on_tail('-h', '--help', 'Show this message') do
|
data/lib/cleanup_vendor.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'pathname'
|
4
3
|
require 'yaml'
|
5
4
|
|
6
5
|
require 'cleanup_vendor/version'
|
6
|
+
require 'cleanup_vendor/path'
|
7
7
|
|
8
8
|
module CleanupVendor
|
9
9
|
class Error < StandardError; end
|
@@ -16,7 +16,7 @@ module CleanupVendor
|
|
16
16
|
summary = []
|
17
17
|
|
18
18
|
filter(dir, DEFAULTS.merge(opts)) do |p|
|
19
|
-
summary <<
|
19
|
+
summary << p.summary if opts[:summary]
|
20
20
|
|
21
21
|
print_verbose(p) if opts[:verbose]
|
22
22
|
print_path(p) if opts[:print0]
|
@@ -27,72 +27,35 @@ module CleanupVendor
|
|
27
27
|
print_summary(summary) if opts[:summary]
|
28
28
|
end
|
29
29
|
|
30
|
+
# rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
30
31
|
def filter(dir, opts = {})
|
31
32
|
raise Error, 'Not a directory' unless File.directory?(dir.to_s)
|
32
33
|
return to_enum(:filter, dir, opts) unless block_given?
|
33
34
|
|
34
|
-
|
35
|
-
filtered = Set.new
|
35
|
+
files, directories, filtered = get_options(opts)
|
36
36
|
|
37
|
-
|
38
|
-
next if
|
39
|
-
next unless
|
37
|
+
Path.new(dir).recursive_entries do |path|
|
38
|
+
next if path.include?(filtered)
|
39
|
+
next unless path.file? && path.match?(files) || path.directory? && path.match?(directories)
|
40
40
|
|
41
41
|
filtered << path
|
42
42
|
yield(path)
|
43
43
|
end
|
44
44
|
end
|
45
|
-
|
46
|
-
def skip_path?(path, filtered)
|
47
|
-
path.basename.to_s == '.' || path.descend.any? { |p| filtered.include?(p) }
|
48
|
-
end
|
49
|
-
private :skip_path?
|
50
|
-
|
51
|
-
def match_file?(path, filenames: [], extensions: [])
|
52
|
-
return unless path.file?
|
53
|
-
|
54
|
-
filenames.include?(path.basename.to_s) || extensions.include?(path.extname.delete('.'))
|
55
|
-
end
|
56
|
-
private :match_file?
|
57
|
-
|
58
|
-
def match_directory?(path, directories: [], top_level_directories: [])
|
59
|
-
return unless path.directory?
|
60
|
-
|
61
|
-
basename = path.basename.to_s
|
62
|
-
directories.include?(basename) || top_level_directories.include?(basename) && path.parent.glob('*.gemspec').any?
|
63
|
-
end
|
64
|
-
private :match_directory?
|
45
|
+
# rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
65
46
|
|
66
47
|
def get_options(options)
|
67
|
-
|
68
|
-
dir_opts = transform_options(options, :directories, :top_level_directories)
|
69
|
-
[file_opts, dir_opts]
|
70
|
-
end
|
71
|
-
private :get_options
|
72
|
-
|
73
|
-
def transform_options(options, *keys)
|
74
|
-
options.slice(*keys).transform_values do |v|
|
48
|
+
options.values_at(:files, :directories, :filtered).map do |v|
|
75
49
|
(v || []).to_set
|
76
50
|
end
|
77
51
|
end
|
78
|
-
private :
|
79
|
-
|
80
|
-
def dir_entries(dir, &block)
|
81
|
-
Pathname.new(dir).glob('**/*', File::FNM_DOTMATCH, &block)
|
82
|
-
end
|
83
|
-
private :dir_entries
|
52
|
+
private :get_options
|
84
53
|
|
85
54
|
def format_summary(prefix, number)
|
86
55
|
"\t#{prefix}\t#{number.to_s.rjust(20)}"
|
87
56
|
end
|
88
57
|
private :format_summary
|
89
58
|
|
90
|
-
def collect_summary(path)
|
91
|
-
files = path.file? ? [path] : dir_entries(path).reject { |p| p.basename.to_s == '.' }
|
92
|
-
files.map(&:stat)
|
93
|
-
end
|
94
|
-
private :collect_summary
|
95
|
-
|
96
59
|
def print_verbose(path)
|
97
60
|
$stderr.puts "Removing #{path}..."
|
98
61
|
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'pathname'
|
4
|
+
|
5
|
+
module CleanupVendor
|
6
|
+
class Path < ::Pathname
|
7
|
+
def recursive_entries
|
8
|
+
return to_enum(:recursive_entries) unless block_given?
|
9
|
+
|
10
|
+
glob('**/*', File::FNM_DOTMATCH) do |path|
|
11
|
+
yield(Path.new(path)) unless path == self
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def match?(patterns)
|
16
|
+
patterns.any? do |p|
|
17
|
+
p.start_with?('**') && fnmatch?(p, File::FNM_EXTGLOB) || basename.fnmatch?(p, File::FNM_EXTGLOB) && gem_level?
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def gem_level?
|
22
|
+
@gem_level ||= parent.glob('*.gemspec').any?
|
23
|
+
end
|
24
|
+
|
25
|
+
def include?(enum)
|
26
|
+
descend.any? { |p| enum.include?(p) }
|
27
|
+
end
|
28
|
+
|
29
|
+
def summary
|
30
|
+
entries = [self] + recursive_entries.to_a
|
31
|
+
entries.map(&:stat)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/lib/defaults.yml
CHANGED
@@ -1,54 +1,28 @@
|
|
1
|
-
extensions:
|
2
|
-
- c
|
3
|
-
- cpp
|
4
|
-
- gcov
|
5
|
-
- gem
|
6
|
-
- h
|
7
|
-
- hpp
|
8
|
-
- java
|
9
|
-
- log
|
10
|
-
- markdown
|
11
|
-
- md
|
12
|
-
- mk
|
13
|
-
- o
|
14
|
-
- orig
|
15
|
-
- rdoc
|
16
|
-
- txt
|
17
|
-
filenames:
|
18
|
-
- .DS_Store
|
19
|
-
- .appveyor.yml
|
20
|
-
- .byebug_history
|
21
|
-
- .codeclimate.yml
|
22
|
-
- .dockerignore
|
23
|
-
- .gitignore
|
24
|
-
- .gitkeep
|
25
|
-
- .gitmodules
|
26
|
-
- .hound.yml
|
27
|
-
- .keep
|
28
|
-
- .npmignore
|
29
|
-
- .rspec
|
30
|
-
- .rspec_status
|
31
|
-
- .rubocop.yml
|
32
|
-
- .ruby-gemset
|
33
|
-
- .ruby-version
|
34
|
-
- .rvmrc
|
35
|
-
- .travis.yml
|
36
|
-
- .yardopts
|
37
|
-
- CHANGELOG
|
38
|
-
- LICENSE
|
39
|
-
- MIT-LICENSE
|
40
|
-
- Makefile
|
41
|
-
- NEWS
|
42
|
-
- README
|
43
|
-
- TAGS
|
44
|
-
- TODO
|
45
|
-
- gem_make.out
|
46
|
-
top_level_directories:
|
47
|
-
- spec
|
48
1
|
directories:
|
49
|
-
-
|
50
|
-
-
|
51
|
-
-
|
52
|
-
-
|
53
|
-
-
|
54
|
-
-
|
2
|
+
- "spec"
|
3
|
+
- "coverage"
|
4
|
+
- "**/.circleci"
|
5
|
+
- "**/.config"
|
6
|
+
- "**/.{git,github}"
|
7
|
+
- "**/.idea"
|
8
|
+
- "**/.{npm,yarn}"
|
9
|
+
- "**/.yardoc"
|
10
|
+
files:
|
11
|
+
- "**/.DS_Store"
|
12
|
+
- "**/*.{c,cpp,h,hpp,java,log,markdown,md,mk,o,orig,rdoc,txt}"
|
13
|
+
- "**/gem_make.out"
|
14
|
+
- "**/Makefile"
|
15
|
+
- "**/TAGS"
|
16
|
+
- "**/*.{gcov,gem}"
|
17
|
+
- "**/*.{log,markdown,md,rdoc,txt,yardopts}"
|
18
|
+
- "**/*.{bak,orig}"
|
19
|
+
- "**/{CHANGELOG,LICENSE,MIT-LICENSE,NEWS,README,TODO}"
|
20
|
+
- "**/.{gitkeep,gitignore,gitmodules}"
|
21
|
+
- "**/.keep"
|
22
|
+
- "**/{Dockerfile,.dockerignore}"
|
23
|
+
- "**/.{appveyor,codeclimate,hound,travis}.yml"
|
24
|
+
- "**/.{ruby-gemset,ruby-version,rvm}"
|
25
|
+
- "**/.{rspec,rspec_status}"
|
26
|
+
- "**/.npmignore"
|
27
|
+
- "**/.rubocop.yml"
|
28
|
+
- "**/.byebug_history"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cleanup_vendor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- KARASZI István
|
@@ -100,14 +100,14 @@ dependencies:
|
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: 0.
|
103
|
+
version: 0.17.1
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: 0.
|
110
|
+
version: 0.17.1
|
111
111
|
description: Removes unnecessary files which are not required in production environment.
|
112
112
|
email:
|
113
113
|
- github@spam.raszi.hu
|
@@ -129,6 +129,7 @@ files:
|
|
129
129
|
- cleanup_vendor.gemspec
|
130
130
|
- exe/cleanup_vendor
|
131
131
|
- lib/cleanup_vendor.rb
|
132
|
+
- lib/cleanup_vendor/path.rb
|
132
133
|
- lib/cleanup_vendor/version.rb
|
133
134
|
- lib/defaults.yml
|
134
135
|
homepage: https://github.com/raszi/cleanup_vendor
|