dead_gems 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/dummy/test/test_helper.rb +0 -24
- data/lib/dead_gems.rb +9 -7
- data/lib/dead_gems/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: edf0394889a1ec90dea0741ea3286a7ad660ec73
|
4
|
+
data.tar.gz: 59e4dbd7cc6985741dc6db818b483b7b024cfd77
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: becfae2e4d9e14a98bac286a65d633632a281077173d1c3d820c30b5b21bea30abf2c95afc04317b6dfa441244df8fa110ce8c7e7c4983483744a920def37f2e
|
7
|
+
data.tar.gz: a6286dfd402ffe4f89557fc7299e05922f513a08ff09e3c1de2414df90061137e898e61ad9bb78541572b65c6207141e9345f7a05c06b05d676fce5b7de170eb
|
data/dummy/test/test_helper.rb
CHANGED
@@ -8,27 +8,3 @@ class ActiveSupport::TestCase
|
|
8
8
|
|
9
9
|
# Add more helper methods to be used by all tests here...
|
10
10
|
end
|
11
|
-
|
12
|
-
gem_paths = ["/Users/jbodah/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/coffee-rails-4.0.1", "/Users/jbodah/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/factory_girl-4.4.0", "/Users/jbodah/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/jbuilder-2.3.1", "/Users/jbodah/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/jquery-rails-3.1.3", "/Users/jbodah/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rails-4.1.5", "/Users/jbodah/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/sass-rails-4.0.5", "/Users/jbodah/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/sdoc-0.4.1", "/Users/jbodah/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/spring-1.3.6", "/Users/jbodah/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/sqlite3-1.3.10", "/Users/jbodah/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/timecop-0.5.4", "/Users/jbodah/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/turbolinks-2.5.3", "/Users/jbodah/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/uglifier-2.7.1"]
|
13
|
-
trace = TracePoint.new(:call) do |tp|
|
14
|
-
# Gem is used
|
15
|
-
# Print to file
|
16
|
-
if path = gem_paths.detect {|p| tp.path.include?(p)}
|
17
|
-
puts "Gem used: #{tp.defined_class} called with #{tp.method_id} in #{tp.path}"
|
18
|
-
File.open('dead_gems.out', 'a') {|f| f.write path}
|
19
|
-
gem_paths.delete(path)
|
20
|
-
end
|
21
|
-
end
|
22
|
-
trace.enable
|
23
|
-
|
24
|
-
gem_paths = ["/Users/jbodah/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/coffee-rails-4.0.1", "/Users/jbodah/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/factory_girl-4.4.0", "/Users/jbodah/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/jbuilder-2.3.1", "/Users/jbodah/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/jquery-rails-3.1.3", "/Users/jbodah/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rails-4.1.5", "/Users/jbodah/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/sass-rails-4.0.5", "/Users/jbodah/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/sdoc-0.4.1", "/Users/jbodah/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/spring-1.3.6", "/Users/jbodah/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/sqlite3-1.3.10", "/Users/jbodah/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/timecop-0.5.4", "/Users/jbodah/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/turbolinks-2.5.3", "/Users/jbodah/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/uglifier-2.7.1"]
|
25
|
-
trace = TracePoint.new(:call) do |tp|
|
26
|
-
# Gem is used
|
27
|
-
# Print to file
|
28
|
-
if path = gem_paths.detect {|p| tp.path.include?(p)}
|
29
|
-
puts "Gem used: #{tp.defined_class} called with #{tp.method_id} in #{tp.path}"
|
30
|
-
File.open('dead_gems.out', 'a') {|f| f.puts path}
|
31
|
-
gem_paths.delete(path)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
trace.enable
|
data/lib/dead_gems.rb
CHANGED
@@ -16,8 +16,8 @@ module DeadGems
|
|
16
16
|
path = find_gem_path(name)
|
17
17
|
GemInstance.new(name, path)
|
18
18
|
end
|
19
|
-
apply_environment_patch(gems, test_helper) do
|
20
|
-
run(exerciser, gems)
|
19
|
+
apply_environment_patch(gems, test_helper) do |outfile|
|
20
|
+
run(exerciser, gems, outfile)
|
21
21
|
end
|
22
22
|
ensure
|
23
23
|
change_directory_to begin_dir
|
@@ -55,6 +55,7 @@ module DeadGems
|
|
55
55
|
end
|
56
56
|
|
57
57
|
def apply_environment_patch(gems, test_helper)
|
58
|
+
outfile = Tempfile.new('deadgems')
|
58
59
|
prepatch = File.read(test_helper)
|
59
60
|
patch = <<-END
|
60
61
|
gem_paths = #{gems.map(&:path)}
|
@@ -63,25 +64,26 @@ trace = TracePoint.new(:call) do |tp|
|
|
63
64
|
# Print to file
|
64
65
|
if path = gem_paths.detect {|p| tp.path.include?(p)}
|
65
66
|
puts "Gem used: \#{tp.defined_class} called with \#{tp.method_id} in \#{tp.path}"
|
66
|
-
File.open('
|
67
|
+
File.open('#{outfile.path}', 'a') {|f| f.puts path}
|
67
68
|
gem_paths.delete(path)
|
68
69
|
end
|
69
70
|
end
|
70
71
|
trace.enable
|
71
72
|
END
|
72
73
|
File.open(test_helper, 'w') { |f| f.write([prepatch, patch].join("\n")) }
|
73
|
-
yield
|
74
|
+
yield outfile
|
74
75
|
ensure
|
75
76
|
File.open(test_helper, 'w') { |f| f.write(prepatch) }
|
76
|
-
|
77
|
+
outfile.close
|
78
|
+
outfile.unlink
|
77
79
|
end
|
78
80
|
|
79
|
-
def run(exerciser, gems)
|
81
|
+
def run(exerciser, gems, outfile)
|
80
82
|
Bundler.with_clean_env do
|
81
83
|
# If all tests pass then the gem is unused.
|
82
84
|
# Otherwise it would've have exited on-call.
|
83
85
|
system exerciser
|
84
|
-
|
86
|
+
outfile.read.each_line do |line|
|
85
87
|
path = line.chomp
|
86
88
|
gems.delete_if {|g| g.path == path}
|
87
89
|
end
|
data/lib/dead_gems/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dead_gems
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josh Bodah
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-11-
|
11
|
+
date: 2015-11-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|