Class: AsProject::FlashPlayerTrust

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

Instance Method Summary collapse

Constructor Details

#initialize(user, path) ⇒ FlashPlayerTrust

Returns a new instance of FlashPlayerTrust.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/tasks/flash_player_trust.rb', line 5

def initialize(user, path)
  trust_file = user.asproject_player_trust
  if(!File.exists?(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
    Logger.puts ">> Added #{path} to Flash Player Trust file at: #{trust_file}"
  end
end

Instance Method Details

#has_path?(file, path) ⇒ Boolean

Returns:

  • (Boolean)


24
25
26
27
28
# File 'lib/tasks/flash_player_trust.rb', line 24

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