depth-charge 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +7 -0
- data/Rakefile +6 -4
- data/TODO.txt +2 -2
- data/lib/depth_charge.rb +83 -23
- data/lib/depth_charge/version.rb +1 -1
- data/lib/tasks/depth_charge.rake +11 -4
- data/test/test_depth_charge.rb +21 -3
- data/test/test_helper.rb +2 -0
- data/website/index.html +4 -22
- data/website/index.txt +3 -16
- metadata +2 -2
data/History.txt
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
== 0.0.2 2008-02-27
|
2
|
+
|
3
|
+
* 3 minor enhancements:
|
4
|
+
* gem list --local is run to pull a list of locally-installed gems
|
5
|
+
* gem list --remote is run to create a list of all available gems (which is then cached)
|
6
|
+
* Dependencies are segmented into installed gems, uninstalled gems, and other
|
7
|
+
|
1
8
|
== 0.0.1 2008-02-26
|
2
9
|
|
3
10
|
* 1 major enhancement:
|
data/Rakefile
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
-
require 'config/requirements'
|
2
|
-
require 'config/hoe' # setup Hoe + all gem configuration
|
3
|
-
|
4
|
-
Dir['tasks/**/*.rake'].each { |rake| load rake }
|
1
|
+
require 'config/requirements'
|
2
|
+
require 'config/hoe' # setup Hoe + all gem configuration
|
3
|
+
|
4
|
+
Dir['tasks/**/*.rake'].each { |rake| load rake }
|
5
|
+
|
6
|
+
Dir['lib/**/*.rake'].each { |rake| load rake }
|
data/TODO.txt
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
-
|
2
|
-
-
|
1
|
+
- validate that requirements are, in fact, gems
|
2
|
+
- gem version checking?
|
data/lib/depth_charge.rb
CHANGED
@@ -1,32 +1,92 @@
|
|
1
1
|
$:.unshift File.dirname(__FILE__)
|
2
2
|
|
3
3
|
module DepthCharge
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
4
|
+
USER_HOME = File.expand_path('~')
|
5
|
+
|
6
|
+
class << self
|
7
|
+
def gem_list(scope = 'local')
|
8
|
+
process_gem_list(`gem list --#{scope} --no-verbose`, scope)
|
9
|
+
end
|
10
|
+
|
11
|
+
def process_gem_list(raw_gem_list, scope = 'remote')
|
12
|
+
gems = raw_gem_list.split(/\n/).select {|g| g =~ / \(/}
|
13
|
+
gems.map! {|g| g.sub(/\s+.+$/, '')}
|
14
|
+
end
|
15
|
+
|
16
|
+
def local_gems
|
17
|
+
gem_list
|
18
|
+
end
|
19
|
+
|
20
|
+
def remote_gems
|
21
|
+
gems = []
|
22
|
+
if File.exists?(File.join(USER_HOME, '.remote_gemlist'))
|
23
|
+
File.open(File.join(USER_HOME, '.remote_gemlist'), 'r') do |file|
|
24
|
+
gems = file.readlines.map {|l| l.chomp}
|
25
|
+
end
|
26
|
+
else
|
27
|
+
puts "Creating remote gem list cache (this may take awhile)"
|
28
|
+
gems = gem_list('remote')
|
29
|
+
File.open(File.join(USER_HOME, '.remote_gemlist'), 'wb+') do |file|
|
30
|
+
file.puts gems.join("\n")
|
31
|
+
end
|
32
|
+
end
|
33
|
+
gems
|
34
|
+
end
|
35
|
+
|
36
|
+
def find_requirements(root)
|
37
|
+
root ||= File.dirname(__FILE__) + "/.."
|
38
|
+
requirements = {}
|
39
|
+
|
40
|
+
Dir.chdir(root)
|
41
|
+
Dir['**/*.rb'].each do |path|
|
42
|
+
next if path =~ /^vendor\/rails/
|
43
|
+
File.open( path ) do |f|
|
44
|
+
f.grep( /^(require|gem)/ ) do |line|
|
45
|
+
required = line.scan(/('|")(.+?)('|")/).flatten[1]
|
46
|
+
unless [/File/, /\*/, /\</, /#/, /\.{2}/, /^\//].detect {|pattern| required =~ pattern}
|
47
|
+
requirements[required] ||= []
|
48
|
+
requirements[required] << path
|
49
|
+
end
|
17
50
|
end
|
18
51
|
end
|
19
52
|
end
|
53
|
+
|
54
|
+
installed_gems = local_gems
|
55
|
+
all_gems = remote_gems
|
56
|
+
uninstalled_gems = all_gems - installed_gems
|
57
|
+
|
58
|
+
installed = {}
|
59
|
+
uninstalled = {}
|
60
|
+
other = {}
|
61
|
+
requirements.keys.sort.each do |k|
|
62
|
+
if installed_gems.include?(k)
|
63
|
+
installed[k] = requirements[k]
|
64
|
+
elsif uninstalled_gems.include?(k)
|
65
|
+
uninstalled[k] = requirements[k]
|
66
|
+
else
|
67
|
+
other[k] = requirements[k]
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
return installed, uninstalled, other
|
20
72
|
end
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
73
|
+
|
74
|
+
def display(hash, header, show_files = true)
|
75
|
+
unless hash.empty?
|
76
|
+
puts "\n#{header}\n#{'='*header.length}"
|
77
|
+
hash.keys.sort.each do |k|
|
78
|
+
puts "#{k}"
|
79
|
+
puts " #{hash[k].join("\n ")}\n" if show_files
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def run(path)
|
85
|
+
installed, uninstalled, other = find_requirements(path)
|
86
|
+
|
87
|
+
display(installed, 'INSTALLED GEMS', false)
|
88
|
+
display(uninstalled, 'UNINSTALLED GEMS')
|
89
|
+
display(other, 'OTHER REQUIREMENTS')
|
30
90
|
end
|
31
91
|
end
|
32
|
-
end
|
92
|
+
end
|
data/lib/depth_charge/version.rb
CHANGED
data/lib/tasks/depth_charge.rake
CHANGED
@@ -1,8 +1,15 @@
|
|
1
1
|
require 'depth_charge'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
task :check
|
6
|
-
DepthCharge.run(
|
3
|
+
namespace :dc do
|
4
|
+
desc 'Check project for dependencies'
|
5
|
+
task :check do
|
6
|
+
DepthCharge.run(File.expand_path('.'))
|
7
|
+
end
|
8
|
+
|
9
|
+
namespace :rails do
|
10
|
+
desc 'Check Rails project for dependencies'
|
11
|
+
task :check do
|
12
|
+
DepthCharge.run(RAILS_ROOT)
|
13
|
+
end
|
7
14
|
end
|
8
15
|
end
|
data/test/test_depth_charge.rb
CHANGED
@@ -2,10 +2,28 @@ require File.dirname(__FILE__) + '/test_helper.rb'
|
|
2
2
|
|
3
3
|
class TestDepthCharge < Test::Unit::TestCase
|
4
4
|
|
5
|
-
def
|
5
|
+
def test_retrieve_local_gems_should_run_gem_list_local
|
6
|
+
DepthCharge.expects(:`).returns( "\n*** LOCAL GEMS ***\n\nabstract (1.0.0)\nactionmailer (2.0.2, 2.0.1, 1.3.3)\n")
|
7
|
+
gems = DepthCharge.local_gems
|
8
|
+
|
9
|
+
assert_equal 'abstract', gems[0]
|
10
|
+
assert_equal 'actionmailer', gems[1]
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_retrieve_remote_gems_should_run_gem_list_remote
|
14
|
+
File.expects(:exists?).returns(false)
|
15
|
+
File.expects(:open).returns(true)
|
16
|
+
DepthCharge.expects(:puts).returns(true)
|
17
|
+
DepthCharge.expects(:`).returns( "*** REMOTE GEMS ***\n\nempty\naalib-ruby (1.0)\nabstract (1.0)")
|
18
|
+
gems = DepthCharge.remote_gems
|
19
|
+
|
20
|
+
assert_equal 'aalib-ruby', gems[0]
|
21
|
+
assert_equal 'abstract', gems[1]
|
6
22
|
end
|
7
23
|
|
8
|
-
def
|
9
|
-
|
24
|
+
def test_remote_gems_should_hit_cache
|
25
|
+
DepthCharge.expects(:`).never
|
26
|
+
File.expects(:open).returns(true)
|
27
|
+
gems = DepthCharge.remote_gems
|
10
28
|
end
|
11
29
|
end
|
data/test/test_helper.rb
CHANGED
data/website/index.html
CHANGED
@@ -33,9 +33,9 @@
|
|
33
33
|
<h1>DepthCharge</h1>
|
34
34
|
<div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/depth_charge"; return false'>
|
35
35
|
<p>Get Version</p>
|
36
|
-
<a href="http://rubyforge.org/projects/depth_charge" class="numbers">0.0.
|
36
|
+
<a href="http://rubyforge.org/projects/depth_charge" class="numbers">0.0.2</a>
|
37
37
|
</div>
|
38
|
-
<h1>→ ‘
|
38
|
+
<h1>→ ‘depth-charge’</h1>
|
39
39
|
|
40
40
|
|
41
41
|
<h2>What</h2>
|
@@ -44,7 +44,7 @@
|
|
44
44
|
<h2>Installing</h2>
|
45
45
|
|
46
46
|
|
47
|
-
<p><pre class='syntax'><span class="ident">sudo</span> <span class="ident">gem</span> <span class="ident">install</span> <span class="ident">
|
47
|
+
<p><pre class='syntax'><span class="ident">sudo</span> <span class="ident">gem</span> <span class="ident">install</span> <span class="ident">depth</span><span class="punct">-</span><span class="ident">charge</span></pre></p>
|
48
48
|
|
49
49
|
|
50
50
|
<h2>The basics</h2>
|
@@ -53,24 +53,6 @@
|
|
53
53
|
<h2>Demonstration of usage</h2>
|
54
54
|
|
55
55
|
|
56
|
-
<h2>Forum</h2>
|
57
|
-
|
58
|
-
|
59
|
-
<p><a href="http://groups.google.com/group/depth_charge">http://groups.google.com/group/depth_charge</a></p>
|
60
|
-
|
61
|
-
|
62
|
-
<p><span class="caps">TODO</span> – create Google Group – depth_charge</p>
|
63
|
-
|
64
|
-
|
65
|
-
<h2>How to submit patches</h2>
|
66
|
-
|
67
|
-
|
68
|
-
<p>Read the <a href="http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/">8 steps for fixing other people’s code</a> and for section <a href="http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/#8b-google-groups">8b: Submit patch to Google Groups</a>, use the Google Group above.</p>
|
69
|
-
|
70
|
-
|
71
|
-
<p>The trunk repository is <code>svn://rubyforge.org/var/svn/dependency_finder/trunk</code> for anonymous access.</p>
|
72
|
-
|
73
|
-
|
74
56
|
<h2>License</h2>
|
75
57
|
|
76
58
|
|
@@ -80,7 +62,7 @@
|
|
80
62
|
<h2>Contact</h2>
|
81
63
|
|
82
64
|
|
83
|
-
<p>Comments are welcome. Send an email to <a href="mailto:rubyforge@turrean.com">Ben Scofield</a
|
65
|
+
<p>Comments are welcome. Send an email to <a href="mailto:rubyforge@turrean.com">Ben Scofield</a></p>
|
84
66
|
<p class="coda">
|
85
67
|
<a href="mailto:rubyforge@turrean.com">Ben Scofield</a>, 26th February 2008<br>
|
86
68
|
Theme extended from <a href="http://rb2js.rubyforge.org/">Paul Battley</a>
|
data/website/index.txt
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
h1. DepthCharge
|
2
2
|
|
3
|
-
h1. → '
|
3
|
+
h1. → 'depth-charge'
|
4
4
|
|
5
5
|
|
6
6
|
h2. What
|
@@ -8,7 +8,7 @@ h2. What
|
|
8
8
|
|
9
9
|
h2. Installing
|
10
10
|
|
11
|
-
<pre syntax="ruby">sudo gem install
|
11
|
+
<pre syntax="ruby">sudo gem install depth-charge</pre>
|
12
12
|
|
13
13
|
h2. The basics
|
14
14
|
|
@@ -16,24 +16,11 @@ h2. The basics
|
|
16
16
|
h2. Demonstration of usage
|
17
17
|
|
18
18
|
|
19
|
-
|
20
|
-
h2. Forum
|
21
|
-
|
22
|
-
"http://groups.google.com/group/depth_charge":http://groups.google.com/group/depth_charge
|
23
|
-
|
24
|
-
TODO - create Google Group - depth_charge
|
25
|
-
|
26
|
-
h2. How to submit patches
|
27
|
-
|
28
|
-
Read the "8 steps for fixing other people's code":http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/ and for section "8b: Submit patch to Google Groups":http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/#8b-google-groups, use the Google Group above.
|
29
|
-
|
30
|
-
The trunk repository is <code>svn://rubyforge.org/var/svn/dependency_finder/trunk</code> for anonymous access.
|
31
|
-
|
32
19
|
h2. License
|
33
20
|
|
34
21
|
This code is free to use under the terms of the MIT license.
|
35
22
|
|
36
23
|
h2. Contact
|
37
24
|
|
38
|
-
Comments are welcome. Send an email to "Ben Scofield":mailto:rubyforge@turrean.com
|
25
|
+
Comments are welcome. Send an email to "Ben Scofield":mailto:rubyforge@turrean.com
|
39
26
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: depth-charge
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ""
|
6
6
|
authors:
|
7
7
|
- Ben Scofield
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-02-
|
12
|
+
date: 2008-02-27 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|