Sha256: 2632f9c3e749662330333b278b9993f74d247943eca56a2b95c26ec56ae1e8c4

Contents?: true

Size: 622 Bytes

Versions: 3

Compression:

Stored size: 622 Bytes

Contents

class LockedKeys
  def initialize(root_path)
    @locked_patterns = []

    fullpath = File.join(root_path, 'locked_keys')
    if File.exists? fullpath
      read_locked_patterns(fullpath) unless File.directory?(fullpath)
    end
  end

  def locked?(full_key)
    @locked_patterns.each do |pattern|
      if full_key =~ pattern
        return true
      end
    end

    false
  end

private

  def read_locked_patterns(fullpath)
    File.open(fullpath) do |f|
      f.each_line do |line|
        next if line.empty? or line.start_with? '#'
        @locked_patterns << Regexp.new(line.rstrip)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
yaml-validator-0.1.10 lib/locked_keys.rb
yaml-validator-0.1.9 lib/locked_keys.rb
yaml-validator-0.1.8 lib/locked_keys.rb