libgems 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +5811 -0
- data/History.txt +887 -0
- data/LICENSE.txt +51 -0
- data/README.md +87 -0
- data/Rakefile +113 -0
- data/lib/gauntlet_libgems.rb +50 -0
- data/lib/libgems.rb +1246 -0
- data/lib/libgems/builder.rb +102 -0
- data/lib/libgems/command.rb +534 -0
- data/lib/libgems/command_manager.rb +182 -0
- data/lib/libgems/commands/build_command.rb +53 -0
- data/lib/libgems/commands/cert_command.rb +86 -0
- data/lib/libgems/commands/check_command.rb +80 -0
- data/lib/libgems/commands/cleanup_command.rb +106 -0
- data/lib/libgems/commands/contents_command.rb +98 -0
- data/lib/libgems/commands/dependency_command.rb +195 -0
- data/lib/libgems/commands/environment_command.rb +133 -0
- data/lib/libgems/commands/fetch_command.rb +67 -0
- data/lib/libgems/commands/generate_index_command.rb +133 -0
- data/lib/libgems/commands/help_command.rb +172 -0
- data/lib/libgems/commands/install_command.rb +178 -0
- data/lib/libgems/commands/list_command.rb +35 -0
- data/lib/libgems/commands/lock_command.rb +110 -0
- data/lib/libgems/commands/mirror_command.rb +111 -0
- data/lib/libgems/commands/outdated_command.rb +33 -0
- data/lib/libgems/commands/owner_command.rb +75 -0
- data/lib/libgems/commands/pristine_command.rb +93 -0
- data/lib/libgems/commands/push_command.rb +56 -0
- data/lib/libgems/commands/query_command.rb +280 -0
- data/lib/libgems/commands/rdoc_command.rb +91 -0
- data/lib/libgems/commands/search_command.rb +31 -0
- data/lib/libgems/commands/server_command.rb +86 -0
- data/lib/libgems/commands/sources_command.rb +157 -0
- data/lib/libgems/commands/specification_command.rb +125 -0
- data/lib/libgems/commands/stale_command.rb +27 -0
- data/lib/libgems/commands/uninstall_command.rb +83 -0
- data/lib/libgems/commands/unpack_command.rb +121 -0
- data/lib/libgems/commands/update_command.rb +160 -0
- data/lib/libgems/commands/which_command.rb +86 -0
- data/lib/libgems/config_file.rb +345 -0
- data/lib/libgems/custom_require.rb +44 -0
- data/lib/libgems/defaults.rb +101 -0
- data/lib/libgems/dependency.rb +227 -0
- data/lib/libgems/dependency_installer.rb +286 -0
- data/lib/libgems/dependency_list.rb +208 -0
- data/lib/libgems/doc_manager.rb +242 -0
- data/lib/libgems/errors.rb +35 -0
- data/lib/libgems/exceptions.rb +91 -0
- data/lib/libgems/ext.rb +18 -0
- data/lib/libgems/ext/builder.rb +56 -0
- data/lib/libgems/ext/configure_builder.rb +25 -0
- data/lib/libgems/ext/ext_conf_builder.rb +24 -0
- data/lib/libgems/ext/rake_builder.rb +39 -0
- data/lib/libgems/format.rb +81 -0
- data/lib/libgems/gem_openssl.rb +92 -0
- data/lib/libgems/gem_path_searcher.rb +100 -0
- data/lib/libgems/gem_runner.rb +79 -0
- data/lib/libgems/gemcutter_utilities.rb +49 -0
- data/lib/libgems/indexer.rb +720 -0
- data/lib/libgems/install_update_options.rb +125 -0
- data/lib/libgems/installer.rb +604 -0
- data/lib/libgems/local_remote_options.rb +135 -0
- data/lib/libgems/old_format.rb +153 -0
- data/lib/libgems/package.rb +97 -0
- data/lib/libgems/package/f_sync_dir.rb +23 -0
- data/lib/libgems/package/tar_header.rb +266 -0
- data/lib/libgems/package/tar_input.rb +222 -0
- data/lib/libgems/package/tar_output.rb +144 -0
- data/lib/libgems/package/tar_reader.rb +106 -0
- data/lib/libgems/package/tar_reader/entry.rb +141 -0
- data/lib/libgems/package/tar_writer.rb +241 -0
- data/lib/libgems/package_task.rb +126 -0
- data/lib/libgems/platform.rb +183 -0
- data/lib/libgems/remote_fetcher.rb +414 -0
- data/lib/libgems/require_paths_builder.rb +18 -0
- data/lib/libgems/requirement.rb +153 -0
- data/lib/libgems/security.rb +814 -0
- data/lib/libgems/server.rb +872 -0
- data/lib/libgems/source_index.rb +597 -0
- data/lib/libgems/source_info_cache.rb +395 -0
- data/lib/libgems/source_info_cache_entry.rb +56 -0
- data/lib/libgems/spec_fetcher.rb +337 -0
- data/lib/libgems/specification.rb +1487 -0
- data/lib/libgems/test_utilities.rb +147 -0
- data/lib/libgems/text.rb +65 -0
- data/lib/libgems/uninstaller.rb +278 -0
- data/lib/libgems/user_interaction.rb +527 -0
- data/lib/libgems/validator.rb +240 -0
- data/lib/libgems/version.rb +316 -0
- data/lib/libgems/version_option.rb +65 -0
- data/lib/rbconfig/datadir.rb +20 -0
- data/test/bogussources.rb +8 -0
- data/test/data/gem-private_key.pem +27 -0
- data/test/data/gem-public_cert.pem +20 -0
- data/test/fake_certlib/openssl.rb +7 -0
- data/test/foo/discover.rb +0 -0
- data/test/gem_installer_test_case.rb +97 -0
- data/test/gem_package_tar_test_case.rb +132 -0
- data/test/gemutilities.rb +605 -0
- data/test/insure_session.rb +43 -0
- data/test/mockgemui.rb +56 -0
- data/test/plugin/exception/libgems_plugin.rb +2 -0
- data/test/plugin/load/libgems_plugin.rb +1 -0
- data/test/plugin/standarderror/libgems_plugin.rb +2 -0
- data/test/private_key.pem +27 -0
- data/test/public_cert.pem +20 -0
- data/test/rubygems_plugin.rb +21 -0
- data/test/simple_gem.rb +66 -0
- data/test/test_config.rb +12 -0
- data/test/test_gem.rb +780 -0
- data/test/test_gem_builder.rb +27 -0
- data/test/test_gem_command.rb +178 -0
- data/test/test_gem_command_manager.rb +207 -0
- data/test/test_gem_commands_build_command.rb +74 -0
- data/test/test_gem_commands_cert_command.rb +124 -0
- data/test/test_gem_commands_check_command.rb +18 -0
- data/test/test_gem_commands_contents_command.rb +156 -0
- data/test/test_gem_commands_dependency_command.rb +216 -0
- data/test/test_gem_commands_environment_command.rb +144 -0
- data/test/test_gem_commands_fetch_command.rb +76 -0
- data/test/test_gem_commands_generate_index_command.rb +135 -0
- data/test/test_gem_commands_install_command.rb +315 -0
- data/test/test_gem_commands_list_command.rb +36 -0
- data/test/test_gem_commands_lock_command.rb +68 -0
- data/test/test_gem_commands_mirror_command.rb +60 -0
- data/test/test_gem_commands_outdated_command.rb +40 -0
- data/test/test_gem_commands_owner_command.rb +105 -0
- data/test/test_gem_commands_pristine_command.rb +108 -0
- data/test/test_gem_commands_push_command.rb +81 -0
- data/test/test_gem_commands_query_command.rb +426 -0
- data/test/test_gem_commands_server_command.rb +59 -0
- data/test/test_gem_commands_sources_command.rb +209 -0
- data/test/test_gem_commands_specification_command.rb +139 -0
- data/test/test_gem_commands_stale_command.rb +38 -0
- data/test/test_gem_commands_uninstall_command.rb +83 -0
- data/test/test_gem_commands_unpack_command.rb +199 -0
- data/test/test_gem_commands_update_command.rb +207 -0
- data/test/test_gem_commands_which_command.rb +66 -0
- data/test/test_gem_config_file.rb +287 -0
- data/test/test_gem_dependency.rb +149 -0
- data/test/test_gem_dependency_installer.rb +661 -0
- data/test/test_gem_dependency_list.rb +230 -0
- data/test/test_gem_doc_manager.rb +31 -0
- data/test/test_gem_ext_configure_builder.rb +84 -0
- data/test/test_gem_ext_ext_conf_builder.rb +173 -0
- data/test/test_gem_ext_rake_builder.rb +81 -0
- data/test/test_gem_format.rb +70 -0
- data/test/test_gem_gem_path_searcher.rb +78 -0
- data/test/test_gem_gem_runner.rb +45 -0
- data/test/test_gem_gemcutter_utilities.rb +103 -0
- data/test/test_gem_indexer.rb +673 -0
- data/test/test_gem_install_update_options.rb +68 -0
- data/test/test_gem_installer.rb +857 -0
- data/test/test_gem_local_remote_options.rb +97 -0
- data/test/test_gem_package_tar_header.rb +130 -0
- data/test/test_gem_package_tar_input.rb +112 -0
- data/test/test_gem_package_tar_output.rb +97 -0
- data/test/test_gem_package_tar_reader.rb +46 -0
- data/test/test_gem_package_tar_reader_entry.rb +109 -0
- data/test/test_gem_package_tar_writer.rb +144 -0
- data/test/test_gem_package_task.rb +59 -0
- data/test/test_gem_platform.rb +264 -0
- data/test/test_gem_remote_fetcher.rb +740 -0
- data/test/test_gem_requirement.rb +292 -0
- data/test/test_gem_server.rb +356 -0
- data/test/test_gem_silent_ui.rb +113 -0
- data/test/test_gem_source_index.rb +461 -0
- data/test/test_gem_spec_fetcher.rb +410 -0
- data/test/test_gem_specification.rb +1334 -0
- data/test/test_gem_stream_ui.rb +218 -0
- data/test/test_gem_text.rb +43 -0
- data/test/test_gem_uninstaller.rb +146 -0
- data/test/test_gem_validator.rb +63 -0
- data/test/test_gem_version.rb +181 -0
- data/test/test_gem_version_option.rb +89 -0
- data/test/test_kernel.rb +59 -0
- metadata +402 -0
@@ -0,0 +1,98 @@
|
|
1
|
+
require 'libgems/command'
|
2
|
+
require 'libgems/version_option'
|
3
|
+
|
4
|
+
class LibGems::Commands::ContentsCommand < LibGems::Command
|
5
|
+
|
6
|
+
include LibGems::VersionOption
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
super 'contents', 'Display the contents of the installed gems',
|
10
|
+
:specdirs => [], :lib_only => false, :prefix => true
|
11
|
+
|
12
|
+
add_version_option
|
13
|
+
|
14
|
+
add_option( '--all',
|
15
|
+
"Contents for all gems") do |all, options|
|
16
|
+
options[:all] = all
|
17
|
+
end
|
18
|
+
|
19
|
+
add_option('-s', '--spec-dir a,b,c', Array,
|
20
|
+
"Search for gems under specific paths") do |spec_dirs, options|
|
21
|
+
options[:specdirs] = spec_dirs
|
22
|
+
end
|
23
|
+
|
24
|
+
add_option('-l', '--[no-]lib-only',
|
25
|
+
"Only return files in the LibGems's lib_dirs") do |lib_only, options|
|
26
|
+
options[:lib_only] = lib_only
|
27
|
+
end
|
28
|
+
|
29
|
+
add_option( '--[no-]prefix',
|
30
|
+
"Don't include installed path prefix") do |prefix, options|
|
31
|
+
options[:prefix] = prefix
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def arguments # :nodoc:
|
36
|
+
"GEMNAME name of gem to list contents for"
|
37
|
+
end
|
38
|
+
|
39
|
+
def defaults_str # :nodoc:
|
40
|
+
"--no-lib-only --prefix"
|
41
|
+
end
|
42
|
+
|
43
|
+
def usage # :nodoc:
|
44
|
+
"#{program_name} GEMNAME [GEMNAME ...]"
|
45
|
+
end
|
46
|
+
|
47
|
+
def execute
|
48
|
+
version = options[:version] || LibGems::Requirement.default
|
49
|
+
|
50
|
+
spec_dirs = options[:specdirs].map do |i|
|
51
|
+
[i, File.join(i, "specifications")]
|
52
|
+
end.flatten
|
53
|
+
|
54
|
+
path_kind = if spec_dirs.empty? then
|
55
|
+
spec_dirs = LibGems::SourceIndex.installed_spec_directories
|
56
|
+
"default gem paths"
|
57
|
+
else
|
58
|
+
"specified path"
|
59
|
+
end
|
60
|
+
|
61
|
+
si = LibGems::SourceIndex.from_gems_in(*spec_dirs)
|
62
|
+
|
63
|
+
gem_names = if options[:all] then
|
64
|
+
si.map { |_, spec| spec.name }
|
65
|
+
else
|
66
|
+
get_all_gem_names
|
67
|
+
end
|
68
|
+
|
69
|
+
gem_names.each do |name|
|
70
|
+
gem_spec = si.find_name(name, version).last
|
71
|
+
|
72
|
+
unless gem_spec then
|
73
|
+
say "Unable to find gem '#{name}' in #{path_kind}"
|
74
|
+
|
75
|
+
if LibGems.configuration.verbose then
|
76
|
+
say "\nDirectories searched:"
|
77
|
+
spec_dirs.each { |dir| say dir }
|
78
|
+
end
|
79
|
+
|
80
|
+
terminate_interaction 1 if gem_names.length == 1
|
81
|
+
end
|
82
|
+
|
83
|
+
files = options[:lib_only] ? gem_spec.lib_files : gem_spec.files
|
84
|
+
|
85
|
+
files.each do |f|
|
86
|
+
path = if options[:prefix] then
|
87
|
+
File.join gem_spec.full_gem_path, f
|
88
|
+
else
|
89
|
+
f
|
90
|
+
end
|
91
|
+
|
92
|
+
say path
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
end
|
98
|
+
|
@@ -0,0 +1,195 @@
|
|
1
|
+
require 'libgems/command'
|
2
|
+
require 'libgems/local_remote_options'
|
3
|
+
require 'libgems/version_option'
|
4
|
+
require 'libgems/source_info_cache'
|
5
|
+
|
6
|
+
class LibGems::Commands::DependencyCommand < LibGems::Command
|
7
|
+
|
8
|
+
include LibGems::LocalRemoteOptions
|
9
|
+
include LibGems::VersionOption
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
super 'dependency',
|
13
|
+
'Show the dependencies of an installed gem',
|
14
|
+
:version => LibGems::Requirement.default, :domain => :local
|
15
|
+
|
16
|
+
add_version_option
|
17
|
+
add_platform_option
|
18
|
+
add_prerelease_option
|
19
|
+
|
20
|
+
add_option('-R', '--[no-]reverse-dependencies',
|
21
|
+
'Include reverse dependencies in the output') do
|
22
|
+
|value, options|
|
23
|
+
options[:reverse_dependencies] = value
|
24
|
+
end
|
25
|
+
|
26
|
+
add_option('-p', '--pipe',
|
27
|
+
"Pipe Format (name --version ver)") do |value, options|
|
28
|
+
options[:pipe_format] = value
|
29
|
+
end
|
30
|
+
|
31
|
+
add_local_remote_options
|
32
|
+
end
|
33
|
+
|
34
|
+
def arguments # :nodoc:
|
35
|
+
"GEMNAME name of gem to show dependencies for"
|
36
|
+
end
|
37
|
+
|
38
|
+
def defaults_str # :nodoc:
|
39
|
+
"--local --version '#{LibGems::Requirement.default}' --no-reverse-dependencies"
|
40
|
+
end
|
41
|
+
|
42
|
+
def usage # :nodoc:
|
43
|
+
"#{program_name} GEMNAME"
|
44
|
+
end
|
45
|
+
|
46
|
+
def execute
|
47
|
+
options[:args] << '' if options[:args].empty?
|
48
|
+
specs = {}
|
49
|
+
|
50
|
+
source_indexes = Hash.new do |h, source_uri|
|
51
|
+
h[source_uri] = LibGems::SourceIndex.new
|
52
|
+
end
|
53
|
+
|
54
|
+
pattern = if options[:args].length == 1 and
|
55
|
+
options[:args].first =~ /\A\/(.*)\/(i)?\z/m then
|
56
|
+
flags = $2 ? Regexp::IGNORECASE : nil
|
57
|
+
Regexp.new $1, flags
|
58
|
+
else
|
59
|
+
/\A#{Regexp.union(*options[:args])}/
|
60
|
+
end
|
61
|
+
|
62
|
+
dependency = LibGems::Dependency.new pattern, options[:version]
|
63
|
+
dependency.prerelease = options[:prerelease]
|
64
|
+
|
65
|
+
if options[:reverse_dependencies] and remote? and not local? then
|
66
|
+
alert_error 'Only reverse dependencies for local gems are supported.'
|
67
|
+
terminate_interaction 1
|
68
|
+
end
|
69
|
+
|
70
|
+
if local? then
|
71
|
+
LibGems.source_index.search(dependency).each do |spec|
|
72
|
+
source_indexes[:local].add_spec spec
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
if remote? and not options[:reverse_dependencies] then
|
77
|
+
fetcher = LibGems::SpecFetcher.fetcher
|
78
|
+
|
79
|
+
begin
|
80
|
+
specs_and_sources = fetcher.find_matching(dependency, false, true,
|
81
|
+
dependency.prerelease?)
|
82
|
+
|
83
|
+
specs_and_sources.each do |spec_tuple, source_uri|
|
84
|
+
spec = fetcher.fetch_spec spec_tuple, URI.parse(source_uri)
|
85
|
+
|
86
|
+
source_indexes[source_uri].add_spec spec
|
87
|
+
end
|
88
|
+
rescue LibGems::RemoteFetcher::FetchError => e
|
89
|
+
raise unless fetcher.warn_legacy e do
|
90
|
+
require 'libgems/source_info_cache'
|
91
|
+
|
92
|
+
specs = LibGems::SourceInfoCache.search_with_source dependency, false
|
93
|
+
|
94
|
+
specs.each do |spec, source_uri|
|
95
|
+
source_indexes[source_uri].add_spec spec
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
if source_indexes.empty? then
|
102
|
+
patterns = options[:args].join ','
|
103
|
+
say "No gems found matching #{patterns} (#{options[:version]})" if
|
104
|
+
LibGems.configuration.verbose
|
105
|
+
|
106
|
+
terminate_interaction 1
|
107
|
+
end
|
108
|
+
|
109
|
+
specs = {}
|
110
|
+
|
111
|
+
source_indexes.values.each do |source_index|
|
112
|
+
source_index.gems.each do |name, spec|
|
113
|
+
specs[spec.full_name] = [source_index, spec]
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
reverse = Hash.new { |h, k| h[k] = [] }
|
118
|
+
|
119
|
+
if options[:reverse_dependencies] then
|
120
|
+
specs.values.each do |_, spec|
|
121
|
+
reverse[spec.full_name] = find_reverse_dependencies spec
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
if options[:pipe_format] then
|
126
|
+
specs.values.sort_by { |_, spec| spec }.each do |_, spec|
|
127
|
+
unless spec.dependencies.empty?
|
128
|
+
spec.dependencies.sort_by { |dep| dep.name }.each do |dep|
|
129
|
+
say "#{dep.name} --version '#{dep.requirement}'"
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
133
|
+
else
|
134
|
+
response = ''
|
135
|
+
|
136
|
+
specs.values.sort_by { |_, spec| spec }.each do |_, spec|
|
137
|
+
response << print_dependencies(spec)
|
138
|
+
unless reverse[spec.full_name].empty? then
|
139
|
+
response << " Used by\n"
|
140
|
+
reverse[spec.full_name].each do |sp, dep|
|
141
|
+
response << " #{sp} (#{dep})\n"
|
142
|
+
end
|
143
|
+
end
|
144
|
+
response << "\n"
|
145
|
+
end
|
146
|
+
|
147
|
+
say response
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
def print_dependencies(spec, level = 0)
|
152
|
+
response = ''
|
153
|
+
response << ' ' * level + "Gem #{spec.full_name}\n"
|
154
|
+
unless spec.dependencies.empty? then
|
155
|
+
spec.dependencies.sort_by { |dep| dep.name }.each do |dep|
|
156
|
+
response << ' ' * level + " #{dep}\n"
|
157
|
+
end
|
158
|
+
end
|
159
|
+
response
|
160
|
+
end
|
161
|
+
|
162
|
+
##
|
163
|
+
# Returns an Array of [specification, dep] that are satisfied by +spec+.
|
164
|
+
|
165
|
+
def find_reverse_dependencies(spec)
|
166
|
+
result = []
|
167
|
+
|
168
|
+
LibGems.source_index.each do |name, sp|
|
169
|
+
sp.dependencies.each do |dep|
|
170
|
+
dep = LibGems::Dependency.new(*dep) unless LibGems::Dependency === dep
|
171
|
+
|
172
|
+
if spec.name == dep.name and
|
173
|
+
dep.requirement.satisfied_by?(spec.version) then
|
174
|
+
result << [sp.full_name, dep]
|
175
|
+
end
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
result
|
180
|
+
end
|
181
|
+
|
182
|
+
def find_gems(name, source_index)
|
183
|
+
specs = {}
|
184
|
+
|
185
|
+
spec_list = source_index.search name, options[:version]
|
186
|
+
|
187
|
+
spec_list.each do |spec|
|
188
|
+
specs[spec.full_name] = [source_index, spec]
|
189
|
+
end
|
190
|
+
|
191
|
+
specs
|
192
|
+
end
|
193
|
+
|
194
|
+
end
|
195
|
+
|
@@ -0,0 +1,133 @@
|
|
1
|
+
require 'libgems/command'
|
2
|
+
|
3
|
+
class LibGems::Commands::EnvironmentCommand < LibGems::Command
|
4
|
+
|
5
|
+
def initialize
|
6
|
+
super 'environment', "Display information about the #{LibGems::NAME} environment"
|
7
|
+
end
|
8
|
+
|
9
|
+
def arguments # :nodoc:
|
10
|
+
args = <<-EOF
|
11
|
+
packageversion display the package version
|
12
|
+
gemdir display the path where gems are installed
|
13
|
+
gempath display path used to search for gems
|
14
|
+
version display the gem format version
|
15
|
+
remotesources display the remote gem servers
|
16
|
+
platform display the supported gem platforms
|
17
|
+
<omitted> display everything
|
18
|
+
EOF
|
19
|
+
return args.gsub(/^\s+/, '')
|
20
|
+
end
|
21
|
+
|
22
|
+
def description # :nodoc:
|
23
|
+
<<-EOF
|
24
|
+
The #{LibGems::NAME} environment can be controlled through command line arguments,
|
25
|
+
gemrc files, environment variables and built-in defaults.
|
26
|
+
|
27
|
+
Command line argument defaults and some #{LibGems::NAME} defaults can be set in
|
28
|
+
~/.gemrc file for individual users and a /etc/gemrc for all users. A gemrc
|
29
|
+
is a YAML file with the following YAML keys:
|
30
|
+
|
31
|
+
:sources: A YAML array of remote gem repositories to install gems from
|
32
|
+
:verbose: Verbosity of the gem command. false, true, and :really are the
|
33
|
+
levels
|
34
|
+
:update_sources: Enable/disable automatic updating of repository metadata
|
35
|
+
:backtrace: Print backtrace when #{LibGems::NAME} encounters an error
|
36
|
+
:bulk_threshold: Switch to a bulk update when this many sources are out of
|
37
|
+
date (legacy setting)
|
38
|
+
:gempath: The paths in which to look for gems
|
39
|
+
gem_command: A string containing arguments for the specified gem command
|
40
|
+
|
41
|
+
Example:
|
42
|
+
|
43
|
+
:verbose: false
|
44
|
+
install: --no-wrappers
|
45
|
+
update: --no-wrappers
|
46
|
+
|
47
|
+
#{LibGems::NAME}' default local repository can be overriden with the GEM_PATH and
|
48
|
+
GEM_HOME environment variables. GEM_HOME sets the default repository to
|
49
|
+
install into. GEM_PATH allows multiple local repositories to be searched for
|
50
|
+
gems.
|
51
|
+
|
52
|
+
If you are behind a proxy server, #{LibGems::NAME} uses the HTTP_PROXY,
|
53
|
+
HTTP_PROXY_USER and HTTP_PROXY_PASS environment variables to discover the
|
54
|
+
proxy server.
|
55
|
+
|
56
|
+
If you are packaging #{LibGems::NAME} all of #{LibGems::NAME}' defaults are in
|
57
|
+
lib/libgems/defaults.rb. You may override these in
|
58
|
+
lib/libgems/defaults/operating_system.rb
|
59
|
+
EOF
|
60
|
+
end
|
61
|
+
|
62
|
+
def usage # :nodoc:
|
63
|
+
"#{program_name} [arg]"
|
64
|
+
end
|
65
|
+
|
66
|
+
def execute
|
67
|
+
out = ''
|
68
|
+
arg = options[:args][0]
|
69
|
+
case arg
|
70
|
+
when /^packageversion/ then
|
71
|
+
out << LibGems::RubyGemsPackageVersion
|
72
|
+
when /^version/ then
|
73
|
+
out << LibGems::VERSION
|
74
|
+
when /^gemdir/, /^gemhome/, /^home/, /^LIBGEMS_HOME/, /^GEM_HOME/ then
|
75
|
+
out << LibGems.dir
|
76
|
+
when /^gempath/, /^path/, /^LIBGEMS_PATH/, /^GEM_PATH/ then
|
77
|
+
out << LibGems.path.join(File::PATH_SEPARATOR)
|
78
|
+
when /^remotesources/ then
|
79
|
+
out << LibGems.sources.join("\n")
|
80
|
+
when /^platform/ then
|
81
|
+
out << LibGems.platforms.join(File::PATH_SEPARATOR)
|
82
|
+
when nil then
|
83
|
+
out = "#{LibGems::NAME} Environment:\n"
|
84
|
+
|
85
|
+
out << " - LibGems VERSION: #{LibGems::VERSION}\n"
|
86
|
+
out << " - RUBYGEMS VERSION: #{LibGems::GEM_VERSION}\n"
|
87
|
+
|
88
|
+
out << " - RUBY VERSION: #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}"
|
89
|
+
out << " patchlevel #{RUBY_PATCHLEVEL}" if defined? RUBY_PATCHLEVEL
|
90
|
+
out << ") [#{RUBY_PLATFORM}]\n"
|
91
|
+
|
92
|
+
out << " - INSTALLATION DIRECTORY: #{LibGems.dir}\n"
|
93
|
+
|
94
|
+
out << " - RUBYGEMS PREFIX: #{LibGems.prefix}\n" unless LibGems.prefix.nil?
|
95
|
+
|
96
|
+
out << " - RUBY EXECUTABLE: #{LibGems.ruby}\n"
|
97
|
+
|
98
|
+
out << " - EXECUTABLE DIRECTORY: #{LibGems.bindir}\n"
|
99
|
+
|
100
|
+
out << " - RUBYGEMS PLATFORMS:\n"
|
101
|
+
LibGems.platforms.each do |platform|
|
102
|
+
out << " - #{platform}\n"
|
103
|
+
end
|
104
|
+
|
105
|
+
out << " - GEM PATHS:\n"
|
106
|
+
out << " - #{LibGems.dir}\n"
|
107
|
+
|
108
|
+
path = LibGems.path.dup
|
109
|
+
path.delete LibGems.dir
|
110
|
+
path.each do |p|
|
111
|
+
out << " - #{p}\n"
|
112
|
+
end
|
113
|
+
|
114
|
+
out << " - GEM CONFIGURATION:\n"
|
115
|
+
LibGems.configuration.each do |name, value|
|
116
|
+
value = value.gsub(/./, '*') if name == 'gemcutter_key'
|
117
|
+
out << " - #{name.inspect} => #{value.inspect}\n"
|
118
|
+
end
|
119
|
+
|
120
|
+
out << " - REMOTE SOURCES:\n"
|
121
|
+
LibGems.sources.each do |s|
|
122
|
+
out << " - #{s}\n"
|
123
|
+
end
|
124
|
+
|
125
|
+
else
|
126
|
+
raise LibGems::CommandLineError, "Unknown enviroment option [#{arg}]"
|
127
|
+
end
|
128
|
+
say out
|
129
|
+
true
|
130
|
+
end
|
131
|
+
|
132
|
+
end
|
133
|
+
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require 'libgems/command'
|
2
|
+
require 'libgems/local_remote_options'
|
3
|
+
require 'libgems/version_option'
|
4
|
+
require 'libgems/source_info_cache'
|
5
|
+
|
6
|
+
class LibGems::Commands::FetchCommand < LibGems::Command
|
7
|
+
|
8
|
+
include LibGems::LocalRemoteOptions
|
9
|
+
include LibGems::VersionOption
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
super 'fetch', 'Download a gem and place it in the current directory'
|
13
|
+
|
14
|
+
add_bulk_threshold_option
|
15
|
+
add_proxy_option
|
16
|
+
add_source_option
|
17
|
+
|
18
|
+
add_version_option
|
19
|
+
add_platform_option
|
20
|
+
add_prerelease_option
|
21
|
+
end
|
22
|
+
|
23
|
+
def arguments # :nodoc:
|
24
|
+
'GEMNAME name of gem to download'
|
25
|
+
end
|
26
|
+
|
27
|
+
def defaults_str # :nodoc:
|
28
|
+
"--version '#{LibGems::Requirement.default}'"
|
29
|
+
end
|
30
|
+
|
31
|
+
def usage # :nodoc:
|
32
|
+
"#{program_name} GEMNAME [GEMNAME ...]"
|
33
|
+
end
|
34
|
+
|
35
|
+
def execute
|
36
|
+
version = options[:version] || LibGems::Requirement.default
|
37
|
+
all = LibGems::Requirement.default != version
|
38
|
+
|
39
|
+
gem_names = get_all_gem_names
|
40
|
+
|
41
|
+
gem_names.each do |gem_name|
|
42
|
+
dep = LibGems::Dependency.new gem_name, version
|
43
|
+
dep.prerelease = options[:prerelease]
|
44
|
+
|
45
|
+
specs_and_sources = LibGems::SpecFetcher.fetcher.fetch(dep, all, true,
|
46
|
+
dep.prerelease?)
|
47
|
+
|
48
|
+
specs_and_sources, errors =
|
49
|
+
LibGems::SpecFetcher.fetcher.fetch_with_errors(dep, all, true,
|
50
|
+
dep.prerelease?)
|
51
|
+
|
52
|
+
spec, source_uri = specs_and_sources.sort_by { |s,| s.version }.last
|
53
|
+
|
54
|
+
if spec.nil? then
|
55
|
+
show_lookup_failure gem_name, version, errors, options[:domain]
|
56
|
+
next
|
57
|
+
end
|
58
|
+
|
59
|
+
path = LibGems::RemoteFetcher.fetcher.download spec, source_uri
|
60
|
+
FileUtils.mv path, spec.file_name
|
61
|
+
|
62
|
+
say "Downloaded #{spec.full_name}"
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
|