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.



234
235
236
237
238
239
240
241
242
243
# File 'lib/path_finder.rb', line 234

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



255
256
257
# File 'lib/path_finder.rb', line 255

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

#asproject_player_trustObject



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

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



307
308
309
# File 'lib/path_finder.rb', line 307

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

#file_exists?(file) ⇒ Boolean

Returns:

  • (Boolean)


346
347
348
# File 'lib/path_finder.rb', line 346

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

#flash_player_configObject



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

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

#flash_player_config_contentObject



267
268
269
270
271
272
273
274
# File 'lib/path_finder.rb', line 267

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

#flash_player_homeObject

Raises:



331
332
333
# File 'lib/path_finder.rb', line 331

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



297
298
299
300
301
302
303
304
305
# File 'lib/path_finder.rb', line 297

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



293
294
295
# File 'lib/path_finder.rb', line 293

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

#flash_player_trustObject



335
336
337
# File 'lib/path_finder.rb', line 335

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

#get_or_create(dir) ⇒ Object



350
351
352
353
354
355
# File 'lib/path_finder.rb', line 350

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

#get_player_url(version) ⇒ Object



276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
# File 'lib/path_finder.rb', line 276

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



311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
# File 'lib/path_finder.rb', line 311

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



259
260
261
# File 'lib/path_finder.rb', line 259

def library
  return home
end

#remote_file_task(name, task) ⇒ Object



245
246
247
248
249
250
251
252
253
# File 'lib/path_finder.rb', line 245

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