nu 0.2.5 → 0.2.6.pre
Sign up to get free protection for your applications and to get access to all the features.
- data/docs/Home.md +9 -0
- data/docs/help-about-authors.md +17 -0
- data/docs/help-commands-config.md +10 -0
- data/docs/help-commands-install.md +4 -0
- data/docs/help-commands.md +9 -0
- data/docs/help-usage.md +34 -0
- data/docs/help.md +4 -0
- data/lib/nu/api.rb +39 -7
- data/lib/nu/app.rb +22 -35
- data/lib/nu/cli_shim.rb +22 -4
- data/lib/nu/dependency_leveling/analysis_results.rb +8 -0
- data/lib/nu/dependency_leveling/package_conflict_finder.rb +81 -0
- data/lib/nu/dependency_leveling/package_conflict_overlap_resolver.rb +43 -0
- data/lib/nu/gem_tools.rb +13 -0
- data/lib/nu/has_out_and_log.rb +6 -0
- data/lib/nu/help/help.rb +44 -0
- data/lib/nu/json_shim.rb +14 -5
- data/lib/nu/loader.rb +3 -27
- metadata +17 -5
data/docs/Home.md
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
Nubular - Gems for .NET
|
2
|
+
=======
|
3
|
+
**Nu will automatically download and install specified library packages into your lib folder, along with all their dependencies.**
|
4
|
+
|
5
|
+
This wiki provides the help content for Nu.
|
6
|
+
|
7
|
+
* [[Usage|help-usage]]
|
8
|
+
* [[Commands|help-commands]]
|
9
|
+
* [[About: Authors|help-about-authors]]
|
@@ -0,0 +1,17 @@
|
|
1
|
+
Help: About: Authors
|
2
|
+
====================
|
3
|
+
Some of the folks who have brought this project to you.
|
4
|
+
|
5
|
+
|
6
|
+
Code & Infrastructure:
|
7
|
+
----------------------
|
8
|
+
* Dru Sellers
|
9
|
+
* Brendan Erwin
|
10
|
+
* Rob Reynolds
|
11
|
+
* Travis Smith
|
12
|
+
|
13
|
+
|
14
|
+
Help Documentation:
|
15
|
+
-------------------
|
16
|
+
* Brendan Erwin
|
17
|
+
* _Your name here?_
|
@@ -0,0 +1,10 @@
|
|
1
|
+
Help: Commands: Config
|
2
|
+
======================
|
3
|
+
|
4
|
+
The `config` command works a lot like Git's. You can pass in any string and the value will be stored. If there is code that cares about the value you set, it will be affected, otherwise nothing will happen.
|
5
|
+
|
6
|
+
These are the current active config values:
|
7
|
+
|
8
|
+
* `lib.location` - The path to the library folder Nu will be placing the packages into. Defaults to `./lib`
|
9
|
+
|
10
|
+
* `lib.use_long_names` - If `true` Nu will place the packages in folders that include the version number. i.e. `log4net-1.2.3`. Defaults to `false`. (Note: this option can make it difficult to upgrade packages in the future as all the project references will have to be adjusted if the version changes.)
|
@@ -0,0 +1,9 @@
|
|
1
|
+
Help: Commands
|
2
|
+
==============
|
3
|
+
|
4
|
+
* `[[install|help-commands-install]] PACKAGE [OPTIONS...]` - Installs the specified PACKAGE in the lib folder.
|
5
|
+
* `[[report|help-commands-report]]` - Outputs the current packages in the lib folder.
|
6
|
+
* `[[specification|help-commands-specification]]` - Returns the package specification. Always returns JSON.
|
7
|
+
* `[[propose|help-commands-propose]] PACKAGE [--version VERSION]` - Analyzes what installing the proposed PACKAGE would do to the lib folder.
|
8
|
+
* `[[help|help-commands-help]]`
|
9
|
+
* `[[config|help-commands-config]]`
|
data/docs/help-usage.md
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
Help: Usage
|
2
|
+
===========
|
3
|
+
|
4
|
+
Nu will automatically download and install specified library packages into your lib folder, along with all their dependencies.
|
5
|
+
|
6
|
+
Usage:
|
7
|
+
nu help [SUBJECTS...]
|
8
|
+
nu -v/--version
|
9
|
+
nu COMMAND [arguments...] [options...]
|
10
|
+
|
11
|
+
Examples:
|
12
|
+
nu install fluentnhibernate
|
13
|
+
nu install nunit --version 2.5.7.10213.20100801
|
14
|
+
nu config lib.location ./lib
|
15
|
+
nu report
|
16
|
+
nu install fluentnhibernate --report
|
17
|
+
nu help commands install
|
18
|
+
nu help about
|
19
|
+
|
20
|
+
Options and Switches:
|
21
|
+
-v, --version VERSION Specify version of package to install
|
22
|
+
-r, --report Report on the packages currently installed in the lib folder. When called as a switch it will run the report AFTER executing the requested command.
|
23
|
+
--remote Use package server for query operations.
|
24
|
+
--cache Use local package cache for query operations.
|
25
|
+
-V, --verbose
|
26
|
+
-q, --quiet
|
27
|
+
--json Run in JSON mode. All outputs will be in JSON, status messages silenced.
|
28
|
+
-h, --help Display this screen
|
29
|
+
|
30
|
+
|
31
|
+
Further Information:
|
32
|
+
http://nu.wikispot.org
|
33
|
+
http://groups.google.com/group/nu-net
|
34
|
+
http://github.com/nu/nu/wiki
|
data/docs/help.md
ADDED
data/lib/nu/api.rb
CHANGED
@@ -5,6 +5,16 @@ require File.expand_path(File.dirname(__FILE__) + "/lib_tools.rb")
|
|
5
5
|
require File.expand_path(File.dirname(__FILE__) + "/gem_tools.rb")
|
6
6
|
require File.expand_path(File.dirname(__FILE__) + "/settings.rb")
|
7
7
|
|
8
|
+
require File.expand_path(File.dirname(__FILE__) + "/dependency_leveling/package_conflict_overlap_resolver.rb")
|
9
|
+
|
10
|
+
class ::Hash
|
11
|
+
def method_missing(name)
|
12
|
+
return self[name] if key? name
|
13
|
+
self.each { |k,v| return v if k.to_s.to_sym == name }
|
14
|
+
super.method_missing name
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
8
18
|
module Nu
|
9
19
|
class Api
|
10
20
|
|
@@ -79,14 +89,38 @@ module Nu
|
|
79
89
|
"Nubular, version #{nu_spec.version}"
|
80
90
|
end
|
81
91
|
|
82
|
-
def self.install_package(package_name, package_version)
|
83
|
-
log "Install called: package_name
|
92
|
+
def self.install_package(package_name, package_version=nil)
|
93
|
+
log "Install called: package_name: #{package_name} package_version: #{package_version}."
|
94
|
+
|
95
|
+
current_specs = @lib_tools.read_specs_from_lib(@project_settings.lib.location)
|
96
|
+
analyzer = PackageConflictOverlapResolver.new(current_specs, @gem_tools)
|
97
|
+
results = analyzer.analyze_proposal(@gem_tools.remote_spec_for(package_name, package_version))
|
84
98
|
|
85
|
-
|
86
|
-
|
87
|
-
|
99
|
+
unless results.conflict?
|
100
|
+
results.suggested_packages.each do |package|
|
101
|
+
loader = Nu::Loader.new(package.name, package.version, @project_settings.lib.location, @project_settings.lib.use_long_names, @out, @log)
|
102
|
+
log "Installing #{package.name} (#{package.version})"
|
103
|
+
if loader.load_gem
|
104
|
+
loader.copy_to_lib
|
105
|
+
end
|
106
|
+
end
|
107
|
+
out "Installed package #{(package + " #{package_version}").strip}"
|
108
|
+
else
|
109
|
+
out "Could not install #{package_name} due to conflicts. Run `propose` to see analysis."
|
88
110
|
end
|
111
|
+
|
112
|
+
return results
|
113
|
+
end
|
114
|
+
|
115
|
+
def self.propose_package(package_name, package_version=nil)
|
116
|
+
log "Propose Package called. package_name: #{package_name} package_version: #{package_version}"
|
117
|
+
current_specs = @lib_tools.read_specs_from_lib(@project_settings.lib.location)
|
118
|
+
|
119
|
+
log "Current Package Specs:"
|
120
|
+
current_specs.each{|spec| log "#{spec.name} (#{spec.version})"}
|
89
121
|
|
122
|
+
analyzer = PackageConflictOverlapResolver.new(current_specs, @gem_tools)
|
123
|
+
analyzer.analyze_proposal(@gem_tools.remote_spec_for(package_name, package_version))
|
90
124
|
end
|
91
125
|
|
92
126
|
def self.report()
|
@@ -121,8 +155,6 @@ module Nu
|
|
121
155
|
else
|
122
156
|
raise "source can only be :lib, :cache, or :remote"
|
123
157
|
end
|
124
|
-
|
125
|
-
|
126
158
|
end
|
127
159
|
|
128
160
|
private
|
data/lib/nu/app.rb
CHANGED
@@ -8,9 +8,11 @@ require File.expand_path(File.dirname(__FILE__) + "/api.rb")
|
|
8
8
|
require File.expand_path(File.dirname(__FILE__) + "/loader.rb")
|
9
9
|
require File.expand_path(File.dirname(__FILE__) + "/cli_shim.rb")
|
10
10
|
require File.expand_path(File.dirname(__FILE__) + "/json_shim.rb")
|
11
|
-
|
11
|
+
require File.expand_path(File.dirname(__FILE__) + "/help/help.rb")
|
12
|
+
|
12
13
|
class App
|
13
|
-
|
14
|
+
include Help
|
15
|
+
|
14
16
|
attr_reader :options
|
15
17
|
|
16
18
|
def initialize(arguments, stdin, stdout)
|
@@ -37,41 +39,27 @@ class App
|
|
37
39
|
begin
|
38
40
|
OptionParser.new do |opts|
|
39
41
|
|
40
|
-
opts.
|
41
|
-
"\n nu -h/--help" +
|
42
|
-
"\n nu -v/--version" +
|
43
|
-
"\n nu COMMAND [arguments...] [options...]" +
|
44
|
-
"\n\nExamples:" +
|
45
|
-
"\n nu install fluentnhibernate" +
|
46
|
-
"\n nu install nunit --version 2.5.7.10213.20100801" +
|
47
|
-
"\n nu config lib.location ./lib" +
|
48
|
-
"\n nu report" +
|
49
|
-
"\n nu install fluentnhibernate --report" +
|
50
|
-
"\n\nOptions and Switches:"
|
51
|
-
|
52
|
-
opts.on('-v', '--version VERSION','Specify version of package to install' ) do |ver|
|
42
|
+
opts.on('-v', '--version VERSION') do |ver|
|
53
43
|
@options.package_version = ver
|
54
44
|
end
|
55
45
|
|
56
|
-
opts.on('-r','--report'
|
46
|
+
opts.on('-r','--report') do
|
57
47
|
@commands << lambda {@shim.report}
|
58
48
|
end
|
59
49
|
|
60
50
|
# Specify options
|
61
51
|
@options.source = :lib
|
62
|
-
opts.on('--remote'
|
63
|
-
opts.on('--cache'
|
52
|
+
opts.on('--remote') {@options.source = :remote}
|
53
|
+
opts.on('--cache') {@options.source = :cache unless @options.source == :remote}
|
64
54
|
opts.on('-V', '--verbose') { @options.verbose = true }
|
65
55
|
opts.on('-q', '--quiet') { @options.quiet = true }
|
66
|
-
opts.on('--json'
|
67
|
-
set_json
|
68
|
-
end
|
56
|
+
opts.on('--json') {set_json}
|
69
57
|
|
70
|
-
opts.on_tail( '-h', '--help'
|
71
|
-
output_help
|
58
|
+
opts.on_tail( '-h', '--help' ) do
|
59
|
+
output_help
|
72
60
|
end
|
73
61
|
|
74
|
-
@help_command = lambda{output_help
|
62
|
+
@help_command = lambda{output_help}
|
75
63
|
|
76
64
|
end.parse!
|
77
65
|
rescue
|
@@ -118,7 +106,7 @@ class App
|
|
118
106
|
@commands << lambda {@shim.report}
|
119
107
|
when 'specification'
|
120
108
|
if @options.source == :lib && @options.package_version
|
121
|
-
puts "The --version flag
|
109
|
+
puts "The --version flag cannot be used with the specification command unless either --cache or --remote is also specified."
|
122
110
|
exit 1
|
123
111
|
end
|
124
112
|
set_json
|
@@ -131,6 +119,12 @@ class App
|
|
131
119
|
# assert_param_count(2)
|
132
120
|
# @options.package = @arguments[1]
|
133
121
|
# @commands << lambda {@shim.uninstall_package(@options.package, @options.package_version)}
|
122
|
+
when 'propose'
|
123
|
+
assert_param_count(2)
|
124
|
+
@options.package = @arguments[1]
|
125
|
+
@commands << lambda {@shim.propose(@options.package, @options.package_version)}
|
126
|
+
when 'help'
|
127
|
+
@commands << lambda {output_help(@arguments)}
|
134
128
|
when 'config'
|
135
129
|
if @arguments.length == 2
|
136
130
|
@commands << lambda {@shim.get_setting(@arguments[1])}
|
@@ -170,14 +164,11 @@ class App
|
|
170
164
|
disp ""
|
171
165
|
end
|
172
166
|
|
173
|
-
def output_help(
|
167
|
+
def output_help(descriptor='help-usage')
|
174
168
|
@options.quiet = false
|
175
169
|
output_version
|
176
|
-
|
177
|
-
disp
|
178
|
-
disp "\n\nFurther Information:" +
|
179
|
-
"\n http://nu.wikispot.org" +
|
180
|
-
"\n http://groups.google.com/group/nu-net"
|
170
|
+
disp ''
|
171
|
+
disp help_doc_for(descriptor)
|
181
172
|
disp ''
|
182
173
|
exit 0
|
183
174
|
end
|
@@ -185,10 +176,6 @@ class App
|
|
185
176
|
def output_version
|
186
177
|
disp Nu::Api.version_string
|
187
178
|
end
|
188
|
-
|
189
|
-
def output_description
|
190
|
-
disp "Nu will automatically download and install specified library packages into your lib folder, along with all their dependencies.\n"
|
191
|
-
end
|
192
179
|
|
193
180
|
def disp(msg)
|
194
181
|
puts msg unless @options.quiet || @options.json
|
data/lib/nu/cli_shim.rb
CHANGED
@@ -8,19 +8,37 @@ class CliShim < HasOutAndLog
|
|
8
8
|
|
9
9
|
out "\n"
|
10
10
|
out "The following packages are installed:"
|
11
|
-
|
11
|
+
hr
|
12
12
|
#TODO: render differently if details==true
|
13
13
|
Nu::Api.report.each{|i| out " #{i.name} (#{i.version})"}
|
14
|
-
|
15
|
-
out ""
|
14
|
+
hr("\n")
|
16
15
|
end
|
17
16
|
|
18
17
|
def install_package(package, package_version)
|
19
18
|
Nu::Api.install_package(package, package_version)
|
20
|
-
out "Installed package #{(package + " #{package_version}").strip}."
|
21
19
|
end
|
22
20
|
|
23
21
|
def get_setting(name)
|
24
22
|
out "#{name} = #{Nu::Api.get_setting(name)}"
|
25
23
|
end
|
24
|
+
|
25
|
+
def propose(name, version)
|
26
|
+
log "Propose called. name: #{name} version: #{version}"
|
27
|
+
report(true)
|
28
|
+
out "Analyzing effects of installing #{name}..."
|
29
|
+
results = Nu::Api.propose_package(name, version)
|
30
|
+
|
31
|
+
if results.conflict?
|
32
|
+
out "A conflict is detected between #{name} \nand the currently installed:"
|
33
|
+
hr
|
34
|
+
results.conflicts.each{|spec| out " #{spec[:name]} (#{spec[:requirement_one].requirements.first}) vs. (#{spec[:requirement_two].requirements.first})"}
|
35
|
+
hr("\n")
|
36
|
+
else
|
37
|
+
out "No unresolved conflicts. \nAdding #{name} would result in:"
|
38
|
+
hr
|
39
|
+
results.suggested_packages.each{|spec| out " #{spec[:name]} (#{spec[:version]})"}
|
40
|
+
hr("\n")
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
26
44
|
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require File.expand_path(File.dirname(__FILE__) + "/analysis_results.rb")
|
3
|
+
|
4
|
+
class PackageConflictFinder
|
5
|
+
def initialize(installed_packages)
|
6
|
+
@installed_packages = installed_packages
|
7
|
+
end
|
8
|
+
|
9
|
+
def analyze_proposal(proposed_package)
|
10
|
+
suggested_packages = initialized_suggested_packages(proposed_package)
|
11
|
+
|
12
|
+
conflicts = find_conflicts(proposed_package)
|
13
|
+
conflict_found = conflicts.length > 0
|
14
|
+
|
15
|
+
conflicting_packages = conflicts.map{|hash| hash[:name]}
|
16
|
+
suggested_packages = suggested_packages.delete_if{|item| conflicting_packages.include?(item[:name])}
|
17
|
+
|
18
|
+
AnalysisResults.new do |r|
|
19
|
+
r.conflict = conflict_found
|
20
|
+
r.conflicts = conflicts.uniq
|
21
|
+
r.suggested_packages = suggested_packages.uniq
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def req(val)
|
28
|
+
Gem::Requirement.create(val)
|
29
|
+
end
|
30
|
+
|
31
|
+
def initialized_suggested_packages(proposed_package)
|
32
|
+
suggested_packages = @installed_packages.map{|spec| {:name=> spec.name, :version=> req(spec.version)}}
|
33
|
+
|
34
|
+
suggested_packages.reject! {|i| i[:name] == proposed_package.name}
|
35
|
+
suggested_packages << {:name=>proposed_package.name, :version=> req(proposed_package.version)}
|
36
|
+
|
37
|
+
proposed_package.dependencies.each do |dep|
|
38
|
+
suggested_packages.reject! {|i| i[:name] == dep.name}
|
39
|
+
suggested_packages << {:name=>dep.name, :version=>dep.requirement}
|
40
|
+
end
|
41
|
+
return suggested_packages
|
42
|
+
end
|
43
|
+
|
44
|
+
def find_conflicts(proposed_spec)
|
45
|
+
conflicts = []
|
46
|
+
|
47
|
+
#installed packages that conflict with the proposed_spec
|
48
|
+
@installed_packages.each do |installed_package|
|
49
|
+
if (installed_package.name == proposed_spec.name ? installed_package.version != proposed_spec.version : false)
|
50
|
+
conflicts << {:name => installed_package.name, :requirement_one => req(installed_package.version), :requirement_two => req(proposed_spec.version)}
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
#installed package's dependencies that conflict with the proposed_spec
|
55
|
+
@installed_packages.each do |installed_package|
|
56
|
+
conflicts = conflicts | installed_package.dependencies.select do |dep|
|
57
|
+
dep.name == proposed_spec.name ? !proposed_spec.satisfies_requirement?(dep) : false
|
58
|
+
end.map{|dep| {:name => dep.name, :requirement_one => get_req_as_dep_of_installed(proposed_spec.name), :requirement_two => req(proposed_spec.version)}}
|
59
|
+
end
|
60
|
+
|
61
|
+
#proposed_spec's dependencies that conflict with installed packages
|
62
|
+
@installed_packages.each do |installed_package|
|
63
|
+
conflicts = conflicts | proposed_spec.dependencies.select do |dep|
|
64
|
+
dep.name == installed_package.name ? !installed_package.satisfies_requirement?(dep) : false
|
65
|
+
end.map{|dep| {:name => dep.name, :requirement_one => dep.requirement, :requirement_two => get_req_as_dep_of_installed(installed_package.name)}}
|
66
|
+
end
|
67
|
+
|
68
|
+
conflicts
|
69
|
+
end
|
70
|
+
|
71
|
+
def get_req_as_dep_of_installed(name)
|
72
|
+
|
73
|
+
deps = []
|
74
|
+
@installed_packages.select{|p| p.dependencies.length > 0}.each do |spec|
|
75
|
+
spec.dependencies.each{|d| deps << d}
|
76
|
+
end
|
77
|
+
dep = deps.select{|d| d.name == name}.first
|
78
|
+
return dep.requirement if dep
|
79
|
+
return req(@installed_packages.select{|p| p.name == name}.first.version) unless dep
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require File.expand_path(File.dirname(__FILE__) + "/package_conflict_finder.rb")
|
3
|
+
|
4
|
+
class PackageConflictOverlapResolver
|
5
|
+
def initialize(installed_packages, package_lister)
|
6
|
+
@installed_packages = installed_packages
|
7
|
+
raise "package_lister must respond to find(name)" unless package_lister.respond_to?("find")
|
8
|
+
@package_lister = package_lister
|
9
|
+
@conflict_finder = PackageConflictFinder.new(installed_packages)
|
10
|
+
end
|
11
|
+
|
12
|
+
def analyze_proposal(proposed_package)
|
13
|
+
r = @conflict_finder.analyze_proposal(proposed_package)
|
14
|
+
|
15
|
+
Array.new(r.conflicts).each do |conflict|
|
16
|
+
hav = highest_acceptable_version(conflict[:name], conflict[:requirement_one], conflict[:requirement_two])
|
17
|
+
resolve_conflict(r,conflict,hav) if hav
|
18
|
+
end if r.conflict?
|
19
|
+
|
20
|
+
r.suggested_packages.uniq!
|
21
|
+
r.conflicts.uniq!
|
22
|
+
|
23
|
+
return r
|
24
|
+
end
|
25
|
+
|
26
|
+
def highest_acceptable_version(name, requirement_one, requirement_two)
|
27
|
+
candidates = @package_lister.find(name)
|
28
|
+
candidates = candidates.select do |spec|
|
29
|
+
requirement_one.satisfied_by?(spec.version) and requirement_two.satisfied_by?(spec.version)
|
30
|
+
end
|
31
|
+
return Gem::Requirement.new(candidates.sort{|a,b| a.version <=> b.version}.last.version) if candidates.length > 0
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
def resolve_conflict(results,conflict,version)
|
37
|
+
results.conflicts.reject! {|c| c[:name] == conflict[:name]}
|
38
|
+
results.suggested_packages.reject! {|p| p[:name] == conflict[:name]}
|
39
|
+
results.suggested_packages << {:name => conflict[:name], :version => version}
|
40
|
+
results.conflict = results.conflicts.length > 0
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
data/lib/nu/gem_tools.rb
CHANGED
@@ -11,6 +11,19 @@ module Nu
|
|
11
11
|
Gem::Dependency.new(spec,requirement)
|
12
12
|
end
|
13
13
|
|
14
|
+
def find(package_name)
|
15
|
+
dependency = dependency_from_requirement(package_name, nil)
|
16
|
+
fetcher = Gem::SpecFetcher.new
|
17
|
+
specs = fetcher.fetch(dependency, true)
|
18
|
+
unless specs == nil
|
19
|
+
specs.map! do |item|
|
20
|
+
item.first
|
21
|
+
end
|
22
|
+
specs.sort! {|a,b| b.version <=> a.version}
|
23
|
+
end
|
24
|
+
specs
|
25
|
+
end
|
26
|
+
|
14
27
|
def remote_spec_for(spec, requirement=nil)
|
15
28
|
dependency = dependency_from_requirement(spec, nil)
|
16
29
|
fetcher = Gem::SpecFetcher.new
|
data/lib/nu/has_out_and_log.rb
CHANGED
data/lib/nu/help/help.rb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../gem_tools.rb")
|
2
|
+
|
3
|
+
module Help
|
4
|
+
|
5
|
+
def help_doc_path
|
6
|
+
gtool = Nu::GemTools.new
|
7
|
+
File.expand_path(File.join(gtool.spec_for('nu').full_gem_path,'docs'))
|
8
|
+
end
|
9
|
+
|
10
|
+
def help_doc_for(descriptor)
|
11
|
+
log "help_doc_for called: descriptor: #{descriptor.inspect}"
|
12
|
+
|
13
|
+
if descriptor.is_a?(String)
|
14
|
+
descriptor.downcase!
|
15
|
+
descriptor_description = descriptor.gsub(/-/, ": ")
|
16
|
+
end
|
17
|
+
|
18
|
+
if descriptor.is_a?(Array)
|
19
|
+
descriptor.map!{|item| item.downcase}
|
20
|
+
descriptor_description = descriptor.join(': ')
|
21
|
+
descriptor = descriptor.join('-')
|
22
|
+
end
|
23
|
+
|
24
|
+
file_path = File.join(help_doc_path, descriptor + ".md")
|
25
|
+
log "Looking for file at: #{file_path}"
|
26
|
+
|
27
|
+
return "No help found for \"#{descriptor_description}\"" unless File.exists?(file_path)
|
28
|
+
|
29
|
+
filter_markdown(IO.read(file_path))
|
30
|
+
end
|
31
|
+
|
32
|
+
def filter_markdown(from)
|
33
|
+
#links
|
34
|
+
from.gsub!(/\[\[(.*)\|.*\]\]/,'\1')
|
35
|
+
from.gsub!(/\[\[(.*)\]\]/,'\1')
|
36
|
+
|
37
|
+
#word wrap
|
38
|
+
col = 80
|
39
|
+
from.gsub!(/(.{1,#{col}})( +|$\n?)|(.{1,#{col}})/,"\\1\\3\n")
|
40
|
+
|
41
|
+
return from
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
data/lib/nu/json_shim.rb
CHANGED
@@ -6,24 +6,33 @@ require File.expand_path(File.dirname(__FILE__) + "/has_out_and_log.rb")
|
|
6
6
|
class JsonShim < HasOutAndLog
|
7
7
|
|
8
8
|
def report
|
9
|
-
|
9
|
+
json_out Nu::Api.report
|
10
|
+
end
|
11
|
+
|
12
|
+
def json_out(object)
|
13
|
+
out object.to_json
|
10
14
|
end
|
11
15
|
|
12
16
|
def install_package(package, package_version)
|
13
|
-
Nu::Api.install_package(package, package_version)
|
17
|
+
json_out Nu::Api.install_package(package, package_version)
|
14
18
|
end
|
15
19
|
|
16
20
|
def get_setting(name)
|
17
|
-
|
21
|
+
json_out ({:name => name, :value => Nu::Api.get_setting(name) })
|
18
22
|
end
|
19
23
|
|
20
24
|
def specification(name, version, source)
|
21
25
|
log "Json Shim Specification called. name: #{name} version: #{version} source:#{source}"
|
22
26
|
if version == nil
|
23
|
-
|
27
|
+
json_out Nu::Api.retrieve_specification(name, :from => source)
|
24
28
|
else
|
25
|
-
|
29
|
+
json_out Nu::Api.retrieve_specification_with_version(name, version, :from => source)
|
26
30
|
end
|
27
31
|
end
|
28
32
|
|
33
|
+
def propose(name, version)
|
34
|
+
log "Json Shim Propose called. name: #{name} version: #{version}"
|
35
|
+
json_out Nu::Api.propose_package(name, version)
|
36
|
+
end
|
37
|
+
|
29
38
|
end
|
data/lib/nu/loader.rb
CHANGED
@@ -23,14 +23,13 @@ module Nu
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def load_gem
|
26
|
-
|
27
|
-
|
28
|
-
out "Gem #{(@gem_name + " #{@version}").strip} is not installed locally - I am now going to try and install it"
|
26
|
+
if (!Gem.available? @gem_name, @version) or (@version == nil)
|
27
|
+
out "Getting #{(@gem_name + " #{@version}").strip}..."
|
29
28
|
begin
|
30
29
|
inst = Gem::DependencyInstaller.new
|
31
30
|
inst.install @gem_name, @version
|
32
31
|
inst.installed_gems.each do |spec|
|
33
|
-
out "
|
32
|
+
out "Got #{spec.full_name}"
|
34
33
|
end
|
35
34
|
rescue Gem::GemNotFoundException => e
|
36
35
|
out "ERROR: #{e.message}"
|
@@ -50,22 +49,12 @@ module Nu
|
|
50
49
|
|
51
50
|
FileUtils.copy_entry start_here, to
|
52
51
|
@gem_tools.write_spec(gemspec, to)
|
53
|
-
|
54
|
-
process_dependencies
|
55
52
|
end
|
56
53
|
|
57
54
|
def gemspec
|
58
55
|
@gem_tools.spec_for(@gem_name, @version)
|
59
56
|
end
|
60
57
|
|
61
|
-
def gem_available?
|
62
|
-
if @version.nil?
|
63
|
-
Gem.available? @gem_name
|
64
|
-
else
|
65
|
-
Gem.available? @gem_name, @version
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
58
|
def copy_source
|
70
59
|
@gem_tools.lib_for(@gem_name, @version).gsub '{lib}','lib'
|
71
60
|
end
|
@@ -74,18 +63,5 @@ module Nu
|
|
74
63
|
@lib_tools.folder_for(gemspec, @location, @long_names)
|
75
64
|
end
|
76
65
|
|
77
|
-
def process_dependencies
|
78
|
-
gemspec.dependencies.each do |d|
|
79
|
-
if Gem.available? d.name
|
80
|
-
out "Loading dependency: #{d.name} #{d.requirement}"
|
81
|
-
loader = Loader.new(d.name, d.requirement, @location, @long_names, @out, @log)
|
82
|
-
loader.copy_to_lib
|
83
|
-
else
|
84
|
-
out "#{d.name} is not installed locally"
|
85
|
-
out "please run 'gem install #{d.name}"
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
66
|
end
|
91
67
|
end
|
metadata
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 961915980
|
5
|
+
prerelease: true
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
|
9
|
+
- 6
|
10
|
+
- pre
|
11
|
+
version: 0.2.6.pre
|
11
12
|
platform: ruby
|
12
13
|
authors:
|
13
14
|
- Dru Sellers
|
@@ -18,7 +19,7 @@ autorequire:
|
|
18
19
|
bindir: bin
|
19
20
|
cert_chain: []
|
20
21
|
|
21
|
-
date: 2010-09-
|
22
|
+
date: 2010-09-20 00:00:00 -04:00
|
22
23
|
default_executable:
|
23
24
|
dependencies:
|
24
25
|
- !ruby/object:Gem::Dependency
|
@@ -51,13 +52,24 @@ files:
|
|
51
52
|
- lib/nu/api.rb
|
52
53
|
- lib/nu/app.rb
|
53
54
|
- lib/nu/cli_shim.rb
|
55
|
+
- lib/nu/dependency_leveling/analysis_results.rb
|
56
|
+
- lib/nu/dependency_leveling/package_conflict_finder.rb
|
57
|
+
- lib/nu/dependency_leveling/package_conflict_overlap_resolver.rb
|
54
58
|
- lib/nu/gem_tools.rb
|
55
59
|
- lib/nu/has_out_and_log.rb
|
60
|
+
- lib/nu/help/help.rb
|
56
61
|
- lib/nu/json_shim.rb
|
57
62
|
- lib/nu/lib_tools.rb
|
58
63
|
- lib/nu/loader.rb
|
59
64
|
- lib/nu/settings.rb
|
60
65
|
- lib/nu.rb
|
66
|
+
- docs/help-about-authors.md
|
67
|
+
- docs/help-commands-config.md
|
68
|
+
- docs/help-commands-install.md
|
69
|
+
- docs/help-commands.md
|
70
|
+
- docs/help-usage.md
|
71
|
+
- docs/help.md
|
72
|
+
- docs/Home.md
|
61
73
|
has_rdoc: true
|
62
74
|
homepage: http://groups.google.com/group/nu-net
|
63
75
|
licenses: []
|