Class: AsProject::User

Inherits:
Object
  • Object
show all
Defined in:
lib/path_finder.rb

Overview

User class

Direct Known Subclasses

OSXUser, WinUser

Instance Method Summary collapse

Constructor Details

#initializeUser

Returns a new instance of User.



238
239
240
241
242
243
244
245
246
247
# File 'lib/path_finder.rb', line 238

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_homeObject



263
264
265
# File 'lib/path_finder.rb', line 263

def asproject_home
  return get_or_create(File.join(home, @default_asproject))
end

#asproject_player_trustObject



347
348
349
350
351
352
# File 'lib/path_finder.rb', line 347

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

#downloadsObject



315
316
317
# File 'lib/path_finder.rb', line 315

def downloads
  return File.join(asproject_home, 'downloads')
end

#file_exists?(file) ⇒ Boolean

Returns:

  • (Boolean)


354
355
356
# File 'lib/path_finder.rb', line 354

def file_exists?(file)
  return File.exists?(file)
end

#flash_player_configObject



271
272
273
# File 'lib/path_finder.rb', line 271

def flash_player_config
  return File.join(home, 'mm.cfg')
end

#flash_player_config_contentObject



275
276
277
278
279
280
281
282
# File 'lib/path_finder.rb', line 275

def flash_player_config_content
  return <<EOF
ErrorReportingEnable=1
MaxWarnings=0
TraceOutputEnable=1
TraceOutputFileName=#{flash_player_log}
EOF
end

#flash_player_homeObject

Raises:



339
340
341
# File 'lib/path_finder.rb', line 339

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_logObject



305
306
307
308
309
310
311
312
313
# File 'lib/path_finder.rb', line 305

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



301
302
303
# File 'lib/path_finder.rb', line 301

def flash_player_path(version)
  return File.join(asproject_home, 'players', 'FlashPlayer' + version.to_s)
end

#flash_player_trustObject



343
344
345
# File 'lib/path_finder.rb', line 343

def flash_player_trust
  return File.join(flash_player_home, '#Security', 'FlashPlayerTrust')
end

#get_or_create(dir) ⇒ Object



358
359
360
361
362
363
# File 'lib/path_finder.rb', line 358

def get_or_create dir
  if(!file_exists? dir)
    Dir.mkdir dir
  end
  return dir
end

#get_player_url(version) ⇒ Object



284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
# File 'lib/path_finder.rb', line 284

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

#homeObject



319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
# File 'lib/path_finder.rb', line 319

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.expand_path("~")
  rescue StandardError => ex
    if File::ALT_SEPARATOR
      "C:\\"
    else
      "/"
    end
  end
end

#libraryObject



267
268
269
# File 'lib/path_finder.rb', line 267

def library
  return home
end

#mxmlcObject



249
250
251
# File 'lib/path_finder.rb', line 249

def mxmlc
  return 'mxmlc'
end

#remote_file_task(name, task) ⇒ Object



253
254
255
256
257
258
259
260
261
# File 'lib/path_finder.rb', line 253

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