class RefererParser::Parser
- RefererParser::Parser
- Reference
- Object
Defined in:
referer-parser/parser.crConstant 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
-
.new(file_path : String = DefaultFile, get_data : Bool = true)
Create a new parser from one or more filenames/uris, defaults to ../data/referers.json
Instance Method Summary
-
#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.
-
#clear!
Clean out the database
- #deserialize_referer_data
- #domain_index : Hash(String, Array(Array(String)))
- #name_hash : Hash(String, {source: String, medium: String, parameters: Array(String)?})
-
#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
-
#parse(obj : String | URI)
Given a string or URI, return a hash of data
Constructor Detail
Create a new parser from one or more filenames/uris, defaults to ../data/referers.json
Instance Method Detail
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.
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