metrika 0.0.2 → 0.0.3
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 +13 -0
- data/VERSION +1 -1
- data/lib/metrika.rb +3 -4
- data/lib/metrika/api/methods.rb +12 -1
- data/lib/metrika/client.rb +5 -3
- data/lib/metrika/ext.rb +9 -0
- data/lib/metrika/helpers.rb +21 -0
- data/metrika.gemspec +3 -2
- metadata +4 -3
- data/lib/metrika/helpers/parser.rb +0 -11
data/README.md
CHANGED
|
@@ -3,6 +3,8 @@ Metrika
|
|
|
3
3
|
|
|
4
4
|
Wrapper for Yandex.Metrika API
|
|
5
5
|
|
|
6
|
+
Inspired by [Wynn Netherland's LinkedIn Gem](https://github.com/pengwynn/linkedin).
|
|
7
|
+
|
|
6
8
|
# Info
|
|
7
9
|
|
|
8
10
|
**Under heavy development!**
|
|
@@ -26,6 +28,17 @@ Wrapper for Yandex.Metrika API
|
|
|
26
28
|
c.delete_counter(id)
|
|
27
29
|
c.check_counter(id)
|
|
28
30
|
|
|
31
|
+
#goals
|
|
32
|
+
c.get_counter_goals(counter_id)
|
|
33
|
+
c.create_counter_goal(counter_id, params)
|
|
34
|
+
c.create_counter_goal(counter_id, params)
|
|
35
|
+
c.get_counter_goal(counter_id, id)
|
|
36
|
+
c.update_counter_goal(counter_id, id, params)
|
|
37
|
+
c.delete_counter_goal(counter_id, id)
|
|
38
|
+
|
|
39
|
+
#stats
|
|
40
|
+
c.get_counter_stat_traffic_summary(1131265, :group => :month, :date1 => Date.parse('20110925'), :date2 => Date.today)
|
|
41
|
+
|
|
29
42
|
# Object API
|
|
30
43
|
|
|
31
44
|
Later…
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.0.
|
|
1
|
+
0.0.3
|
data/lib/metrika.rb
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
METRIKA_PATH = File.dirname(__FILE__) +
|
|
1
|
+
METRIKA_PATH = File.dirname(__FILE__) + '/metrika/'
|
|
2
2
|
|
|
3
|
-
require METRIKA_PATH + 'helpers
|
|
4
|
-
require METRIKA_PATH + '
|
|
5
|
-
require METRIKA_PATH + 'helpers/request'
|
|
3
|
+
require METRIKA_PATH + 'helpers'
|
|
4
|
+
require METRIKA_PATH + 'ext'
|
|
6
5
|
|
|
7
6
|
require METRIKA_PATH + 'api/methods'
|
|
8
7
|
require METRIKA_PATH + 'client'
|
data/lib/metrika/api/methods.rb
CHANGED
|
@@ -53,7 +53,7 @@ module Metrika
|
|
|
53
53
|
end
|
|
54
54
|
|
|
55
55
|
def get_counter_goal(counter_id, id)
|
|
56
|
-
self.get(self.counter_goal_path(counter_id, id))['goal']
|
|
56
|
+
self.get(self.counter_goal_path(counter_id, id))['goal']
|
|
57
57
|
end
|
|
58
58
|
|
|
59
59
|
def update_counter_goal(counter_id, id, params)
|
|
@@ -67,6 +67,17 @@ module Metrika
|
|
|
67
67
|
def counter_goal_path(counter_id, id)
|
|
68
68
|
"/counter/#{counter_id}/goal/#{id}"
|
|
69
69
|
end
|
|
70
|
+
|
|
71
|
+
# Statistics
|
|
72
|
+
def get_counter_stat_traffic_summary(id, params = {})
|
|
73
|
+
params = self.format_params(params)
|
|
74
|
+
|
|
75
|
+
self.get(self.counter_stat_traffic_summary_path, params.merge(:id => id))
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
def counter_stat_traffic_summary_path
|
|
79
|
+
"/stat/traffic/summary"
|
|
80
|
+
end
|
|
70
81
|
end
|
|
71
82
|
end
|
|
72
83
|
end
|
data/lib/metrika/client.rb
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
module Metrika
|
|
2
2
|
class Client
|
|
3
|
-
include Helpers
|
|
4
|
-
include Helpers::Request
|
|
5
|
-
include Helpers::Parser
|
|
3
|
+
include Helpers
|
|
6
4
|
|
|
7
5
|
include Api::Methods
|
|
8
6
|
|
|
@@ -10,5 +8,9 @@ module Metrika
|
|
|
10
8
|
@application_id = application_id
|
|
11
9
|
@application_password = application_password
|
|
12
10
|
end
|
|
11
|
+
|
|
12
|
+
protected
|
|
13
|
+
|
|
14
|
+
|
|
13
15
|
end
|
|
14
16
|
end
|
data/lib/metrika/ext.rb
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
module Metrika
|
|
2
|
+
module Helpers
|
|
3
|
+
autoload :Authorization, METRIKA_PATH + "helpers/authorization"
|
|
4
|
+
autoload :Request, METRIKA_PATH + "helpers/request"
|
|
5
|
+
|
|
6
|
+
include Metrika::Helpers::Authorization
|
|
7
|
+
include Metrika::Helpers::Request
|
|
8
|
+
|
|
9
|
+
protected
|
|
10
|
+
def format_params(params)
|
|
11
|
+
params[:date1] = self.format_date(params[:date1]) if params[:date1].present?
|
|
12
|
+
params[:date2] = self.format_date(params[:date2]) if params[:date2].present?
|
|
13
|
+
|
|
14
|
+
params
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def format_date(date)
|
|
18
|
+
date.is_a?(Date) || date.is_a?(DateTime) ? date.strftime('%Y%m%d') : date
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
data/metrika.gemspec
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
Gem::Specification.new do |s|
|
|
7
7
|
s.name = "metrika"
|
|
8
|
-
s.version = "0.0.
|
|
8
|
+
s.version = "0.0.3"
|
|
9
9
|
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
11
11
|
s.authors = ["Igor Alexandrov"]
|
|
@@ -27,8 +27,9 @@ Gem::Specification.new do |s|
|
|
|
27
27
|
"lib/metrika/api/methods.rb",
|
|
28
28
|
"lib/metrika/client.rb",
|
|
29
29
|
"lib/metrika/errors.rb",
|
|
30
|
+
"lib/metrika/ext.rb",
|
|
31
|
+
"lib/metrika/helpers.rb",
|
|
30
32
|
"lib/metrika/helpers/authorization.rb",
|
|
31
|
-
"lib/metrika/helpers/parser.rb",
|
|
32
33
|
"lib/metrika/helpers/request.rb",
|
|
33
34
|
"metrika.gemspec",
|
|
34
35
|
"test/helper.rb",
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: metrika
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.3
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -126,8 +126,9 @@ files:
|
|
|
126
126
|
- lib/metrika/api/methods.rb
|
|
127
127
|
- lib/metrika/client.rb
|
|
128
128
|
- lib/metrika/errors.rb
|
|
129
|
+
- lib/metrika/ext.rb
|
|
130
|
+
- lib/metrika/helpers.rb
|
|
129
131
|
- lib/metrika/helpers/authorization.rb
|
|
130
|
-
- lib/metrika/helpers/parser.rb
|
|
131
132
|
- lib/metrika/helpers/request.rb
|
|
132
133
|
- metrika.gemspec
|
|
133
134
|
- test/helper.rb
|
|
@@ -147,7 +148,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
147
148
|
version: '0'
|
|
148
149
|
segments:
|
|
149
150
|
- 0
|
|
150
|
-
hash: -
|
|
151
|
+
hash: -3176208076306458523
|
|
151
152
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
152
153
|
none: false
|
|
153
154
|
requirements:
|