Class: Sprout::FlashPlayerTrust

Inherits:
Object
  • Object
show all
Defined in:
lib/sprout/tasks/flashplayer_task.rb

Overview

FlashPlayerTrust Class

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ FlashPlayerTrust

:nodoc:



458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
# File 'lib/sprout/tasks/flashplayer_task.rb', line 458

def initialize(path)
  trust_file = FlashPlayerTask.trust
  if(!File.exists?(trust_file))
   FileUtils.mkdir_p(File.dirname(trust_file))
   FileUtils.touch(trust_file)
  end

  parts = path.split(File::SEPARATOR)
  if(parts.size == 1)
    path = File::SEPARATOR + path
  end

  if(!has_path?(trust_file, path))
    File.open(trust_file, 'a') do |f|
      f.puts path
    end
    Log.puts ">> Added #{path} to Flash Player Trust file at: #{trust_file}"
  end
end

Instance Method Details

#has_path?(file, path) ⇒ Boolean

Returns:

  • (Boolean)


478
479
480
481
482
# File 'lib/sprout/tasks/flashplayer_task.rb', line 478

def has_path?(file, path)
  File.open(file, 'r') do |f|
    return (f.read.index(path))
  end
end