Class: Sekisyo::Whitelist

Inherits:
Object
  • Object
show all
Defined in:
lib/sekisyo/whitelist.rb

Overview

Sekisyo Whitelist parses the yaml file and assists in finding the corresponding whitelist.

Instance Method Summary collapse

Instance Method Details

#find(path) ⇒ Sekisyo::WhitelistDetails::Path

Parameters:

  • path (String)

    URL string.

Returns:



30
31
32
# File 'lib/sekisyo/whitelist.rb', line 30

def find(path)
  @paths.find { |pattern| pattern.match?(path) }
end

#parse(*file_paths) ⇒ Object

Reads the yaml file containing the whitelist definition and converts it to a Ruby object.

Parameters:

  • file_paths (Array<string>)

    Paths of the yaml file where the whitelist is defined.



17
18
19
20
21
22
23
# File 'lib/sekisyo/whitelist.rb', line 17

def parse(*file_paths)
  @hash = Hashie::Mash.new.deep_merge(*file_paths.map(&Hashie::Mash.method(:load)))
  @paths = @hash['paths'].map do |path, object|
    Sekisyo::WhitelistDetails::Path.new(path, object)
  end
  self
end