Class: Setup
- Inherits:
-
Object
- Object
- Setup
- Defined in:
- lib/six/launcher-app.rb
Overview
require ‘singleton’
Constant Summary collapse
- RUBY =
"tools/ruby/bin/ruby.exe"- GEM =
"tools/ruby/bin/gem"- VERSION =
"0.1.7"- BASE_PATH =
include Singleton
if ENV['OCRA_EXECUTABLE'] if ENV['OCRA_EXECUTABLE'][/(.*)[\/|\\].*/] p = $1 p.gsub!('\\', '/') p else p = Dir.pwd p.gsub!('\\', '/') p end elsif defined?(TAR2RUBYSCRIPT) if oldlocation oldlocation else Dir.pwd end else p = Dir.pwd p.gsub!('\\', '/') p end
- TOOL_PATH =
File.join(BASE_PATH, 'tools')
- RUBY_PATH =
File.join(TOOL_PATH, 'ruby')
- RUBY_BIN =
File.join(RUBY_PATH, 'bin', 'ruby.exe')
Instance Method Summary collapse
- #action(code) ⇒ Object
- #bla ⇒ Object
- #detached(app, cl, path) ⇒ Object
-
#initialize(b = nil) ⇒ Setup
constructor
A new instance of Setup.
- #options ⇒ Object
- #rubycheck ⇒ Object
- #start_updater(params = nil) ⇒ Object
- #start_updater_web(cl = nil) ⇒ Object
- #update_gems ⇒ Object
- #update_ruby ⇒ Object
- #verify_admin ⇒ Object
Constructor Details
Instance Method Details
#action(code) ⇒ Object
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
# File 'lib/six/launcher-app.rb', line 134 def action(code) case code when "100" update_ruby when "101" update_gems when "1" start_updater_web when "2" start_updater("--wait") when "21" start_updater("--install --startgame --wait") when "22" start_updater("--install --join --wait") when "23" start_updater("--startgame --wait") when "24" start_updater("--join --wait") when "51" start_updater_web("--bind 0.0.0.0") end bla end |
#bla ⇒ Object
73 74 75 76 77 |
# File 'lib/six/launcher-app.rb', line 73 def bla puts puts "Please press enter to continue" STDIN.gets end |
#detached(app, cl, path) ⇒ Object
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/six/launcher-app.rb', line 115 def detached(app, cl, path) begin app.gsub!("/", "\\") cl = "/C \"#{app}\" #{cl}" struct = Process.create( :app_name => File.join(ENV['WINDIR'], 'system32', 'cmd.exe'), :command_line => cl, :creation_flags => Process::DETACHED_PROCESS, :process_inherit => false, :thread_inherit => false, :cwd => path, :inherit => false #:environment => "" ) rescue puts "WARNING: Something went wrong starting the app: #{app}" end end |
#options ⇒ Object
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 |
# File 'lib/six/launcher-app.rb', line 158 def puts puts <<BEGIN Launcher application v#{VERSION} by Sickboy WARNING: If you use Windows Vista/7 with UAC, please make sure you run this program 'As Administrator' ----- 1 - Start updater-web 2 - Start updater ----- 21 - Start updater, --install --startgame 22 - Start updater, --install --join 23 - Start updater, --startgame 24 - Start updater, --join ----- 51 - Start updater-web on public interface ----- 100 - Install/Update Ruby 101 - Install/Update Ruby Gems Please enter your choice and press enter. Or press CTRL+C to abort BEGIN end |
#rubycheck ⇒ Object
69 70 71 |
# File 'lib/six/launcher-app.rb', line 69 def rubycheck update_ruby unless File.exists?(RUBY_BIN) end |
#start_updater(params = nil) ⇒ Object
107 108 109 110 111 112 113 |
# File 'lib/six/launcher-app.rb', line 107 def start_updater(params = nil) rubycheck update_gems puts "Starting Updater..." # -U detached(RUBY_BIN, "-rubygems six-updater.rb #{params}", BASE_PATH) end |
#start_updater_web(cl = nil) ⇒ Object
93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/six/launcher-app.rb', line 93 def start_updater_web(cl = nil) rubycheck update_gems puts "Starting Updater-web..." # -U b = "-rubygems six-updater-web.rb" cl = if cl "#{b} #{cl}" else b end detached(RUBY_BIN, cl, BASE_PATH) end |
#update_gems ⇒ Object
85 86 87 88 89 90 91 |
# File 'lib/six/launcher-app.rb', line 85 def update_gems rubycheck puts "Updating Ruby Gems" system "#{RUBY} #{GEM} install *.gem" if Dir["*.gem"].size > 0 system "#{RUBY} #{GEM} update" system "#{RUBY} #{GEM} clean" end |
#update_ruby ⇒ Object
79 80 81 82 83 |
# File 'lib/six/launcher-app.rb', line 79 def update_ruby puts "Updating Ruby" system "#{RUBY} tools/six-downloader.rb tools/six-downloader_ruby.yml" system "tools/7z.exe x -y tools/ruby.7z -otools" end |
#verify_admin ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/six/launcher-app.rb', line 54 def verify_admin =begin begin out = %x[whoami /groups] unless out[/High Mandatory Level/] puts "You are not running this application \"as Administrator\", exitting..." puts "You must right click this application and choose \"Run as Administrator\"" sleep 10 Process.exit end rescue end =end end |