class RefererParser::Parser

Defined in:

referer-parser/parser.cr

Constant Summary

DefaultFile = File.expand_path(File.join(File.dirname("/srv/crystaldoc.info/github-confact-referer-parser.cr-v0.1.1/src/referer-parser/parser.cr"), "..", "..", "data", "referers.yml"))

Constructors

Instance Method Summary

Constructor Detail

def self.new(file_path : String = DefaultFile, get_data : Bool = true) #

Create a new parser from one or more filenames/uris, defaults to ../data/referers.json


[View source]

Instance Method Detail

def add_referer(medium, name, domains, parameters = [""]) #

Add a referer to the database with medium, name, domain or array of domains, and a parameter or array of parameters If called manually and a domain is added to an existing entry with a path, you may need to call optimize_index! afterwards.


[View source]
def clear! #

Clean out the database


[View source]
def deserialize_referer_data #

[View source]
def domain_index : Hash(String, Array(Array(String))) #

[View source]
def name_hash : Hash(String, {source: String, medium: String, parameters: Array(String)?}) #

[View source]
def optimize_index! #

Prune duplicate entries and sort with the most specific path first if there is more than one entry In this case, sorting by the longest string works fine


[View source]
def parse(obj : String | URI) #

Given a string or URI, return a hash of data


[View source]