muvandy 1.1.1a1 → 1.2a1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +14 -17
- data/lib/muvandy/muvandy.rb +3 -3
- data/lib/muvandy/version.rb +1 -1
- data/lib/muvandy.rb +22 -22
- metadata +7 -7
data/README.md
CHANGED
@@ -6,7 +6,7 @@ Client for [Muvandy API](http://muvandy.com)
|
|
6
6
|
|
7
7
|
Add this line to your application's Gemfile:
|
8
8
|
|
9
|
-
gem 'muvandy', '~> 1.1a1'
|
9
|
+
gem 'muvandy', '~> 1.1.1a1'
|
10
10
|
|
11
11
|
And then execute:
|
12
12
|
|
@@ -18,12 +18,21 @@ Or install it yourself as:
|
|
18
18
|
|
19
19
|
## To Configure
|
20
20
|
|
21
|
-
Create a file in your config/initializers folder named muvandy_setup.rb (or whichever name you prefer)
|
21
|
+
Create a file in your `config/initializers` folder named `muvandy_setup.rb` (or whichever name you prefer)
|
22
22
|
|
23
23
|
Muvandy.configure do |c|
|
24
|
-
c.api_key = '
|
24
|
+
c.api_key = 'api_key_here'
|
25
25
|
end
|
26
26
|
|
27
|
+
Add `include Muvandy` in your `controllers/application_controller.rb`.
|
28
|
+
|
29
|
+
class ApplicationController < ActionController::Base
|
30
|
+
include Muvandy
|
31
|
+
|
32
|
+
...
|
33
|
+
end
|
34
|
+
|
35
|
+
|
27
36
|
## Get Variations
|
28
37
|
|
29
38
|
### Controller
|
@@ -31,24 +40,12 @@ Create a file in your config/initializers folder named muvandy_setup.rb (or whic
|
|
31
40
|
Example of using muvandy on a controller.
|
32
41
|
|
33
42
|
class HomeController < ApplicationController
|
34
|
-
include Muvandy
|
35
|
-
before_filter :collect_muvandy_visitor_indfo, :only => [:index]
|
36
|
-
|
37
43
|
def index
|
38
|
-
@muvandy = Muvandy.new('
|
44
|
+
@muvandy = Muvandy.new('experiment_id', :visitor_key => request.remote_ip)
|
39
45
|
end
|
40
46
|
end
|
41
47
|
|
42
|
-
A
|
43
|
-
|
44
|
-
Setting 'collect_muvandy_visitor_indfo' in your before_filter helps muvandy collect the following information from your 'request' & 'params' variables.
|
45
|
-
* referrer
|
46
|
-
* utm_term
|
47
|
-
* utm_campaign
|
48
|
-
* utm_source
|
49
|
-
* utm_medium
|
50
|
-
* mode
|
51
|
-
|
48
|
+
A `visitor_key` is required. By default, we recommend using the visitor's IP address but if you have other information on them their account id or email address make good unique visitor identifiers.
|
52
49
|
|
53
50
|
### Views
|
54
51
|
|
data/lib/muvandy/muvandy.rb
CHANGED
@@ -36,7 +36,7 @@ module Muvandy
|
|
36
36
|
@variable_variations = {}
|
37
37
|
begin
|
38
38
|
xml = get(:variable_variations)
|
39
|
-
Rails.logger.debug { "DEBUG ------------ #{xml.parsed_response.inspect}" }
|
39
|
+
# Rails.logger.debug { "DEBUG ------------ #{xml.parsed_response.inspect}" }
|
40
40
|
if xml.parsed_response && !xml.parsed_response["visitor"].blank?
|
41
41
|
# self.id = xml.parsed_response["visitor"]["id"].to_i if !xml.parsed_response["visitor"].blank? && !xml.parsed_response["visitor"]["id"].blank?
|
42
42
|
xml.parsed_response["visitor"]["variable_variations"]["variable"].each do |v|
|
@@ -58,7 +58,7 @@ module Muvandy
|
|
58
58
|
end
|
59
59
|
begin
|
60
60
|
xml = self.class.get("#{api_prefix}#{query_string}#{extra_params_to_query(add_to_query)}")
|
61
|
-
raise Exception.new(xml.parsed_response["error"]["message"]) if xml.response.code != 200
|
61
|
+
raise Exception.new(xml.parsed_response["error"]["message"]) if xml.response.code != '200'
|
62
62
|
rescue Exception => e
|
63
63
|
Rails.logger.debug { "Muvandy Gem Error: #{e.message}" }
|
64
64
|
end
|
@@ -72,7 +72,7 @@ module Muvandy
|
|
72
72
|
end
|
73
73
|
begin
|
74
74
|
xml = self.class.post("#{api_prefix}#{query_string}", :query => query.merge!(:visitor_key => @visitor_key)) # #{extra_params_to_query(add_to_query)}
|
75
|
-
raise Exception.new(xml.parsed_response["error"]["message"]) if xml.response.code != 200
|
75
|
+
raise Exception.new(xml.parsed_response["error"]["message"]) if xml.response.code != '200'
|
76
76
|
rescue Exception => e
|
77
77
|
Rails.logger.debug { "Muvandy Gem Error: #{e.message}" }
|
78
78
|
end
|
data/lib/muvandy/version.rb
CHANGED
data/lib/muvandy.rb
CHANGED
@@ -3,36 +3,36 @@ require "muvandy/version"
|
|
3
3
|
require "muvandy/muvandy"
|
4
4
|
|
5
5
|
module Muvandy
|
6
|
-
|
7
|
-
|
8
|
-
base.send(:include, ClassMethods)
|
9
|
-
end
|
10
|
-
|
11
|
-
module ClassMethods
|
6
|
+
def collect_muvandy_visitor_info
|
7
|
+
Muvandy.mode = params[:mode]
|
12
8
|
|
13
|
-
|
14
|
-
|
15
|
-
Muvandy.utm_term = params[:utm_term]
|
16
|
-
Muvandy.utm_campaign = params[:utm_campaign]
|
17
|
-
Muvandy.utm_source = params[:utm_source]
|
18
|
-
Muvandy.utm_medium = params[:utm_medium]
|
19
|
-
|
20
|
-
Muvandy.referrer = request.referrer
|
21
|
-
end
|
22
|
-
|
23
|
-
end
|
24
|
-
|
25
|
-
class << self
|
9
|
+
cookies[:muvandy_utm_term] = params[:utm_term] if cookies[:muvandy_utm_term].blank? || (!params[:utm_term].blank? && cookies[:muvandy_utm_term] != params[:utm_term])
|
10
|
+
Muvandy.utm_term = cookies[:muvandy_utm_term] unless cookies[:muvandy_utm_term].blank?
|
26
11
|
|
12
|
+
cookies[:muvandy_utm_campaign] = params[:utm_campaign] if cookies[:muvandy_utm_campaign].blank? || (!params[:utm_campaign].blank? && cookies[:muvandy_utm_campaign] != params[:utm_campaign])
|
13
|
+
Muvandy.utm_campaign = cookies[:muvandy_utm_campaign] unless cookies[:muvandy_utm_campaign].blank?
|
14
|
+
|
15
|
+
cookies[:muvandy_utm_source] = params[:utm_source] if cookies[:muvandy_utm_source].blank? || (!params[:utm_source].blank? && cookies[:muvandy_utm_source] != params[:utm_source])
|
16
|
+
Muvandy.utm_source = cookies[:muvandy_utm_source] unless cookies[:muvandy_utm_source].blank?
|
17
|
+
|
18
|
+
cookies[:muvandy_utm_medium] = params[:utm_medium] if cookies[:muvandy_utm_medium].blank? || (!params[:utm_medium].blank? && cookies[:muvandy_utm_medium] != params[:utm_medium])
|
19
|
+
Muvandy.utm_medium = cookies[:muvandy_utm_medium] unless cookies[:muvandy_utm_medium].blank?
|
20
|
+
|
21
|
+
cookies[:muvandy_referrer] = request.referrer if cookies[:muvandy_referrer].blank? || (cookies[:muvandy_referrer] != request.referrer)
|
22
|
+
Muvandy.referrer = cookies[:muvandy_referrer] unless cookies[:muvandy_referrer].blank?
|
23
|
+
end
|
24
|
+
|
25
|
+
class << self
|
27
26
|
attr_accessor :api_key, :site
|
28
27
|
|
29
28
|
def configure
|
30
|
-
yield self
|
31
|
-
|
29
|
+
yield self
|
32
30
|
Muvandy.api_key = api_key
|
33
31
|
Muvandy.site = (site.nil?) ? 'http://muvandy.com' : site
|
34
32
|
end
|
35
33
|
|
34
|
+
def included(base)
|
35
|
+
base.before_filter :collect_muvandy_visitor_info
|
36
|
+
end
|
36
37
|
end
|
37
|
-
|
38
38
|
end
|
metadata
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: muvandy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
5
|
-
prerelease:
|
4
|
+
version: 1.2a1
|
5
|
+
prerelease: 3
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Aldwin Ibuna
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-05-08 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: httparty
|
16
|
-
requirement: &
|
16
|
+
requirement: &70119528830660 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0.8'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70119528830660
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: versionomy
|
27
|
-
requirement: &
|
27
|
+
requirement: &70119528827140 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: 0.4.3
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70119528827140
|
36
36
|
description: Client for Muvandy API
|
37
37
|
email:
|
38
38
|
- aibuna@gmail.com
|