Class: Gem::Commands::MiniMirrorCommand
- Inherits:
-
Gem::Command
- Object
- Gem::Command
- Gem::Commands::MiniMirrorCommand
- Defined in:
- lib/rubygems/mini_mirror/command.rb
Constant Summary collapse
- SUPPORTS_INFO_SIGNAL =
Signal.list['INFO']
Instance Method Summary collapse
-
#description ⇒ Object
:nodoc:.
- #execute ⇒ Object
-
#initialize ⇒ MiniMirrorCommand
constructor
A new instance of MiniMirrorCommand.
Constructor Details
#initialize ⇒ MiniMirrorCommand
Returns a new instance of MiniMirrorCommand.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/rubygems/mini_mirror/command.rb', line 8 def initialize super 'mirror', 'Mirror a gem repository' add_option '-c', '--config-file=FILE', 'the main config file' do |file, | [:path] = file end add_option '-t', '--file-type=FILETYPE', 'file type of config file if not guessed' do |t, | [:type] = t end add_option '-d', '--cd=DIR', 'directory to cd into before running the command' do |dir,| [:cd] = dir end add_option '-r', '--require=lib1,lib2', Array, 'A list of libs to require before running the command' do |libs, | [:libs] ||= [] [:libs].push(*libs) end add_option '-m', '--mirror-dir=MIRROR_DIR', 'The mirror root directory : whre to download gem files. Default to <Gem.user_home>/mirror' do |dir,| [:gems_dir] = dir end add_option '-p', '--pool-size=POOLSIZE', Integer, 'The number of threads in the pool : fro fetching concurrency. Default 10' do |pool, | [:pool_size] = pool end end |
Instance Method Details
#description ⇒ Object
:nodoc:
31 32 33 34 35 36 37 38 39 |
# File 'lib/rubygems/mini_mirror/command.rb', line 31 def description # :nodoc: <<-EOF The mini_mirror command mirrors remote gem repositories to a local path. Not all the repository of rubygem is mirrored but only those you have chosen with their dependencies See https://github.com/hallelujah/rubygems-mini_mirror EOF end |
#execute ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/rubygems/mini_mirror/command.rb', line 41 def execute Dir.chdir(.delete(:cd) || '.') do if [:requires] [:requires].each do |lib| require lib end end mirror = Gem::MiniMirror::Runner.new() mirror.load_resource! say "Total gems: #{mirror.gems.size}" num_to_fetch = mirror.gems_to_fetch.size progress = ui.progress_reporter num_to_fetch, "Fetching #{num_to_fetch} gems" trap(:INFO) { puts "Fetched: #{progress.count}/#{num_to_fetch}" } if SUPPORTS_INFO_SIGNAL mirror.update_gems { progress.updated true } num_to_delete = mirror.gems_to_delete.size progress = ui.progress_reporter num_to_delete, "Deleting #{num_to_delete} gems" trap(:INFO) { puts "Fetched: #{progress.count}/#{num_to_delete}" } if SUPPORTS_INFO_SIGNAL mirror.delete_gems { progress.updated true } end end |