Class: OffGithub::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/off_github.rb

Class Method Summary collapse

Class Method Details

.run(options = {}) ⇒ Object



164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
# File 'lib/off_github.rb', line 164

def self.run(options = {})
  @use_sudo = !options[:"no-sudo"]
  @wet = !options[:dry]
  
  unless Gem.sources.find{|g| g =~ /gemcutter/}
    puts "Looks like you don't have gemcutter installed as a source. Follow instructions at #{GEMCUTTER_URL} before running this tool.\n\n"
    return
  end
  
  investigator = GemInvestigator.new
  puts investigator
  print "Everything looks good? Want to migrate gems? (It'll take a bit to perform all the actions.) (Y/n) "
  reply = STDIN.gets.strip
  if reply == "Y"
    puts "Okeydoke.\n\n"
    
    dont_ask = nil
    investigator.will_be_migrated.each do |args|
      github_gem, gemcutter_gem, action = args
      next if action == "skip"
      
      if action == "reinstall"
        print "Reinstall#{dont_ask && 'ing'} #{github_gem} to #{gemcutter_gem}#{dont_ask ? '...' : '? (y/n/a) '}"
        proceed = dont_ask ? "y" : STDIN.gets.strip
      
        if proceed =~ /^[ya]$/
          cmd "gem uninstall -axq --user-install #{github_gem}"
          cmd "gem install #{gemcutter_gem} -s #{GEMCUTTER_URL}"
          puts "\n"
        end
      else
        print "Uninstall#{dont_ask && 'ing'} #{github_gem}#{dont_ask ? '...' : '? (y/n/a) '}"
        proceed = dont_ask ? "y" : STDIN.gets.strip
        
        if proceed =~ /^[ya]$/
          cmd "gem uninstall -axq --user-install #{github_gem}"
          puts "\n"
        end
      end
      
      dont_ask = true if proceed == "a"
    end
    
    puts "Migration finished."
  else
    puts "Oh well."
  end
end