An crystal implementation of referer-parser, an library for extracting search marketing data from referer (sic) URL.
This one is huge inspired and borrowed code from the ruby implementation: https://github.com/snowplow-referer-parser/ruby-referer-parser
This one only support YAML for now.
-
Add the dependency to your
shard.yml
:dependencies: referer-parser: github: confact/referer-parser.cr
-
Run
shards install
require "referer-parser"
create an instance of the parser:
parser = RefererParser::Parser.new
And then you can start parsing the urls like this:
parser.parse("http://www.google.com/search?q=gateway+oracle+cards+denise+linn&hl=en&client=safari")
# => {
known: true,
source: "Google",
medium: "search",
uri:
"http://www.google.com/search?q=gateway+oracle+cards+denise+linn&hl=en&client=safari",
term: "gateway oracle cards denise linn",
domain: "google.com"
}
We don't support the JSON of the data file snowplow is releasing right now.
shards install
You can then add require on an test file or use the specs for test functionality.
You run the tests like this:
crystal spec
- Fork it (https://github.com/confact/referer-parser/fork)
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
- Håkan Nylén - creator and maintainer