class

RefererParser::Parser

Inherits Reference / Object

Constants

DefaultFile = File.expand_path(File.join(File.dirname("/tmp/tmp.jFpMja/src/src/referer-parser/parser.cr"), "..", "..", "data", "referers.yml"))

Constructors

new(file_path : String = DefaultFile, get_data : Bool = true)

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

Source

Instance methods

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.

Source
clear!

Clean out the database

Source
deserialize_referer_data
Source
domain_index
Source
name_hash
Source
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

Source
parse(obj : String | URI)

Given a string or URI, return a hash of data

Source