muvandy 1.2.1a1 → 1.2.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 +2 -2
- data/lib/muvandy/muvandy.rb +79 -77
- data/lib/muvandy/version.rb +1 -1
- metadata +6 -6
data/README.md
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
# Muvandy
|
2
2
|
|
3
|
-
Client for [Muvandy API](http://muvandy.com)
|
3
|
+
Client for [Muvandy API](http://www.muvandy.com)
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
7
7
|
Add this line to your application's Gemfile:
|
8
8
|
|
9
|
-
gem 'muvandy', '~> 1.2a1'
|
9
|
+
gem 'muvandy', '~> 1.2.2a1'
|
10
10
|
|
11
11
|
And then execute:
|
12
12
|
|
data/lib/muvandy/muvandy.rb
CHANGED
@@ -9,6 +9,7 @@ module Muvandy
|
|
9
9
|
throw Exception.new("No given Experiment ID") if experiment_id.nil?
|
10
10
|
|
11
11
|
@visitor_key = options[:visitor_key] if !options[:visitor_key].blank?
|
12
|
+
@segment_name = options[:segment_by] if !options[:segment_by].blank?
|
12
13
|
|
13
14
|
# For HTTParty
|
14
15
|
self.class.base_uri Muvandy.site
|
@@ -27,82 +28,8 @@ module Muvandy
|
|
27
28
|
|
28
29
|
def convert!(value=nil)
|
29
30
|
value = 50 if value.blank?
|
30
|
-
post(:convert, :value => value)
|
31
|
-
end
|
32
|
-
|
33
|
-
private
|
34
|
-
|
35
|
-
def get_all_variable_variations
|
36
|
-
@variable_variations = {}
|
37
|
-
begin
|
38
|
-
xml = get(:variable_variations)
|
39
|
-
# Rails.logger.debug { "DEBUG ------------ #{xml.parsed_response.inspect}" }
|
40
|
-
if xml.parsed_response && !xml.parsed_response["visitor"].blank?
|
41
|
-
# self.id = xml.parsed_response["visitor"]["id"].to_i if !xml.parsed_response["visitor"].blank? && !xml.parsed_response["visitor"]["id"].blank?
|
42
|
-
xml.parsed_response["visitor"]["variable_variations"]["variable"].each do |v|
|
43
|
-
@variable_variations[v["key"]] = v["value"]
|
44
|
-
end
|
45
|
-
end
|
46
|
-
rescue
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
def api_prefix
|
51
|
-
"/api/v#{Versionomy.parse(VERSION).major}"
|
52
|
-
end
|
53
|
-
|
54
|
-
def get(action, add_to_query={})
|
55
|
-
query_string = case action
|
56
|
-
when :variable_variations
|
57
|
-
"/experiments/#{@experiment_id}/visitors/variable_variations.xml"
|
58
|
-
end
|
59
|
-
begin
|
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'
|
62
|
-
rescue Exception => e
|
63
|
-
Rails.logger.debug { "Muvandy Gem Error: #{e.message}" }
|
64
|
-
end
|
65
|
-
xml
|
66
|
-
end
|
67
|
-
|
68
|
-
def post(action, query={} )
|
69
|
-
query_string = case action
|
70
|
-
when :convert
|
71
|
-
"/experiments/#{@experiment_id}/visitors/convert.xml"
|
72
|
-
end
|
73
|
-
begin
|
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'
|
76
|
-
rescue Exception => e
|
77
|
-
Rails.logger.debug { "Muvandy Gem Error: #{e.message}" }
|
78
|
-
end
|
79
|
-
xml
|
80
|
-
end
|
81
|
-
|
82
|
-
def valid_params
|
83
|
-
[ :mode, :visitor_key, :value, :referrer, :utm_term, :utm_campaign, :utm_source, :utm_medium ]
|
84
|
-
end
|
85
|
-
|
86
|
-
def gather_extra_params
|
87
|
-
@extra_params = {}
|
88
|
-
@extra_params[:mode] = Muvandy.mode unless Muvandy.mode.blank?
|
89
|
-
@extra_params[:utm_term] = Muvandy.utm_term unless Muvandy.utm_term.blank?
|
90
|
-
@extra_params[:utm_campaign] = Muvandy.utm_campaign unless Muvandy.utm_campaign.blank?
|
91
|
-
@extra_params[:utm_source] = Muvandy.utm_source unless Muvandy.utm_source.blank?
|
92
|
-
@extra_params[:utm_medium] = Muvandy.utm_medium unless Muvandy.utm_medium.blank?
|
93
|
-
@extra_params[:visitor_key] = @visitor_key unless @visitor_key.blank? #Muvandy.visitor_key.blank?
|
94
|
-
@extra_params[:referrer] = Muvandy.referrer unless Muvandy.referrer.blank?
|
95
|
-
end
|
96
|
-
|
97
|
-
def extra_params_to_query(add_to_query={})
|
98
|
-
return '' if @extra_params.blank?
|
99
31
|
|
100
|
-
|
101
|
-
params = @extra_params.merge(add_to_query)
|
102
|
-
valid_params.each do |key|
|
103
|
-
query << "#{key}=#{params[key]}" unless params[key].blank?
|
104
|
-
end
|
105
|
-
(query.empty?) ? '' : "?#{query.join('&')}"
|
32
|
+
post(:convert, :value => value )
|
106
33
|
end
|
107
34
|
|
108
35
|
class << self
|
@@ -119,9 +46,84 @@ module Muvandy
|
|
119
46
|
def convert(experiment_id, options={})
|
120
47
|
muvandy = Muvandy.new(experiment_id, options.merge(:skip_variations => true))
|
121
48
|
muvandy.convert!(options[:value])
|
122
|
-
end
|
123
|
-
|
49
|
+
end
|
124
50
|
end
|
125
51
|
|
52
|
+
private
|
53
|
+
|
54
|
+
def get_all_variable_variations
|
55
|
+
@variable_variations = {}
|
56
|
+
begin
|
57
|
+
xml = get(:variable_variations)
|
58
|
+
# Rails.logger.debug { "DEBUG ------------ #{xml.parsed_response.inspect}" }
|
59
|
+
if xml.parsed_response && !xml.parsed_response["visitor"].blank?
|
60
|
+
# self.id = xml.parsed_response["visitor"]["id"].to_i if !xml.parsed_response["visitor"].blank? && !xml.parsed_response["visitor"]["id"].blank?
|
61
|
+
xml.parsed_response["visitor"]["variable_variations"]["variable"].each do |v|
|
62
|
+
@variable_variations[v["key"]] = v["value"]
|
63
|
+
end
|
64
|
+
end
|
65
|
+
rescue
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def api_prefix
|
70
|
+
"/api/v#{Versionomy.parse(VERSION).major}"
|
71
|
+
end
|
72
|
+
|
73
|
+
def get(action, add_to_query={})
|
74
|
+
query_string = case action
|
75
|
+
when :variable_variations
|
76
|
+
"/experiments/#{@experiment_id}/visitors/variable_variations.xml"
|
77
|
+
end
|
78
|
+
begin
|
79
|
+
Rails.logger.debug { "Mubandy DEBUG: #{extra_params_to_query(add_to_query)}" }
|
80
|
+
xml = self.class.get("#{api_prefix}#{query_string}#{extra_params_to_query(add_to_query)}")
|
81
|
+
raise Exception.new(xml.parsed_response["error"]["message"]) if xml.response.code != '200'
|
82
|
+
rescue Exception => e
|
83
|
+
Rails.logger.debug { "Muvandy Gem Error: #{e.message}" }
|
84
|
+
end
|
85
|
+
xml
|
86
|
+
end
|
87
|
+
|
88
|
+
def post(action, query={} )
|
89
|
+
query_string = case action
|
90
|
+
when :convert
|
91
|
+
"/experiments/#{@experiment_id}/visitors/convert.xml"
|
92
|
+
end
|
93
|
+
begin
|
94
|
+
xml = self.class.post("#{api_prefix}#{query_string}", :query => query.merge!(:visitor_key => @visitor_key).merge!(@extra_params)) # #{extra_params_to_query(add_to_query)}
|
95
|
+
raise Exception.new(xml.parsed_response["error"]["message"]) if xml.response.code != '200'
|
96
|
+
rescue Exception => e
|
97
|
+
Rails.logger.debug { "Muvandy Gem Error: #{e.message}" }
|
98
|
+
end
|
99
|
+
xml
|
100
|
+
end
|
101
|
+
|
102
|
+
def valid_params
|
103
|
+
[ :mode, :visitor_key, :value, :referrer, :utm_term, :utm_campaign, :utm_source, :utm_medium, :segment_name ]
|
104
|
+
end
|
105
|
+
|
106
|
+
def gather_extra_params
|
107
|
+
@extra_params = {}
|
108
|
+
@extra_params[:mode] = Muvandy.mode unless Muvandy.mode.blank?
|
109
|
+
@extra_params[:utm_term] = Muvandy.utm_term unless Muvandy.utm_term.blank?
|
110
|
+
@extra_params[:utm_campaign] = Muvandy.utm_campaign unless Muvandy.utm_campaign.blank?
|
111
|
+
@extra_params[:utm_source] = Muvandy.utm_source unless Muvandy.utm_source.blank?
|
112
|
+
@extra_params[:utm_medium] = Muvandy.utm_medium unless Muvandy.utm_medium.blank?
|
113
|
+
@extra_params[:visitor_key] = @visitor_key unless @visitor_key.blank? #Muvandy.visitor_key.blank?
|
114
|
+
@extra_params[:referrer] = Muvandy.referrer unless Muvandy.referrer.blank?
|
115
|
+
@extra_params[:segment_name] = @segment_name unless @segment_name.blank?
|
116
|
+
end
|
117
|
+
|
118
|
+
def extra_params_to_query(add_to_query={})
|
119
|
+
return '' if @extra_params.blank?
|
120
|
+
|
121
|
+
query = []
|
122
|
+
params = @extra_params.merge(add_to_query)
|
123
|
+
valid_params.each do |key|
|
124
|
+
query << "#{key}=#{params[key]}" unless params[key].blank?
|
125
|
+
end
|
126
|
+
(query.empty?) ? '' : "?#{query.join('&')}"
|
127
|
+
end
|
126
128
|
end
|
127
129
|
end
|
data/lib/muvandy/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: muvandy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.2a1
|
5
5
|
prerelease: 5
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-05-
|
12
|
+
date: 2012-05-13 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: httparty
|
16
|
-
requirement: &
|
16
|
+
requirement: &70332539720100 !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: *70332539720100
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: versionomy
|
27
|
-
requirement: &
|
27
|
+
requirement: &70332539717400 !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: *70332539717400
|
36
36
|
description: Client for Muvandy API
|
37
37
|
email:
|
38
38
|
- aibuna@gmail.com
|