Sha256: 178942761be692ecf3b29b1418a88db3dba6669650883fc4965817ee28f561b7

Contents?: true

Size: 774 Bytes

Versions: 3

Compression:

Stored size: 774 Bytes

Contents

module FlashPlayer

  class Trust

    attr_accessor :logger

    def initialize
      @logger = $stdout
    end

    def add path
      file = trust_file
      create(file) unless File.exists?(file)
      update_if_necessary file, path
    end

    private

    def create file
      FileUtils.makedirs File.dirname(file)
      FileUtils.touch file
    end

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

    def has_path? file, path
      !File.read(file).index(path).nil?
    end

    def trust_file
      FlashPlayer.trust
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
flashplayer-10.1.3.pre lib/flashplayer/trust.rb
flashplayer-10.1.2.pre lib/flashplayer/trust.rb
flashplayer-10.1.1.pre lib/flashplayer/trust.rb