项目作者: confact

项目描述 :
Crystal implementation of snowplow's referer-parser.
高级语言: Crystal
项目地址: git://github.com/confact/referer-parser.cr.git
创建时间: 2020-05-26T09:55:46Z
项目社区:https://github.com/confact/referer-parser.cr

开源协议:MIT License

下载


referer-parser

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.

Installation

  1. Add the dependency to your shard.yml:

    1. dependencies:
    2. referer-parser:
    3. github: confact/referer-parser.cr
  2. Run shards install

Usage

  1. require "referer-parser"

Use parser

create an instance of the parser:

  1. parser = RefererParser::Parser.new

And then you can start parsing the urls like this:

  1. parser.parse("http://www.google.com/search?q=gateway+oracle+cards+denise+linn&hl=en&client=safari")
  2. # => {
  3. known: true,
  4. source: "Google",
  5. medium: "search",
  6. uri:
  7. "http://www.google.com/search?q=gateway+oracle+cards+denise+linn&hl=en&client=safari",
  8. term: "gateway oracle cards denise linn",
  9. domain: "google.com"
  10. }

What is left

We don’t support the JSON of the data file snowplow is releasing right now.

Development

  1. shards install

You can then add require on an test file or use the specs for test functionality.

You run the tests like this:

  1. crystal spec

Contributing

  1. Fork it (https://github.com/confact/referer-parser/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors