web_analytics_discovery 2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,3 @@
1
+ module WebAnalyticsDiscovery
2
+ VERSION = '2.0'
3
+ end
@@ -0,0 +1,13 @@
1
+ require 'spec_helper'
2
+
3
+ describe Alexa do
4
+ it 'should parse alexa.com with certified metrics' do
5
+ res = Alexa.new.run('http://alexa.com/')
6
+ res[:id].should == 'alexa.com'
7
+
8
+ res[:visitors_day].should_not be_nil
9
+ res[:pv_day].should_not be_nil
10
+ res[:visitors_mon].should_not be_nil
11
+ res[:pv_mon].should_not be_nil
12
+ end
13
+ end
@@ -0,0 +1,15 @@
1
+ require 'spec_helper'
2
+
3
+ describe LiveInternet do
4
+ it 'should parse utro.ru' do
5
+ res = LiveInternet.new.run('http://utro.ru/')
6
+ res[:id].should == 'utro.ru'
7
+ full_result_check(res)
8
+ end
9
+
10
+ it 'should parse gazeta.ru' do
11
+ res = LiveInternet.new.run('http://gazeta.ru/')
12
+ res[:id].should == 'gazeta_all'
13
+ full_result_check(res)
14
+ end
15
+ end
@@ -0,0 +1,36 @@
1
+ require 'spec_helper'
2
+
3
+ def check_mailru(res)
4
+ res[:visitors_day].should_not be_nil
5
+ res[:visitors_day].should be_an(Integer)
6
+ res[:pv_day].should_not be_nil
7
+ res[:pv_day].should be_an(Integer)
8
+
9
+ res[:visitors_week].should_not be_nil
10
+ res[:visitors_week].should be_an(Integer)
11
+ res[:pv_week].should_not be_nil
12
+ res[:pv_week].should be_an(Integer)
13
+
14
+ res[:visitors_mon].should_not be_nil
15
+ res[:visitors_mon].should be_an(Integer)
16
+ res[:pv_mon].should_not be_nil
17
+ res[:pv_mon].should be_an(Integer)
18
+ end
19
+
20
+ describe MailRu do
21
+ it 'should parse bash.im' do
22
+ res = MailRu.new.run('http://bash.im/')
23
+ res[:id].should == 901403
24
+ check_mailru(res)
25
+ end
26
+ it 'should parse lady.mail.ru' do
27
+ res = MailRu.new.run('http://lady.mail.ru/')
28
+ res[:id].should == 1018953
29
+ check_mailru(res)
30
+ end
31
+ it 'should parse lib.ru' do
32
+ res = MailRu.new.run('http://lib.ru/')
33
+ res[:id].should == 105282
34
+ check_mailru(res)
35
+ end
36
+ end
@@ -0,0 +1,24 @@
1
+ require 'spec_helper'
2
+
3
+ def check_openstat(res)
4
+ res[:visitors_day].should_not be_nil
5
+ res[:visits_day].should_not be_nil
6
+ res[:pv_day].should_not be_nil
7
+
8
+ res[:visitors_mon].should_not be_nil
9
+ res[:visits_mon].should_not be_nil
10
+ res[:pv_mon].should_not be_nil
11
+ end
12
+
13
+ describe Openstat do
14
+ it 'should parse utro.ru' do
15
+ res = Openstat.new.run('http://utro.ru/')
16
+ res[:id].should == 13838
17
+ check_openstat(res)
18
+ end
19
+ it 'should parse lib.ru' do
20
+ res = Openstat.new.run('http://lib.ru/')
21
+ res[:id].should == 8369
22
+ check_openstat(res)
23
+ end
24
+ end
@@ -0,0 +1,59 @@
1
+ require 'spec_helper'
2
+
3
+ def check_mailru(res)
4
+ res[:visitors_day].should_not be_nil
5
+ res[:visitors_day].should be_an(Integer)
6
+ res[:pv_day].should_not be_nil
7
+ res[:pv_day].should be_an(Integer)
8
+
9
+ res[:visitors_week].should_not be_nil
10
+ res[:visitors_week].should be_an(Integer)
11
+ res[:pv_week].should_not be_nil
12
+ res[:pv_week].should be_an(Integer)
13
+
14
+ res[:visitors_mon].should_not be_nil
15
+ res[:visitors_mon].should be_an(Integer)
16
+ res[:pv_mon].should_not be_nil
17
+ res[:pv_mon].should be_an(Integer)
18
+ end
19
+
20
+ describe Quantcast do
21
+ it 'should parse linkedin.com directly' do
22
+ res = Quantcast.new.run('http://linkedin.com/')
23
+ res[:id].should == 'wd:com.linkedin'
24
+
25
+ res[:visitors_day].should_not be_nil
26
+ res[:visitors_day].should be_an(Integer)
27
+ res[:visits_day].should_not be_nil
28
+ res[:visits_day].should be_an(Integer)
29
+ res[:pv_day].should_not be_nil
30
+ res[:pv_day].should be_an(Integer)
31
+
32
+ res[:visitors_week].should_not be_nil
33
+ res[:visitors_week].should be_an(Integer)
34
+ res[:visits_week].should_not be_nil
35
+ res[:visits_week].should be_an(Integer)
36
+ res[:pv_week].should_not be_nil
37
+ res[:pv_week].should be_an(Integer)
38
+
39
+ res[:visitors_mon].should_not be_nil
40
+ res[:visitors_mon].should be_an(Integer)
41
+ res[:visits_mon].should_not be_nil
42
+ res[:visits_mon].should be_an(Integer)
43
+ res[:pv_mon].should_not be_nil
44
+ res[:pv_mon].should be_an(Integer)
45
+
46
+ (res[:pv_week].to_f / res[:pv_day]).should be_between(6, 8)
47
+ (res[:pv_mon].to_f / res[:pv_day]).should be_between(25, 35)
48
+
49
+ (res[:visits_week].to_f / res[:visits_day]).should be_between(6, 8)
50
+ (res[:visits_mon].to_f / res[:visits_day]).should be_between(25, 35)
51
+ end
52
+ it 'should parse yahoo.com indirectly' do
53
+ res = Quantcast.new.run('http://yahoo.com/')
54
+ res[:id].should == 'wd:com.yahoo'
55
+
56
+ res[:visitors_mon].should_not be_nil
57
+ res[:visitors_mon].should be_an(Integer)
58
+ end
59
+ end
@@ -0,0 +1,63 @@
1
+ require 'spec_helper'
2
+
3
+ describe Rambler do
4
+ it 'should properly find yesterday' do
5
+ Rambler.new.spec_yesterday(Time.new(2013, 7, 13)).should == '12.07.2013'
6
+ Rambler.new.spec_yesterday(Time.new(2013, 1, 1)).should == '31.12.2012'
7
+ Rambler.new.spec_yesterday(Time.new(2012, 3, 1)).should == '29.02.2012'
8
+ end
9
+ it 'should properly find last week' do
10
+ Rambler.new.spec_last_week(Time.new(2013, 7, 13)).should == '01.07.2013+-+07.07.2013'
11
+ Rambler.new.spec_last_week(Time.new(2013, 7, 14)).should == '01.07.2013+-+07.07.2013'
12
+ Rambler.new.spec_last_week(Time.new(2013, 7, 15)).should == '08.07.2013+-+14.07.2013'
13
+ Rambler.new.spec_last_week(Time.new(2013, 7, 16)).should == '08.07.2013+-+14.07.2013'
14
+ Rambler.new.spec_last_week(Time.new(2013, 7, 16)).should == '08.07.2013+-+14.07.2013'
15
+ end
16
+ it 'should properly find last month' do
17
+ Rambler.new.spec_last_month(Time.new(2013, 7, 13)).should == '01.06.2013+-+30.06.2013'
18
+ Rambler.new.spec_last_month(Time.new(2013, 7, 1)).should == '01.06.2013+-+30.06.2013'
19
+ Rambler.new.spec_last_month(Time.new(2013, 7, 2)).should == '01.06.2013+-+30.06.2013'
20
+ Rambler.new.spec_last_month(Time.new(2013, 6, 30)).should == '01.05.2013+-+31.05.2013'
21
+ Rambler.new.spec_last_month(Time.new(2013, 6, 1)).should == '01.05.2013+-+31.05.2013'
22
+ Rambler.new.spec_last_month(Time.new(2013, 5, 31)).should == '01.04.2013+-+30.04.2013'
23
+ Rambler.new.spec_last_month(Time.new(2012, 3, 3)).should == '01.02.2012+-+29.02.2012'
24
+ end
25
+ it 'should parse livejournal.com' do
26
+ res = Rambler.new.run('http://www.livejournal.com/')
27
+ full_result_check(res)
28
+ res[:id].should == 1111412
29
+ end
30
+ it 'should parse sport.ru' do
31
+ # Hidden statistics site, information is available only from rating, no session info available
32
+ res = Rambler.new.run('http://sport.ru/')
33
+
34
+ res.should_not be_nil
35
+
36
+ res[:id].should == 327694
37
+
38
+ res[:visitors_day].should_not be_nil
39
+ res[:pv_day].should_not be_nil
40
+
41
+ res[:visitors_week].should_not be_nil
42
+ res[:pv_week].should_not be_nil
43
+
44
+ res[:visitors_mon].should_not be_nil
45
+ res[:pv_mon].should_not be_nil
46
+ end
47
+ it 'should parse ridus.ru' do
48
+ res = Rambler.new.run('http://ridus.ru/')
49
+
50
+ res.should_not be_nil
51
+
52
+ res[:id].should == 2564083
53
+
54
+ res[:visitors_day].should_not be_nil
55
+ res[:pv_day].should_not be_nil
56
+
57
+ res[:visitors_week].should_not be_nil
58
+ res[:pv_week].should_not be_nil
59
+
60
+ res[:visitors_mon].should_not be_nil
61
+ res[:pv_mon].should_not be_nil
62
+ end
63
+ end
@@ -0,0 +1,25 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+
4
+ require 'web_analytics_discovery'
5
+ include WebAnalyticsDiscovery
6
+
7
+ RSpec.configure { |config|
8
+ # some (optional) config here
9
+ }
10
+
11
+ def full_result_check(res)
12
+ res.should_not be_nil
13
+
14
+ res[:visitors_day].should_not be_nil
15
+ res[:visits_day].should_not be_nil
16
+ res[:pv_day].should_not be_nil
17
+
18
+ res[:visitors_week].should_not be_nil
19
+ res[:visits_week].should_not be_nil
20
+ res[:pv_week].should_not be_nil
21
+
22
+ res[:visitors_mon].should_not be_nil
23
+ res[:visits_mon].should_not be_nil
24
+ res[:pv_mon].should_not be_nil
25
+ end
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+
3
+ describe TNS do
4
+ it 'should parse rbc.ru' do
5
+ res = TNS.new.run('http://rbc.ru/')
6
+ res.should_not be_nil
7
+ res[:id].should == 'rbc.ru'
8
+
9
+ res[:visitors_mon].should_not be_nil
10
+ res[:visitors_mon].should be_an(Integer)
11
+ end
12
+
13
+ it 'should parse mamba.ru (mangled ID)' do
14
+ res = TNS.new.run('http://mamba.ru/')
15
+ res.should_not be_nil
16
+ res[:id].should == 'mamba.ru'
17
+
18
+ res[:visitors_mon].should_not be_nil
19
+ res[:visitors_mon].should be_an(Integer)
20
+ end
21
+ end
@@ -0,0 +1,50 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require File.expand_path("../lib/web_analytics_discovery/version", __FILE__)
4
+ require 'date'
5
+
6
+ Gem::Specification.new { |s|
7
+ s.name = 'web_analytics_discovery'
8
+ s.version = WebAnalyticsDiscovery::VERSION
9
+ s.date = Date.today.to_s
10
+
11
+ s.authors = ['Mikhail Yakshin']
12
+ s.email = 'greycat.na.kor@gmail.com'
13
+
14
+ s.homepage = 'https://github.com/GreyCat/web_analytics_discovery'
15
+ s.summary = 'Get web analytics data (site audience, visitors, pageviews) for any given website from a wide array of popular web analytics tools'
16
+ s.license = 'AGPL'
17
+ s.description = <<-EOF
18
+ Web Analytics Discovery is a library and command line tool to quickly
19
+ get valuable web analytics insights for any given website (for
20
+ example, number of unique visitors, number of pageviews per day or per
21
+ month).
22
+
23
+ It works by analyzing site pages, finding snippets of popular web
24
+ analytics systems there, extracting their IDs and then automatically
25
+ querying that systems for publically available data.
26
+
27
+ The supported web analytics systems are:
28
+
29
+ * Alexa
30
+ * Google Analytics
31
+ * LiveInternet
32
+ * Mail.ru
33
+ * Openstat
34
+ * Quantcast
35
+ * Rambler Top100
36
+ * Yandex Metrika
37
+ EOF
38
+
39
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
40
+ s.require_paths = ['lib']
41
+
42
+ s.files = `git ls-files`.split("\n")
43
+ s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
44
+ s.test_files = s.files.grep(%r{^(test|spec|features)/})
45
+
46
+ s.add_development_dependency "bundler", "~> 1.3"
47
+ s.add_development_dependency 'rake', '~> 10'
48
+ s.add_development_dependency 'rspec', '~> 3'
49
+ s.add_development_dependency 'json', '~> 1.8'
50
+ }
metadata ADDED
@@ -0,0 +1,158 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: web_analytics_discovery
3
+ version: !ruby/object:Gem::Version
4
+ version: '2.0'
5
+ platform: ruby
6
+ authors:
7
+ - Mikhail Yakshin
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-10-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: json
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.8'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.8'
69
+ description: |
70
+ Web Analytics Discovery is a library and command line tool to quickly
71
+ get valuable web analytics insights for any given website (for
72
+ example, number of unique visitors, number of pageviews per day or per
73
+ month).
74
+
75
+ It works by analyzing site pages, finding snippets of popular web
76
+ analytics systems there, extracting their IDs and then automatically
77
+ querying that systems for publically available data.
78
+
79
+ The supported web analytics systems are:
80
+
81
+ * Alexa
82
+ * Google Analytics
83
+ * LiveInternet
84
+ * Mail.ru
85
+ * Openstat
86
+ * Quantcast
87
+ * Rambler Top100
88
+ * Yandex Metrika
89
+ email: greycat.na.kor@gmail.com
90
+ executables:
91
+ - web_analytics_discover
92
+ extensions: []
93
+ extra_rdoc_files: []
94
+ files:
95
+ - ".gitignore"
96
+ - ".rspec"
97
+ - ".travis.yml"
98
+ - Gemfile
99
+ - LICENSE
100
+ - README.md
101
+ - Rakefile
102
+ - bin/web_analytics_discover
103
+ - lib/web_analytics_discovery.rb
104
+ - lib/web_analytics_discovery/grabber/alexa.rb
105
+ - lib/web_analytics_discovery/grabber/googleanalytics.rb
106
+ - lib/web_analytics_discovery/grabber/liveinternet.rb
107
+ - lib/web_analytics_discovery/grabber/mailru.rb
108
+ - lib/web_analytics_discovery/grabber/openstat.rb
109
+ - lib/web_analytics_discovery/grabber/quantcast.rb
110
+ - lib/web_analytics_discovery/grabber/rambler.rb
111
+ - lib/web_analytics_discovery/grabber/tns.rb
112
+ - lib/web_analytics_discovery/grabber/yandexmetrika.rb
113
+ - lib/web_analytics_discovery/grabberutils.rb
114
+ - lib/web_analytics_discovery/version.rb
115
+ - spec/alexa_spec.rb
116
+ - spec/liveinternet_spec.rb
117
+ - spec/mailru_spec.rb
118
+ - spec/openstat_spec.rb
119
+ - spec/quantcast_spec.rb
120
+ - spec/rambler_spec.rb
121
+ - spec/spec_helper.rb
122
+ - spec/tns_spec.rb
123
+ - web_analytics_discovery.gemspec
124
+ homepage: https://github.com/GreyCat/web_analytics_discovery
125
+ licenses:
126
+ - AGPL
127
+ metadata: {}
128
+ post_install_message:
129
+ rdoc_options: []
130
+ require_paths:
131
+ - lib
132
+ required_ruby_version: !ruby/object:Gem::Requirement
133
+ requirements:
134
+ - - ">="
135
+ - !ruby/object:Gem::Version
136
+ version: '0'
137
+ required_rubygems_version: !ruby/object:Gem::Requirement
138
+ requirements:
139
+ - - ">="
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
+ requirements: []
143
+ rubyforge_project:
144
+ rubygems_version: 2.2.2
145
+ signing_key:
146
+ specification_version: 4
147
+ summary: Get web analytics data (site audience, visitors, pageviews) for any given
148
+ website from a wide array of popular web analytics tools
149
+ test_files:
150
+ - spec/alexa_spec.rb
151
+ - spec/liveinternet_spec.rb
152
+ - spec/mailru_spec.rb
153
+ - spec/openstat_spec.rb
154
+ - spec/quantcast_spec.rb
155
+ - spec/rambler_spec.rb
156
+ - spec/spec_helper.rb
157
+ - spec/tns_spec.rb
158
+ has_rdoc: