Class: Referrer::MarkupGenerator
- Inherits:
-
Object
- Object
- Referrer::MarkupGenerator
- Defined in:
- lib/other/markup_generator.rb
Constant Summary collapse
- UTM_KEYS =
%w(utm_source utm_medium utm_campaign utm_content utm_term)
- ORGANICS =
[{host: 'search.daum.net', param: 'q'}, {host: 'search.naver.com', param: 'query'}, {host: 'search.yahoo.com', param: 'p'}, {host: /^(www\.)?google\.[a-z]+$/, param: 'q', display: 'google'}, {host: 'www.bing.com', param: 'q'}, {host: 'search.aol.com', params: 'q'}, {host: 'search.lycos.com', param: 'q'}, {host: 'edition.cnn.com', param: 'text'}, {host: 'index.about.com', param: 'q'}, {host: 'mamma.com', param: 'q'}, {host: 'ricerca.virgilio.it', param: 'qs'}, {host: 'www.baidu.com', param: 'wd'}, {host: /^(www\.)?yandex\.[a-z]+$/, param: 'text', display: 'yandex'}, {host: 'search.seznam.cz', param: 'oq'}, {host: 'www.search.com', param: 'q'}, {host: 'search.yam.com', param: 'k'}, {host: 'www.kvasir.no', param: 'q'}, {host: 'buscador.terra.com', param: 'query'}, {host: 'nova.rambler.ru', param: 'query'}, {host: 'go.mail.ru', param: 'q'}, {host: 'www.ask.com', param: 'q'}, {host: 'searches.globososo.com', param: 'q'}, {host: 'search.tut.by', param: 'query'}]
- REFERRALS =
[{host: /^(www\.)?t\.co$/, display: 'twitter.com'}, {host: /^(www\.)?plus\.url\.google\.com$/, display: 'plus.google.com'}]
Instance Attribute Summary collapse
-
#array_params_joiner ⇒ Object
Returns the value of attribute array_params_joiner.
-
#organics ⇒ Object
Returns the value of attribute organics.
-
#referrals ⇒ Object
Returns the value of attribute referrals.
-
#utm_synonyms ⇒ Object
Returns the value of attribute utm_synonyms.
Instance Method Summary collapse
- #generate(referrer, entry_point) ⇒ Object
-
#initialize ⇒ MarkupGenerator
constructor
A new instance of MarkupGenerator.
Constructor Details
#initialize ⇒ MarkupGenerator
Returns a new instance of MarkupGenerator.
33 34 35 36 37 38 |
# File 'lib/other/markup_generator.rb', line 33 def initialize @organics = ORGANICS @referrals = REFERRALS @utm_synonyms = UTM_KEYS.inject({}){|r, key| r.merge({key => []})} @array_params_joiner = ', ' end |
Instance Attribute Details
#array_params_joiner ⇒ Object
Returns the value of attribute array_params_joiner.
31 32 33 |
# File 'lib/other/markup_generator.rb', line 31 def array_params_joiner @array_params_joiner end |
#organics ⇒ Object
Returns the value of attribute organics.
31 32 33 |
# File 'lib/other/markup_generator.rb', line 31 def organics @organics end |
#referrals ⇒ Object
Returns the value of attribute referrals.
31 32 33 |
# File 'lib/other/markup_generator.rb', line 31 def referrals @referrals end |
#utm_synonyms ⇒ Object
Returns the value of attribute utm_synonyms.
31 32 33 |
# File 'lib/other/markup_generator.rb', line 31 def utm_synonyms @utm_synonyms end |
Instance Method Details
#generate(referrer, entry_point) ⇒ Object
40 41 42 43 44 45 |
# File 'lib/other/markup_generator.rb', line 40 def generate(referrer, entry_point) referrer_uri, entry_point_uri = *[referrer, entry_point].map{|url| URI(URI::encode(url || ''))} referrer_params, entry_point_params = *[referrer_uri, entry_point_uri].map{|uri| uri_params(uri)} prepare_result(utm(entry_point_params) || organic(referrer_uri, referrer_params) || referral(referrer_uri) || direct) end |