SHARE
TWEET

Untitled

a guest Nov 11th, 2019 114 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. class TrueClass
  3.     def to_str
  4.         return self.to_s
  5.     end
  6. end
  7.  
  8. class FalseClass
  9.     def to_str
  10.         return self.to_s
  11.     end
  12. end
  13.  
  14. def require_deps
  15.     [
  16.         ['mechanize', 'mechanize', 'for HTTP requests'],
  17.     ].each do |gem, package, reason|
  18.         Gem.clear_paths if Gem
  19.         begin
  20.             require package
  21.         rescue ScriptError
  22.             install_dep(gem, reason)
  23.             Gem.clear_paths if Gem
  24.             require package
  25.         end
  26.     end
  27. end
  28.  
  29. def install_dep(package, reason)
  30.     name = Script.current.name
  31.     line = '-'*50
  32.     msg = []
  33.     msg << line
  34.     msg << "#{name} requires the '#{package}' RubyGem #{reason}."
  35.     msg << ''
  36.     unless RUBY_VERSION =~ /^(\d+)\.(\d+)/
  37.         msg << "It is not able to automatically install it because it cannot determine what version of Ruby you are running."
  38.         msg << "The automatic install requires Ruby 2.4 or later.  Your current version is listed as #{RUBY_VERSION.inspect}"
  39.         msg << ''
  40.         msg << "Please update your Ruby install and/or install sequel manually, then try again."
  41.         msg << line
  42.         respond msg
  43.         exit
  44.     end
  45.     major = $1.to_i
  46.     minor = $2.to_i
  47.  
  48.     unless Gem
  49.         msg << "'Gem' does not appear to be available."
  50.         msg << ''
  51.         msg << "Please update your Ruby install, install gem', or install sequel manually, then try again."
  52.         msg << line
  53.         respond msg
  54.         exit
  55.     end
  56.  
  57.     warning = nil
  58.  
  59.     if major == 2
  60.         if minor < 4
  61.             warning = "Your version of Ruby (#{RUBY_VERSION}) is probably too old for automatic installation to succeed."
  62.  
  63.         end
  64.     elsif major < 2
  65.         warning = "Your version of Ruby (#{RUBY_VERSION}) is too old for Lich(!) much less this script."
  66.     else
  67.         warning = "Your version of Ruby (#{RUBY_VERSION}) is too new and exotic, and the outcome of automatic installation is not guaranteed."
  68.     end
  69.  
  70.     if warning
  71.         msg << warning
  72.         msg << "If you want to attempt automatic installation anyways:"
  73.     else
  74.         msg << "If you want to attempt automatic installation:"
  75.     end
  76.     msg << "    #{$lich_char}unpause #{name}"
  77.     msg << ''
  78.     msg << "Otherwise:"
  79.     msg << "    #{$lich_char}kill #{name}"
  80.     msg << line
  81.     respond msg
  82.  
  83.     pause_script
  84.  
  85.     echo "Installing #{package}.  This may take a minute..."
  86.     Gem.install(package, verbose: true)
  87.     Gem.clear_paths
  88. end
  89. require_deps
  90.  
  91. require 'rubygems'
  92. require 'mechanize'
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top