dead_gems 0.0.3 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -1
- data/lib/dead_gems/version.rb +1 -1
- data/lib/dead_gems.rb +6 -7
- data/spec/dead_gems_spec.rb +12 -15
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2246b24540c8fa6161289db092e74f4104ea6fc7
|
4
|
+
data.tar.gz: a412c88ed0fe63e9a1af3ce8f217d42496d8cfc3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ed6349f91a26eee0ba8efbe2ef9bd5298745fc831e943fc284c7c66f3a09c4814304c7e6976d750e9e85763d30bbf6ebbadc20620643ebc324cf8f2e1defa06e
|
7
|
+
data.tar.gz: 54c588cf353e2bcdf1b13133b4af2d371d74e96ead7ed74a8be3de2fa577a9ffb5560918eb5305efc5a48f9d5d9a5b73b1cf6e7815d56416fa8c1dce153e308b
|
data/.travis.yml
CHANGED
data/lib/dead_gems/version.rb
CHANGED
data/lib/dead_gems.rb
CHANGED
@@ -6,7 +6,7 @@ module DeadGems
|
|
6
6
|
GemInstance = Struct.new(:name, :path)
|
7
7
|
|
8
8
|
class << self
|
9
|
-
def find(project_root, exerciser)
|
9
|
+
def find(project_root, exerciser, test_helper: 'test/test_helper.rb')
|
10
10
|
begin_dir = Dir.pwd
|
11
11
|
logger = Logger.new($stdout)
|
12
12
|
change_directory_to project_root
|
@@ -15,7 +15,7 @@ module DeadGems
|
|
15
15
|
path = find_gem_path(name)
|
16
16
|
GemInstance.new(name, path)
|
17
17
|
end
|
18
|
-
apply_environment_patch(gems) do
|
18
|
+
apply_environment_patch(gems, test_helper) do
|
19
19
|
run(exerciser, gems)
|
20
20
|
end
|
21
21
|
ensure
|
@@ -53,9 +53,8 @@ module DeadGems
|
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
|
-
def apply_environment_patch(gems)
|
57
|
-
|
58
|
-
prepatch = File.read(file)
|
56
|
+
def apply_environment_patch(gems, test_helper)
|
57
|
+
prepatch = File.read(test_helper)
|
59
58
|
patch = <<-END
|
60
59
|
gem_paths = #{gems.map(&:path)}
|
61
60
|
trace = TracePoint.new(:call) do |tp|
|
@@ -69,10 +68,10 @@ trace = TracePoint.new(:call) do |tp|
|
|
69
68
|
end
|
70
69
|
trace.enable
|
71
70
|
END
|
72
|
-
File.open(
|
71
|
+
File.open(test_helper, 'w') { |f| f.write([prepatch, patch].join("\n")) }
|
73
72
|
yield
|
74
73
|
ensure
|
75
|
-
File.open(
|
74
|
+
File.open(test_helper, 'w') { |f| f.write(prepatch) }
|
76
75
|
File.delete('dead_gems.out') if File.exists?('dead_gems.out')
|
77
76
|
end
|
78
77
|
|
data/spec/dead_gems_spec.rb
CHANGED
@@ -4,6 +4,7 @@ class DeadGemsSpec < Minitest::Spec
|
|
4
4
|
describe '.find' do
|
5
5
|
describe 'given the dummy app and the test shell command' do
|
6
6
|
before do
|
7
|
+
skip("Can't run dummy tests on Travis") if ENV['IS_TRAVIS']
|
7
8
|
@project_path = File.expand_path('../../dummy', __FILE__)
|
8
9
|
@exerciser_command = 'bundle exec rake &> /dev/null'
|
9
10
|
end
|
@@ -22,31 +23,27 @@ class DeadGemsSpec < Minitest::Spec
|
|
22
23
|
describe '.find_all_gems' do
|
23
24
|
it 'correctly parses the example lock files' do
|
24
25
|
Dir['spec/fixtures/lock_file*'].each do |path|
|
25
|
-
|
26
|
-
str = File.read(path)
|
27
|
-
|
28
|
-
original = File.method(:read)
|
29
|
-
File.define_singleton_method(:read, -> (f) { str })
|
30
|
-
DeadGems.send(:find_all_gems)
|
31
|
-
ensure
|
32
|
-
File.define_singleton_method(:read, original)
|
33
|
-
end
|
26
|
+
stub_file_read_with(File.read(path)) { DeadGems.send(:find_all_gems) }
|
34
27
|
end
|
35
28
|
end
|
36
29
|
|
37
30
|
it 'correctly parses outs bangs' do
|
38
|
-
|
39
|
-
str = <<-FILE
|
31
|
+
str = <<-FILE
|
40
32
|
DEPENDENCIES
|
41
33
|
test!
|
42
34
|
FILE
|
43
35
|
|
44
|
-
|
45
|
-
File.define_singleton_method(:read, -> (f) { str })
|
36
|
+
stub_file_read_with(str) do
|
46
37
|
assert DeadGems.send(:find_all_gems).any? {|g| g == 'test'}
|
47
|
-
ensure
|
48
|
-
File.define_singleton_method(:read, original)
|
49
38
|
end
|
50
39
|
end
|
51
40
|
end
|
41
|
+
|
42
|
+
def stub_file_read_with(v, &block)
|
43
|
+
original = File.method(:read)
|
44
|
+
File.define_singleton_method(:read, Proc.new { |f| v })
|
45
|
+
yield
|
46
|
+
ensure
|
47
|
+
File.define_singleton_method(:read, original)
|
48
|
+
end
|
52
49
|
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.
|
4
|
+
version: 0.1.3
|
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-10-
|
11
|
+
date: 2015-10-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -207,7 +207,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
207
207
|
version: '0'
|
208
208
|
requirements: []
|
209
209
|
rubyforge_project:
|
210
|
-
rubygems_version: 2.
|
210
|
+
rubygems_version: 2.4.8
|
211
211
|
signing_key:
|
212
212
|
specification_version: 4
|
213
213
|
summary: a gem for finding unused gems in your project
|