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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b3592e808ba4498abb9b158c25279b743309262b
4
- data.tar.gz: ee338b2e226f3c306ded1bdab8199e7af15eedac
3
+ metadata.gz: edf0394889a1ec90dea0741ea3286a7ad660ec73
4
+ data.tar.gz: 59e4dbd7cc6985741dc6db818b483b7b024cfd77
5
5
  SHA512:
6
- metadata.gz: 7d3ad4db03080484b4f1537f2e3682900e13322e8fdea028694629d0a5dda2108437d329a51d40e6eb2d975946d4d103c234056b7d6681f87f3802f7364eb557
7
- data.tar.gz: 1558f6d9edabeebf7ab27bb9cf7352df704bd9155f76664b76372da6ca3d6d3194184c4aea3a12017a8fd8431bfc1937462b9b0f35cf4d56663af7b970b2e1fb
6
+ metadata.gz: becfae2e4d9e14a98bac286a65d633632a281077173d1c3d820c30b5b21bea30abf2c95afc04317b6dfa441244df8fa110ce8c7e7c4983483744a920def37f2e
7
+ data.tar.gz: a6286dfd402ffe4f89557fc7299e05922f513a08ff09e3c1de2414df90061137e898e61ad9bb78541572b65c6207141e9345f7a05c06b05d676fce5b7de170eb
@@ -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('dead_gems.out', 'a') {|f| f.puts path}
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
- File.delete('dead_gems.out') if File.exists?('dead_gems.out')
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
- File.read('dead_gems.out').each_line do |line|
86
+ outfile.read.each_line do |line|
85
87
  path = line.chomp
86
88
  gems.delete_if {|g| g.path == path}
87
89
  end
@@ -1,3 +1,3 @@
1
1
  module DeadGems
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
3
3
  end
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
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-17 00:00:00.000000000 Z
11
+ date: 2015-11-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler