Class: AsProject::User
- Inherits:
-
Object
- Object
- AsProject::User
- Defined in:
- lib/path_finder.rb
Overview
User class
Instance Method Summary collapse
- #asproject_home ⇒ Object
- #asproject_player_trust ⇒ Object
- #downloads ⇒ Object
- #file_exists?(file) ⇒ Boolean
- #flash_player_config ⇒ Object
- #flash_player_config_content ⇒ Object
- #flash_player_home ⇒ Object
- #flash_player_log ⇒ Object
- #flash_player_path(version) ⇒ Object
- #flash_player_trust ⇒ Object
- #get_or_create(dir) ⇒ Object
- #get_player_url(version) ⇒ Object
- #home ⇒ Object
-
#initialize ⇒ User
constructor
A new instance of User.
- #library ⇒ Object
- #mxmlc ⇒ Object
- #remote_file_task(name, task) ⇒ Object
Constructor Details
#initialize ⇒ User
Returns a new instance of User.
246 247 248 249 250 251 252 253 254 255 |
# File 'lib/path_finder.rb', line 246 def initialize @flash_player_7_url = nil @flash_player_8_url = nil @flash_player_9_url = nil @zip_target = "" @default_asproject = '.asproject' @flash_log_file_name = 'flashlog.txt' end |
Instance Method Details
#asproject_home ⇒ Object
271 272 273 |
# File 'lib/path_finder.rb', line 271 def asproject_home return get_or_create(File.join(home, @default_asproject)) end |
#asproject_player_trust ⇒ Object
355 356 357 358 359 360 |
# File 'lib/path_finder.rb', line 355 def asproject_player_trust if(!File.exists?(flash_player_trust)) raise UsageError.new('Could not find the main Flash Player Trust folder at: ' + flash_player_trust) end return File.join(flash_player_trust, 'asproject.cfg') end |
#downloads ⇒ Object
323 324 325 |
# File 'lib/path_finder.rb', line 323 def downloads return File.join(asproject_home, 'downloads') end |
#file_exists?(file) ⇒ Boolean
362 363 364 |
# File 'lib/path_finder.rb', line 362 def file_exists?(file) return File.exists?(file) end |
#flash_player_config ⇒ Object
279 280 281 |
# File 'lib/path_finder.rb', line 279 def flash_player_config return File.join(home, 'mm.cfg') end |
#flash_player_config_content ⇒ Object
283 284 285 286 287 288 289 290 |
# File 'lib/path_finder.rb', line 283 def flash_player_config_content return <<EOF ErrorReportingEnable=1 MaxWarnings=0 TraceOutputEnable=1 TraceOutputFileName=#{flash_player_log} EOF end |
#flash_player_home ⇒ Object
347 348 349 |
# File 'lib/path_finder.rb', line 347 def flash_player_home raise UsageError.new('Not sure where flash_player_home should be on systems other than Win/Mac - please let us know so that we can update this script...') end |
#flash_player_log ⇒ Object
313 314 315 316 317 318 319 320 321 |
# File 'lib/path_finder.rb', line 313 def flash_player_log dir = File.join(flash_player_home, 'Logs') File.makedirs(dir) file = File.join(dir, @flash_log_file_name) if(!File.exists?(file)) File.open(file, 'w') end return file end |
#flash_player_path(version) ⇒ Object
309 310 311 |
# File 'lib/path_finder.rb', line 309 def flash_player_path(version) return File.join(asproject_home, 'players', 'FlashPlayer' + version.to_s) end |
#flash_player_trust ⇒ Object
351 352 353 |
# File 'lib/path_finder.rb', line 351 def flash_player_trust return File.join(flash_player_home, '#Security', 'FlashPlayerTrust') end |
#get_or_create(dir) ⇒ Object
366 367 368 369 370 371 |
# File 'lib/path_finder.rb', line 366 def get_or_create dir if(!file_exists? dir) Dir.mkdir dir end return dir end |
#get_player_url(version) ⇒ Object
292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 |
# File 'lib/path_finder.rb', line 292 def get_player_url(version) url = nil if(version == 7) url = @flash_player_7_url elsif(version == 8) url = @flash_player_8_url elsif(version == 9) url = @flash_player_9_url end if(url.nil?) raise UsageError.new("Not sure where to go for this player version: #{version}, please try 7, 8 or 9") end return url end |
#home ⇒ Object
327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 |
# File 'lib/path_finder.rb', line 327 def home ["HOME", "USERPROFILE"].each do |homekey| return ENV[homekey] if ENV[homekey] end if ENV["HOMEDRIVE"] && ENV["HOMEPATH"] return "#{ENV["HOMEDRIVE"]}:#{ENV["HOMEPATH"]}" end begin File.("~") rescue StandardError => ex if File::ALT_SEPARATOR "C:\\" else "/" end end end |
#library ⇒ Object
275 276 277 |
# File 'lib/path_finder.rb', line 275 def library return home end |
#mxmlc ⇒ Object
257 258 259 |
# File 'lib/path_finder.rb', line 257 def mxmlc return 'mxmlc' end |
#remote_file_task(name, task) ⇒ Object
261 262 263 264 265 266 267 268 269 |
# File 'lib/path_finder.rb', line 261 def remote_file_task(name, task) return UnixRemoteFileTask.new(name, self) do |t| if(task.unix_url.nil?) raise UsageError.new("There was a problem finding a target for #{task.name}, it doesn't appear as if this task was expected to run on your system...") end t.url = task.unix_url t.extracted_file = task.unix_extracted_file end end |