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.2.2"
- 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, uni = false) ⇒ Object
- #start_updater_web(cl = nil, uni = false) ⇒ Object
- #update_gems ⇒ Object
- #update_ruby ⇒ Object
- #verify_admin ⇒ Object
Constructor Details
Instance Method Details
#action(code) ⇒ Object
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 |
# File 'lib/six/launcher-app.rb', line 136 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") when "91" start_updater_web(nil, true) when "92" start_updater("--wait", true) 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
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/six/launcher-app.rb', line 117 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
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 |
# File 'lib/six/launcher-app.rb', line 164 def puts puts <<BEGIN Launcher v#{VERSION} by Sickboy WARNING: If you use Windows Vista/7 with UAC, please make sure you run this program 'As Administrator' ----- Basic 1 - Start web-client 2 - Start updater ----- Shortcuts 21 - Start updater, --install --startgame 22 - Start updater, --install --join 23 - Start updater, --startgame 24 - Start updater, --join ----- Special 51 - Start web-client on public interface ----- Troubleshooting 91 - Start web-client, Ruby Unicode mode 92 - Start updater, Ruby Unicode mode 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, uni = false) ⇒ Object
108 109 110 111 112 113 114 115 |
# File 'lib/six/launcher-app.rb', line 108 def start_updater(params = nil, uni = false) rubycheck update_gems puts "Starting Updater..." b = "-rubygems six-updater.rb #{params}" b = "-U " + b if uni detached(RUBY_BIN, b, BASE_PATH) end |
#start_updater_web(cl = nil, uni = false) ⇒ Object
93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/six/launcher-app.rb', line 93 def start_updater_web(cl = nil, uni = false) rubycheck update_gems puts "Starting Web-client..." # -U b = "-rubygems six-updater-web.rb" b = "-U " + b if uni 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 |