rubygems-update 0.9.4 → 0.9.5
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of rubygems-update might be problematic. Click here for more details.
- data/ChangeLog +587 -0
- data/README +0 -1
- data/Rakefile +39 -12
- data/TODO +0 -5
- data/bin/gem +7 -7
- data/bin/update_rubygems +1 -1
- data/examples/application/an-app.gemspec +1 -1
- data/gemspecs/cgikit-1.1.0.gemspec +1 -2
- data/gemspecs/jabber4r.gemspec +1 -1
- data/gemspecs/linguistics.gemspec +1 -1
- data/gemspecs/ook.gemspec +1 -1
- data/gemspecs/progressbar.gemspec +1 -1
- data/gemspecs/redcloth.gemspec +1 -1
- data/gemspecs/rublog.gemspec +1 -1
- data/gemspecs/ruby-doom.gemspec +1 -1
- data/gemspecs/rubyjdwp.gemspec +1 -1
- data/gemspecs/statistics.gemspec +1 -1
- data/lib/rubygems.rb +167 -105
- data/lib/rubygems/builder.rb +12 -10
- data/lib/rubygems/command.rb +177 -60
- data/lib/rubygems/command_manager.rb +30 -38
- data/lib/rubygems/commands/build_command.rb +42 -46
- data/lib/rubygems/commands/cert_command.rb +72 -69
- data/lib/rubygems/commands/check_command.rb +63 -63
- data/lib/rubygems/commands/cleanup_command.rb +25 -7
- data/lib/rubygems/commands/contents_command.rb +70 -62
- data/lib/rubygems/commands/dependency_command.rb +131 -86
- data/lib/rubygems/commands/environment_command.rb +67 -46
- data/lib/rubygems/commands/fetch_command.rb +62 -0
- data/lib/rubygems/commands/generate_index_command.rb +57 -0
- data/lib/rubygems/commands/help_command.rb +163 -73
- data/lib/rubygems/commands/install_command.rb +114 -128
- data/lib/rubygems/commands/list_command.rb +10 -8
- data/lib/rubygems/commands/lock_command.rb +101 -0
- data/lib/rubygems/commands/mirror_command.rb +105 -0
- data/lib/rubygems/commands/outdated_command.rb +24 -15
- data/lib/rubygems/commands/pristine_command.rb +118 -88
- data/lib/rubygems/commands/query_command.rb +109 -77
- data/lib/rubygems/commands/rdoc_command.rb +13 -10
- data/lib/rubygems/commands/search_command.rb +10 -8
- data/lib/rubygems/commands/server_command.rb +48 -0
- data/lib/rubygems/commands/sources_command.rb +104 -83
- data/lib/rubygems/commands/specification_command.rb +65 -51
- data/lib/rubygems/commands/uninstall_command.rb +17 -12
- data/lib/rubygems/commands/unpack_command.rb +68 -68
- data/lib/rubygems/commands/update_command.rb +72 -25
- data/lib/rubygems/commands/which_command.rb +86 -0
- data/lib/rubygems/config_file.rb +202 -78
- data/lib/rubygems/custom_require.rb +7 -88
- data/lib/rubygems/dependency.rb +65 -0
- data/lib/rubygems/dependency_installer.rb +232 -0
- data/lib/rubygems/dependency_list.rb +133 -105
- data/lib/rubygems/digest/md5.rb +4 -1
- data/lib/rubygems/digest/sha2.rb +1 -1
- data/lib/rubygems/doc_manager.rb +41 -19
- data/lib/rubygems/exceptions.rb +63 -0
- data/lib/rubygems/ext.rb +18 -0
- data/lib/rubygems/ext/builder.rb +56 -0
- data/lib/rubygems/ext/configure_builder.rb +24 -0
- data/lib/rubygems/ext/ext_conf_builder.rb +23 -0
- data/lib/rubygems/ext/rake_builder.rb +27 -0
- data/lib/rubygems/format.rb +16 -6
- data/lib/rubygems/gem_openssl.rb +43 -6
- data/lib/rubygems/gem_path_searcher.rb +84 -0
- data/lib/rubygems/gem_runner.rb +20 -5
- data/lib/rubygems/indexer.rb +163 -0
- data/lib/rubygems/indexer/abstract_index_builder.rb +80 -0
- data/lib/rubygems/indexer/marshal_index_builder.rb +17 -0
- data/lib/rubygems/indexer/master_index_builder.rb +53 -0
- data/lib/rubygems/indexer/quick_index_builder.rb +48 -0
- data/lib/rubygems/install_update_options.rb +87 -0
- data/lib/rubygems/installer.rb +316 -562
- data/lib/rubygems/local_remote_options.rb +106 -0
- data/lib/rubygems/old_format.rb +5 -13
- data/lib/rubygems/open-uri.rb +2 -0
- data/lib/rubygems/package.rb +28 -32
- data/lib/rubygems/platform.rb +187 -0
- data/lib/rubygems/remote_fetcher.rb +46 -29
- data/lib/rubygems/remote_installer.rb +11 -18
- data/lib/rubygems/requirement.rb +157 -0
- data/lib/rubygems/rubygems_version.rb +1 -1
- data/lib/rubygems/security.rb +715 -457
- data/lib/rubygems/server.rb +77 -59
- data/lib/rubygems/source_index.rb +154 -83
- data/lib/rubygems/source_info_cache.rb +73 -30
- data/lib/rubygems/source_info_cache_entry.rb +12 -3
- data/lib/rubygems/specification.rb +378 -145
- data/lib/rubygems/uninstaller.rb +183 -0
- data/lib/rubygems/user_interaction.rb +38 -9
- data/lib/rubygems/validator.rb +53 -24
- data/lib/rubygems/version.rb +126 -289
- data/lib/rubygems/version_option.rb +49 -0
- data/pkgs/sources/lib/sources.rb +1 -4
- data/pkgs/sources/sources.gemspec +3 -3
- data/scripts/gemdoc.rb +0 -1
- data/setup.rb +166 -1505
- data/test/bogussources.rb +0 -1
- data/test/data/gem-private_key.pem +27 -0
- data/test/data/gem-public_cert.pem +20 -0
- data/test/functional.rb +3 -105
- data/test/gemutilities.rb +145 -24
- data/test/insure_session.rb +0 -1
- data/test/{test_datadir.rb → test_config.rb} +7 -13
- data/test/test_gem.rb +360 -9
- data/test/test_gem_builder.rb +34 -0
- data/test/{test_command.rb → test_gem_command.rb} +119 -62
- data/test/{test_parse_commands.rb → test_gem_command_manager.rb} +64 -40
- data/test/test_gem_commands_build_command.rb +75 -0
- data/test/test_gem_commands_cert_command.rb +122 -0
- data/test/test_gem_commands_check_command.rb +25 -0
- data/test/test_gem_commands_contents_command.rb +92 -0
- data/test/test_gem_commands_dependency_command.rb +108 -0
- data/test/test_gem_commands_environment_command.rb +117 -0
- data/test/test_gem_commands_fetch_command.rb +34 -0
- data/test/test_gem_commands_generate_index_command.rb +32 -0
- data/test/test_gem_commands_install_command.rb +160 -0
- data/test/test_gem_commands_mirror_command.rb +56 -0
- data/test/test_gem_commands_pristine_command.rb +100 -0
- data/test/test_gem_commands_query_command.rb +82 -0
- data/test/test_gem_commands_sources_command.rb +147 -0
- data/test/test_gem_commands_specification_command.rb +93 -0
- data/test/test_gem_commands_unpack_command.rb +55 -0
- data/test/test_gem_config_file.rb +210 -0
- data/test/test_gem_dependency.rb +89 -0
- data/test/test_gem_dependency_installer.rb +542 -0
- data/test/test_gem_dependency_list.rb +212 -0
- data/test/test_gem_doc_manager.rb +32 -0
- data/test/test_gem_ext_configure_builder.rb +13 -17
- data/test/test_gem_ext_ext_conf_builder.rb +9 -9
- data/test/test_gem_ext_rake_builder.rb +23 -11
- data/test/test_gem_format.rb +69 -0
- data/test/test_gem_gem_path_searcher.rb +57 -0
- data/test/test_gem_gem_runner.rb +35 -0
- data/test/test_gem_indexer.rb +119 -0
- data/test/test_gem_install_update_options.rb +40 -0
- data/test/test_gem_installer.rb +796 -0
- data/test/test_gem_local_remote_options.rb +84 -0
- data/test/test_gem_outdated_command.rb +11 -9
- data/test/test_gem_platform.rb +240 -0
- data/test/{test_remote_fetcher.rb → test_gem_remote_fetcher.rb} +124 -55
- data/test/{test_remote_installer.rb → test_gem_remote_installer.rb} +3 -4
- data/test/test_gem_requirement.rb +223 -0
- data/test/test_gem_server.rb +71 -0
- data/test/test_gem_source_index.rb +429 -0
- data/test/test_gem_source_info_cache.rb +79 -17
- data/test/test_gem_source_info_cache_entry.rb +11 -9
- data/test/test_gem_specification.rb +738 -0
- data/test/test_gem_stream_ui.rb +117 -0
- data/test/test_gem_validator.rb +70 -0
- data/test/test_gem_version.rb +191 -0
- data/test/test_gem_version_option.rb +77 -0
- data/test/{test_require_gem.rb → test_kernel.rb} +19 -12
- data/test/test_open_uri.rb +1 -2
- data/test/test_package.rb +45 -34
- metadata +116 -141
- data/Releases +0 -127
- data/bin/gem_mirror +0 -73
- data/bin/gem_server +0 -6
- data/bin/gemlock +0 -127
- data/bin/gemri +0 -24
- data/bin/gemwhich +0 -89
- data/bin/index_gem_repository.rb +0 -302
- data/lib/gemconfigure.rb +0 -24
- data/lib/rubygems/gem_commands.rb +0 -273
- data/pkgs/sources/sources-0.0.1.gem +0 -0
- data/post-install.rb +0 -121
- data/test/brokenbuildgem.rb +0 -35
- data/test/data/PostMessage-0.0.1.gem +0 -0
- data/test/data/a-0.0.1.gem +0 -0
- data/test/data/a-0.0.2.gem +0 -0
- data/test/data/b-0.0.2.gem +0 -0
- data/test/data/broken-1.0.0.gem +0 -0
- data/test/data/broken_build/broken-build.gemspec +0 -20
- data/test/data/broken_build/ext/extconf.rb +0 -3
- data/test/data/broken_build/ext/foo.c +0 -1
- data/test/data/c-1.2.gem +0 -0
- data/test/data/gemhome/cache/a-0.0.1.gem +0 -0
- data/test/data/gemhome/cache/a-0.0.2.gem +0 -0
- data/test/data/gemhome/cache/b-0.0.2.gem +0 -0
- data/test/data/gemhome/cache/c-1.2.gem +0 -0
- data/test/data/gemhome/gems/a-0.0.1/lib/code.rb +0 -1
- data/test/data/gemhome/gems/a-0.0.2/lib/code.rb +0 -1
- data/test/data/gemhome/gems/b-0.0.2/lib/code.rb +0 -1
- data/test/data/gemhome/gems/c-1.2/lib/code.rb +0 -1
- data/test/data/gemhome/specifications/a-0.0.1.gemspec +0 -8
- data/test/data/gemhome/specifications/a-0.0.2.gemspec +0 -8
- data/test/data/gemhome/specifications/b-0.0.2.gemspec +0 -8
- data/test/data/gemhome/specifications/c-1.2.gemspec +0 -8
- data/test/data/legacy/keyedlist-0.4.0.ruby +0 -11
- data/test/data/legacy/keyedlist-0.4.0.yaml +0 -16
- data/test/data/lib/code.rb +0 -1
- data/test/data/one/README.one +0 -1
- data/test/data/one/lib/one.rb +0 -9
- data/test/data/one/one-0.0.1.gem +0 -0
- data/test/data/one/one.gemspec +0 -17
- data/test/data/one/one.yaml +0 -40
- data/test/data/post_install.gemspec +0 -19
- data/test/functional_extension_gems.rb +0 -48
- data/test/functional_generate_yaml_index.rb +0 -104
- data/test/gemenvironment.rb +0 -59
- data/test/io_capture.rb +0 -33
- data/test/mock/gems/gems/sources-0.0.1/lib/sources.rb +0 -11
- data/test/mock/gems/specifications/sources-0.0.1.gemspec +0 -8
- data/test/onegem.rb +0 -35
- data/test/test_builder.rb +0 -34
- data/test/test_check_command.rb +0 -34
- data/test/test_configfile.rb +0 -42
- data/test/test_dependency_list.rb +0 -169
- data/test/test_file_list.rb +0 -101
- data/test/test_format.rb +0 -49
- data/test/test_gem_sources_command.rb +0 -135
- data/test/test_gemloadpaths.rb +0 -51
- data/test/test_gempaths.rb +0 -170
- data/test/test_installer.rb +0 -369
- data/test/test_loadmanager.rb +0 -48
- data/test/test_process_commands.rb +0 -52
- data/test/test_source_index.rb +0 -231
- data/test/test_specific_extras.rb +0 -46
- data/test/test_specification.rb +0 -565
- data/test/test_user_interaction.rb +0 -48
- data/test/test_validator.rb +0 -59
- data/test/test_version_comparison.rb +0 -321
- data/test/testgem.rc +0 -7
- data/test/user_capture.rb +0 -7
- data/test/yaml_data.rb +0 -63
@@ -1,7 +1,9 @@
|
|
1
|
+
require 'rubygems/command'
|
2
|
+
require 'rubygems/commands/query_command'
|
3
|
+
|
1
4
|
module Gem
|
2
5
|
module Commands
|
3
6
|
class ListCommand < QueryCommand
|
4
|
-
include CommandAids
|
5
7
|
|
6
8
|
def initialize
|
7
9
|
super(
|
@@ -11,16 +13,16 @@ module Gem
|
|
11
13
|
remove_option('--name-matches')
|
12
14
|
end
|
13
15
|
|
14
|
-
def
|
15
|
-
"
|
16
|
+
def arguments # :nodoc:
|
17
|
+
"STRING start of gem name to look for"
|
16
18
|
end
|
17
19
|
|
18
|
-
def
|
19
|
-
"
|
20
|
+
def defaults_str # :nodoc:
|
21
|
+
"--local --no-details"
|
20
22
|
end
|
21
23
|
|
22
|
-
def
|
23
|
-
"STRING
|
24
|
+
def usage # :nodoc:
|
25
|
+
"#{program_name} [STRING]"
|
24
26
|
end
|
25
27
|
|
26
28
|
def execute
|
@@ -30,4 +32,4 @@ module Gem
|
|
30
32
|
end
|
31
33
|
end
|
32
34
|
end
|
33
|
-
end
|
35
|
+
end
|
@@ -0,0 +1,101 @@
|
|
1
|
+
require 'rubygems/command'
|
2
|
+
|
3
|
+
class Gem::Commands::LockCommand < Gem::Command
|
4
|
+
|
5
|
+
def initialize
|
6
|
+
super 'lock', 'Generate a lockdown list of gems',
|
7
|
+
:strict => false
|
8
|
+
|
9
|
+
add_option '-s', '--[no-]strict',
|
10
|
+
'fail if unable to satisfy a dependency' do |strict, options|
|
11
|
+
options[:strict] = strict
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def arguments # :nodoc:
|
16
|
+
"GEMNAME name of gem to lock\nVERSION version of gem to lock"
|
17
|
+
end
|
18
|
+
|
19
|
+
def defaults_str # :nodoc:
|
20
|
+
"--no-strict"
|
21
|
+
end
|
22
|
+
|
23
|
+
def description # :nodoc:
|
24
|
+
<<-EOF
|
25
|
+
The lock command will generate a list of +gem+ statements that will lock down
|
26
|
+
the versions for the gem given in the command line. It will specify exact
|
27
|
+
versions in the requirements list to ensure that the gems loaded will always
|
28
|
+
be consistent. A full recursive search of all effected gems will be
|
29
|
+
generated.
|
30
|
+
|
31
|
+
Example:
|
32
|
+
|
33
|
+
gemlock rails-1.0.0 > lockdown.rb
|
34
|
+
|
35
|
+
will produce in lockdown.rb:
|
36
|
+
|
37
|
+
require "rubygems"
|
38
|
+
gem 'rails', '= 1.0.0'
|
39
|
+
gem 'rake', '= 0.7.0.1'
|
40
|
+
gem 'activesupport', '= 1.2.5'
|
41
|
+
gem 'activerecord', '= 1.13.2'
|
42
|
+
gem 'actionpack', '= 1.11.2'
|
43
|
+
gem 'actionmailer', '= 1.1.5'
|
44
|
+
gem 'actionwebservice', '= 1.0.0'
|
45
|
+
|
46
|
+
Just load lockdown.rb from your application to ensure that the current
|
47
|
+
versions are loaded. Make sure that lockdown.rb is loaded *before* any
|
48
|
+
other require statements.
|
49
|
+
|
50
|
+
Notice that rails 1.0.0 only requires that rake 0.6.2 or better be used.
|
51
|
+
Rake-0.7.0.1 is the most recent version installed that satisfies that, so we
|
52
|
+
lock it down to the exact version.
|
53
|
+
EOF
|
54
|
+
end
|
55
|
+
|
56
|
+
def usage # :nodoc:
|
57
|
+
"#{program_name} GEMNAME-VERSION [GEMNAME-VERSION ...]"
|
58
|
+
end
|
59
|
+
|
60
|
+
def complain(message)
|
61
|
+
if options.strict then
|
62
|
+
raise message
|
63
|
+
else
|
64
|
+
say "# #{message}"
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def execute
|
69
|
+
say 'require "rubygems"'
|
70
|
+
|
71
|
+
locked = {}
|
72
|
+
|
73
|
+
pending = options[:args]
|
74
|
+
|
75
|
+
until pending.empty? do
|
76
|
+
full_name = pending.shift
|
77
|
+
|
78
|
+
spec = Gem::SourceIndex.load_specification spec_path(full_name)
|
79
|
+
|
80
|
+
say "gem '#{spec.name}', '= #{spec.version}'" unless locked[spec.name]
|
81
|
+
locked[spec.name] = true
|
82
|
+
|
83
|
+
spec.dependencies.each do |dep|
|
84
|
+
next if locked[dep.name]
|
85
|
+
candidates = Gem.source_index.search dep.name, dep.requirement_list
|
86
|
+
|
87
|
+
if candidates.empty? then
|
88
|
+
complain "Unable to satisfy '#{dep}' from currently installed gems."
|
89
|
+
else
|
90
|
+
pending << candidates.last.full_name
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
def spec_path(gem_full_name)
|
97
|
+
File.join Gem.path, "specifications", "#{gem_full_name }.gemspec"
|
98
|
+
end
|
99
|
+
|
100
|
+
end
|
101
|
+
|
@@ -0,0 +1,105 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
require 'zlib'
|
3
|
+
|
4
|
+
require 'rubygems/command'
|
5
|
+
require 'rubygems/gem_open_uri'
|
6
|
+
|
7
|
+
class Gem::Commands::MirrorCommand < Gem::Command
|
8
|
+
|
9
|
+
def initialize
|
10
|
+
super 'mirror', 'Mirror a gem repository'
|
11
|
+
end
|
12
|
+
|
13
|
+
def description # :nodoc:
|
14
|
+
<<-EOF
|
15
|
+
The mirror command uses the ~/.gemmirrorrc config file to mirror remote gem
|
16
|
+
repositories to a local path. The config file is a YAML document that looks
|
17
|
+
like this:
|
18
|
+
|
19
|
+
---
|
20
|
+
- from: http://gems.example.com # source repository URI
|
21
|
+
to: /path/to/mirror # destination directory
|
22
|
+
|
23
|
+
Multiple sources and destinations may be specified.
|
24
|
+
EOF
|
25
|
+
end
|
26
|
+
|
27
|
+
def execute
|
28
|
+
config_file = File.join Gem.user_home, '.gemmirrorrc'
|
29
|
+
|
30
|
+
raise "Config file #{config_file} not found" unless File.exist? config_file
|
31
|
+
|
32
|
+
mirrors = YAML.load_file config_file
|
33
|
+
|
34
|
+
raise "Invalid config file #{config_file}" unless mirrors.respond_to? :each
|
35
|
+
|
36
|
+
mirrors.each do |mir|
|
37
|
+
raise "mirror missing 'from' field" unless mir.has_key? 'from'
|
38
|
+
raise "mirror missing 'to' field" unless mir.has_key? 'to'
|
39
|
+
|
40
|
+
get_from = mir['from']
|
41
|
+
save_to = File.expand_path mir['to']
|
42
|
+
|
43
|
+
raise "Directory not found: #{save_to}" unless File.exist? save_to
|
44
|
+
raise "Not a directory: #{save_to}" unless File.directory? save_to
|
45
|
+
|
46
|
+
gems_dir = File.join save_to, "gems"
|
47
|
+
|
48
|
+
if File.exist? gems_dir then
|
49
|
+
raise "Not a directory: #{gems_dir}" unless File.directory? gems_dir
|
50
|
+
else
|
51
|
+
Dir.mkdir gems_dir
|
52
|
+
end
|
53
|
+
|
54
|
+
sourceindex_data = ''
|
55
|
+
|
56
|
+
say "fetching: #{get_from}/Marshal.#{Gem.marshal_version}.Z"
|
57
|
+
|
58
|
+
get_from = URI.parse get_from
|
59
|
+
|
60
|
+
if get_from.scheme.nil? then
|
61
|
+
get_from = get_from.to_s
|
62
|
+
elsif get_from.scheme == 'file' then
|
63
|
+
get_from = get_from.to_s[5..-1]
|
64
|
+
end
|
65
|
+
|
66
|
+
open File.join(get_from, "Marshal.#{Gem.marshal_version}.Z"), "rb" do |y|
|
67
|
+
sourceindex_data = Zlib::Inflate.inflate y.read
|
68
|
+
open File.join(save_to, "Marshal.#{Gem.marshal_version}"), "wb" do |out|
|
69
|
+
out.write sourceindex_data
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
sourceindex = Marshal.load(sourceindex_data)
|
74
|
+
|
75
|
+
progress = ui.progress_reporter sourceindex.size,
|
76
|
+
"Fetching #{sourceindex.size} gems"
|
77
|
+
sourceindex.each do |fullname, gem|
|
78
|
+
gem_file = "#{fullname}.gem"
|
79
|
+
gem_dest = File.join gems_dir, gem_file
|
80
|
+
|
81
|
+
unless File.exist? gem_dest then
|
82
|
+
begin
|
83
|
+
open "#{get_from}/gems/#{gem_file}", "rb" do |g|
|
84
|
+
contents = g.read
|
85
|
+
open gem_dest, "wb" do |out|
|
86
|
+
out.write contents
|
87
|
+
end
|
88
|
+
end
|
89
|
+
rescue
|
90
|
+
old_gf = gem_file
|
91
|
+
gem_file = gem_file.downcase
|
92
|
+
retry if old_gf != gem_file
|
93
|
+
alert_error $!
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
progress.updated gem_file
|
98
|
+
end
|
99
|
+
|
100
|
+
progress.done
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
end
|
105
|
+
|
@@ -1,21 +1,30 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
require 'rubygems/command'
|
2
|
+
require 'rubygems/local_remote_options'
|
3
|
+
require 'rubygems/source_info_cache'
|
4
|
+
require 'rubygems/version_option'
|
3
5
|
|
4
|
-
|
6
|
+
class Gem::Commands::OutdatedCommand < Gem::Command
|
5
7
|
|
6
|
-
|
7
|
-
|
8
|
-
end
|
8
|
+
include Gem::LocalRemoteOptions
|
9
|
+
include Gem::VersionOption
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
locals.outdated.each do |name|
|
13
|
-
local = locals.search(/^#{name}$/).last
|
14
|
-
remote = Gem::SourceInfoCache.search(/^#{name}$/).last
|
15
|
-
say "#{local.name} (#{local.version} < #{remote.version})"
|
16
|
-
end
|
17
|
-
end
|
11
|
+
def initialize
|
12
|
+
super 'outdated', 'Display all gems that need updates'
|
18
13
|
|
14
|
+
add_local_remote_options
|
15
|
+
add_platform_option
|
16
|
+
end
|
17
|
+
|
18
|
+
def execute
|
19
|
+
locals = Gem::SourceIndex.from_installed_gems
|
20
|
+
|
21
|
+
locals.outdated.sort.each do |name|
|
22
|
+
local = locals.search(/^#{name}$/).last
|
23
|
+
remotes = Gem::SourceInfoCache.search_with_source(/^#{name}$/, true)
|
24
|
+
remote = remotes.last.first
|
25
|
+
say "#{local.name} (#{local.version} < #{remote.version})"
|
19
26
|
end
|
20
27
|
end
|
21
|
-
|
28
|
+
|
29
|
+
end
|
30
|
+
|
@@ -1,103 +1,133 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
def initialize
|
7
|
-
super('pristine',
|
8
|
-
'Restores gem directories to pristine condition from files located in the gem cache',
|
9
|
-
{
|
10
|
-
:version => "> 0.0.0"
|
11
|
-
})
|
12
|
-
add_option('--all',
|
13
|
-
'Restore all installed gems to pristine', 'condition'
|
14
|
-
) do |value, options|
|
15
|
-
options[:all] = value
|
16
|
-
end
|
17
|
-
add_version_option('restore to', 'pristine condition')
|
18
|
-
end
|
1
|
+
require 'fileutils'
|
2
|
+
require 'rubygems/command'
|
3
|
+
require 'rubygems/format'
|
4
|
+
require 'rubygems/installer'
|
5
|
+
require 'rubygems/version_option'
|
19
6
|
|
20
|
-
|
21
|
-
"--all"
|
22
|
-
end
|
7
|
+
class Gem::Commands::PristineCommand < Gem::Command
|
23
8
|
|
24
|
-
|
25
|
-
"#{program_name} [args]"
|
26
|
-
end
|
9
|
+
include Gem::VersionOption
|
27
10
|
|
28
|
-
|
29
|
-
|
30
|
-
|
11
|
+
def initialize
|
12
|
+
super 'pristine',
|
13
|
+
'Restores installed gems to pristine condition from files located in the gem cache',
|
14
|
+
:version => Gem::Requirement.default
|
31
15
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
spec
|
38
|
-
end
|
39
|
-
else
|
40
|
-
all_gems = false
|
41
|
-
gem_name = get_one_gem_name
|
42
|
-
specs = Gem::SourceIndex.from_installed_gems.search(gem_name, options[:version])
|
43
|
-
end
|
16
|
+
add_option('--all',
|
17
|
+
'Restore all installed gems to pristine',
|
18
|
+
'condition') do |value, options|
|
19
|
+
options[:all] = value
|
20
|
+
end
|
44
21
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
22
|
+
add_version_option('restore to', 'pristine condition')
|
23
|
+
end
|
24
|
+
|
25
|
+
def arguments # :nodoc:
|
26
|
+
"GEMNAME gem to restore to pristine condition (unless --all)"
|
27
|
+
end
|
28
|
+
|
29
|
+
def defaults_str # :nodoc:
|
30
|
+
"--all"
|
31
|
+
end
|
32
|
+
|
33
|
+
def description # :nodoc:
|
34
|
+
<<-EOF
|
35
|
+
The pristine command compares the installed gems with the contents of the
|
36
|
+
cached gem and restores any files that don't match the cached gem's copy.
|
37
|
+
|
38
|
+
If you have made modifications to your installed gems, the pristine command
|
39
|
+
will revert them. After all the gem's files have been checked all bin stubs
|
40
|
+
for the gem are regenerated.
|
41
|
+
|
42
|
+
If the cached gem cannot be found, you will need to use `gem install` to
|
43
|
+
revert the gem.
|
44
|
+
EOF
|
45
|
+
end
|
46
|
+
|
47
|
+
def usage # :nodoc:
|
48
|
+
"#{program_name} [args]"
|
49
|
+
end
|
50
|
+
|
51
|
+
def execute
|
52
|
+
gem_name = nil
|
53
|
+
|
54
|
+
specs = if options[:all] then
|
55
|
+
Gem::SourceIndex.from_installed_gems.map do |name, spec|
|
56
|
+
spec
|
78
57
|
end
|
58
|
+
else
|
59
|
+
gem_name = get_one_gem_name
|
60
|
+
Gem::SourceIndex.from_installed_gems.search(gem_name,
|
61
|
+
options[:version])
|
79
62
|
end
|
80
|
-
end
|
81
63
|
|
82
|
-
|
83
|
-
|
64
|
+
if specs.empty? then
|
65
|
+
raise Gem::Exception,
|
66
|
+
"Failed to find gem #{gem_name} #{options[:version]}"
|
67
|
+
end
|
68
|
+
|
69
|
+
install_dir = Gem.dir # TODO use installer option
|
70
|
+
|
71
|
+
raise Gem::FilePermissionError.new(install_dir) unless
|
72
|
+
File.writable?(install_dir)
|
73
|
+
|
74
|
+
say "Restoring gem(s) to pristine condition..."
|
75
|
+
|
76
|
+
specs.each do |spec|
|
77
|
+
gem = Dir[File.join(Gem.dir, 'cache', "#{spec.full_name}.gem")].first
|
78
|
+
|
79
|
+
if gem.nil? then
|
80
|
+
alert_error "Cached gem for #{spec.full_name} not found, use `gem install` to restore"
|
81
|
+
next
|
82
|
+
end
|
83
|
+
|
84
|
+
# TODO use installer options
|
85
|
+
installer = Gem::Installer.new gem, :wrappers => true
|
86
|
+
|
87
|
+
gem_file = File.join install_dir, "cache", "#{spec.full_name}.gem"
|
88
|
+
|
89
|
+
security_policy = nil # TODO use installer option
|
90
|
+
|
91
|
+
format = Gem::Format.from_file_by_path gem_file, security_policy
|
92
|
+
|
93
|
+
target_directory = File.join(install_dir, "gems", format.spec.full_name)
|
94
|
+
target_directory.untaint
|
84
95
|
|
85
|
-
|
96
|
+
pristine_files = format.file_entries.collect { |data| data[0]["path"] }
|
97
|
+
file_map = {}
|
86
98
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
99
|
+
format.file_entries.each do |entry, file_data|
|
100
|
+
file_map[entry["path"]] = file_data
|
101
|
+
end
|
102
|
+
|
103
|
+
Dir.chdir target_directory do
|
104
|
+
deployed_files = Dir.glob(File.join("**", "*")) +
|
105
|
+
Dir.glob(File.join("**", ".*"))
|
106
|
+
|
107
|
+
pristine_files = pristine_files.map { |f| File.expand_path f }
|
108
|
+
deployed_files = deployed_files.map { |f| File.expand_path f }
|
109
|
+
|
110
|
+
to_redeploy = (pristine_files - deployed_files)
|
111
|
+
to_redeploy = to_redeploy.map { |path| path.untaint}
|
112
|
+
|
113
|
+
if to_redeploy.length > 0 then
|
114
|
+
say "Restoring #{to_redeploy.length} file#{to_redeploy.length == 1 ? "" : "s"} to #{spec.full_name}..."
|
115
|
+
|
116
|
+
to_redeploy.each do |path|
|
117
|
+
say " #{path}"
|
118
|
+
FileUtils.mkdir_p File.dirname(path)
|
119
|
+
File.open(path, "wb") do |out|
|
120
|
+
out.write file_map[path]
|
121
|
+
end
|
92
122
|
end
|
93
123
|
else
|
94
|
-
|
95
|
-
say "All installed gem files restored to pristine condition"
|
96
|
-
else
|
97
|
-
say "#{specs[0].full_name} restored to pristine condition"
|
98
|
-
end
|
124
|
+
say "#{spec.full_name} is in pristine condition"
|
99
125
|
end
|
100
126
|
end
|
101
|
-
|
127
|
+
|
128
|
+
installer.generate_bin
|
129
|
+
end
|
102
130
|
end
|
103
|
-
|
131
|
+
|
132
|
+
end
|
133
|
+
|