nu 0.2.6 → 0.2.6.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -24,7 +24,8 @@ class App
24
24
  @commands = []
25
25
 
26
26
  @arguments = arguments
27
-
27
+ @help_command = lambda{output_help}
28
+
28
29
  Nu::Api.set_log(lambda {|msg| log msg})
29
30
  Nu::Api.set_out(lambda {|msg| disp msg})
30
31
  @shim = CliShim.new(lambda {|msg| disp msg}, lambda {|msg| log msg})
@@ -59,8 +60,6 @@ class App
59
60
  output_help
60
61
  end
61
62
 
62
- @help_command = lambda{output_help}
63
-
64
63
  end.parse!
65
64
  rescue
66
65
  @commands << @help_command
@@ -141,7 +140,8 @@ class App
141
140
 
142
141
  def assert_param_count(count)
143
142
  unless @arguments.length == count
144
- @help_command.call
143
+ @commands << @help_command
144
+ execute_commands
145
145
  end
146
146
  end
147
147
 
@@ -2,7 +2,9 @@ require 'rubygems'
2
2
  require File.expand_path(File.dirname(__FILE__) + "/analysis_results.rb")
3
3
 
4
4
  class PackageConflictFinder
5
- def initialize(installed_packages)
5
+ def initialize(installed_packages, package_lister)
6
+ raise "package_lister must respond to find(name, version)" unless package_lister.respond_to?("find")
7
+ @package_lister = package_lister
6
8
  @installed_packages = installed_packages
7
9
  end
8
10
 
@@ -34,12 +36,18 @@ class PackageConflictFinder
34
36
  suggested_packages.reject! {|i| i[:name] == proposed_package.name}
35
37
  suggested_packages << {:name=>proposed_package.name, :version=> req(proposed_package.version)}
36
38
 
37
- proposed_package.dependencies.each do |dep|
39
+ extract_dependencies(proposed_package, suggested_packages)
40
+
41
+ return suggested_packages
42
+ end
43
+
44
+ def extract_dependencies(package, suggested_packages)
45
+ package.dependencies.each do |dep|
38
46
  unless suggested_packages.any?{|i| i[:name] == dep.name}
39
47
  suggested_packages << {:name=>dep.name, :version=>dep.requirement}
48
+ extract_dependencies(@package_lister.find(dep.name, dep.requirement), suggested_packages)
40
49
  end
41
50
  end
42
- return suggested_packages
43
51
  end
44
52
 
45
53
  def find_conflicts(proposed_spec)
@@ -3,10 +3,9 @@ require File.expand_path(File.dirname(__FILE__) + "/package_conflict_finder.rb")
3
3
 
4
4
  class PackageConflictOverlapResolver
5
5
  def initialize(installed_packages, package_lister)
6
+ @conflict_finder = PackageConflictFinder.new(installed_packages, package_lister)
6
7
  @installed_packages = installed_packages
7
- raise "package_lister must respond to find(name)" unless package_lister.respond_to?("find")
8
8
  @package_lister = package_lister
9
- @conflict_finder = PackageConflictFinder.new(installed_packages)
10
9
  end
11
10
 
12
11
  def analyze_proposal(proposed_package)
@@ -11,7 +11,7 @@ module Nu
11
11
  Gem::Dependency.new(spec,requirement)
12
12
  end
13
13
 
14
- def find(package_name)
14
+ def find(package_name, requirement=nil)
15
15
  dependency = dependency_from_requirement(package_name, nil)
16
16
  fetcher = Gem::SpecFetcher.new
17
17
  specs = fetcher.fetch(dependency, true)
@@ -21,7 +21,8 @@ module Nu
21
21
  end
22
22
  specs.sort! {|a,b| b.version <=> a.version}
23
23
  end
24
- specs
24
+ return specs unless requirement
25
+ return specs.detect {|spec| spec.satisfies_requirement?(dependency)} if requirement
25
26
  end
26
27
 
27
28
  def remote_spec_for(spec, requirement=nil)
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nu
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
5
4
  prerelease: false
6
5
  segments:
7
6
  - 0
8
7
  - 2
9
8
  - 6
10
- version: 0.2.6
9
+ - 1
10
+ version: 0.2.6.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Dru Sellers
@@ -18,7 +18,7 @@ autorequire:
18
18
  bindir: bin
19
19
  cert_chain: []
20
20
 
21
- date: 2010-09-25 00:00:00 -04:00
21
+ date: 2010-10-01 00:00:00 -04:00
22
22
  default_executable:
23
23
  dependencies:
24
24
  - !ruby/object:Gem::Dependency
@@ -29,7 +29,6 @@ dependencies:
29
29
  requirements:
30
30
  - - "="
31
31
  - !ruby/object:Gem::Version
32
- hash: 9
33
32
  segments:
34
33
  - 2
35
34
  - 3
@@ -83,7 +82,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
83
82
  requirements:
84
83
  - - ">="
85
84
  - !ruby/object:Gem::Version
86
- hash: 3
87
85
  segments:
88
86
  - 0
89
87
  version: "0"
@@ -92,7 +90,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
92
90
  requirements:
93
91
  - - ">="
94
92
  - !ruby/object:Gem::Version
95
- hash: 17
96
93
  segments:
97
94
  - 1
98
95
  - 3