depth-charge 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
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
- - process output to extract gems
2
- - check for gem installation on system
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
- def self.find_requirements(root)
5
- root ||= File.dirname(__FILE__) + "/.."
6
- requirements = {}
7
-
8
- Dir.chdir(root)
9
- Dir['**/*.rb'].each do |path|
10
- next if path =~ /^vendor\/rails/
11
- File.open( path ) do |f|
12
- f.grep( /^(require|gem)/ ) do |line|
13
- required = line.scan(/('|")(.+?)('|")/).flatten[1]
14
- unless [/File/, /\*/, /\</, /#/, /\.{2}/, /^\//].detect {|pattern| required =~ pattern}
15
- requirements[required] ||= []
16
- requirements[required] << path
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
- requirements
23
- end
24
-
25
- def self.run(path)
26
- requirements = find_requirements(path)
27
- requirements.keys.map.sort.each do |k|
28
- puts "\n#{k}"
29
- puts " #{requirements[k].join("\n ")}"
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
@@ -2,7 +2,7 @@ module DepthCharge #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 0
5
- TINY = 1
5
+ TINY = 2
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -1,8 +1,15 @@
1
1
  require 'depth_charge'
2
2
 
3
- desc 'Check project for dependencies'
4
- namespace :depth_charge do
5
- task :check => :ruby_env do
6
- DepthCharge.run(RAILS_ROOT)
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
@@ -2,10 +2,28 @@ require File.dirname(__FILE__) + '/test_helper.rb'
2
2
 
3
3
  class TestDepthCharge < Test::Unit::TestCase
4
4
 
5
- def setup
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 test_truth
9
- assert true
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
@@ -1,2 +1,4 @@
1
1
  require 'test/unit'
2
2
  require File.dirname(__FILE__) + '/../lib/depth_charge'
3
+ require 'rubygems'
4
+ require 'mocha'
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.1</a>
36
+ <a href="http://rubyforge.org/projects/depth_charge" class="numbers">0.0.2</a>
37
37
  </div>
38
- <h1>&#x2192; &#8216;depth_charge&#8217;</h1>
38
+ <h1>&#x2192; &#8216;depth-charge&#8217;</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">depth_charge</span></pre></p>
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> &#8211; create Google Group &#8211; 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&#8217;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> email via the <a href="http://groups.google.com/group/depth_charge">forum</a></p>
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. &#x2192; 'depth_charge'
3
+ h1. &#x2192; '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 depth_charge</pre>
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 email via the "forum":http://groups.google.com/group/depth_charge
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.1
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-26 00:00:00 -05:00
12
+ date: 2008-02-27 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies: []
15
15