Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class TrueClass
- def to_str
- return self.to_s
- end
- end
- class FalseClass
- def to_str
- return self.to_s
- end
- end
- def require_deps
- [
- ['mechanize', 'mechanize', 'for HTTP requests'],
- ].each do |gem, package, reason|
- Gem.clear_paths if Gem
- begin
- require package
- rescue ScriptError
- install_dep(gem, reason)
- Gem.clear_paths if Gem
- require package
- end
- end
- end
- def install_dep(package, reason)
- name = Script.current.name
- line = '-'*50
- msg = []
- msg << line
- msg << "#{name} requires the '#{package}' RubyGem #{reason}."
- msg << ''
- unless RUBY_VERSION =~ /^(\d+)\.(\d+)/
- msg << "It is not able to automatically install it because it cannot determine what version of Ruby you are running."
- msg << "The automatic install requires Ruby 2.4 or later. Your current version is listed as #{RUBY_VERSION.inspect}"
- msg << ''
- msg << "Please update your Ruby install and/or install sequel manually, then try again."
- msg << line
- respond msg
- exit
- end
- major = $1.to_i
- minor = $2.to_i
- unless Gem
- msg << "'Gem' does not appear to be available."
- msg << ''
- msg << "Please update your Ruby install, install gem', or install sequel manually, then try again."
- msg << line
- respond msg
- exit
- end
- warning = nil
- if major == 2
- if minor < 4
- warning = "Your version of Ruby (#{RUBY_VERSION}) is probably too old for automatic installation to succeed."
- end
- elsif major < 2
- warning = "Your version of Ruby (#{RUBY_VERSION}) is too old for Lich(!) much less this script."
- else
- warning = "Your version of Ruby (#{RUBY_VERSION}) is too new and exotic, and the outcome of automatic installation is not guaranteed."
- end
- if warning
- msg << warning
- msg << "If you want to attempt automatic installation anyways:"
- else
- msg << "If you want to attempt automatic installation:"
- end
- msg << " #{$lich_char}unpause #{name}"
- msg << ''
- msg << "Otherwise:"
- msg << " #{$lich_char}kill #{name}"
- msg << line
- respond msg
- pause_script
- echo "Installing #{package}. This may take a minute..."
- Gem.install(package, verbose: true)
- Gem.clear_paths
- end
- require_deps
- require 'rubygems'
- require 'mechanize'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement