patient_zero 0.5.2 → 0.5.3
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 59aa916f1590ba751b0b050dfa280aa3ebee6f3e
|
4
|
+
data.tar.gz: 0ce2b9f49f60014408c7ea68b9c15a210baea24c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 63539b115d587743db6646af44bae7fdaaca293548ddf7e74bcf92a889b3afa6e8ace9147edc3d3782f2427da3a1d900bf3890e39171148ac7a39d7d42a83e25
|
7
|
+
data.tar.gz: 4c0d0ad475c63d19f09030b9592693a6170dd838dd15aad9765a30cf2dc5a3ca6c4af66964cb3eeaa418cf44f2c44d35eed7dc5dccee1ca6a8c89d4465b90e96
|
@@ -6,7 +6,7 @@ module PatientZero
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def impressions
|
9
|
-
@impressions ||=
|
9
|
+
@impressions ||= total_page_impressions + message_impressions
|
10
10
|
end
|
11
11
|
|
12
12
|
def reach
|
@@ -32,6 +32,22 @@ module PatientZero
|
|
32
32
|
unknown: gender_stats.fetch('U', 0) }
|
33
33
|
end
|
34
34
|
|
35
|
+
def organic_posts
|
36
|
+
find_impressions 'Organic'
|
37
|
+
end
|
38
|
+
|
39
|
+
def promoted_posts
|
40
|
+
find_impressions 'Paid'
|
41
|
+
end
|
42
|
+
|
43
|
+
def likes
|
44
|
+
analytical_data['total_likes'].to_i
|
45
|
+
end
|
46
|
+
|
47
|
+
def total_comments
|
48
|
+
messages.sum { |message| message.data['comments'] }
|
49
|
+
end
|
50
|
+
|
35
51
|
private
|
36
52
|
|
37
53
|
def message_impressions
|
@@ -39,8 +55,16 @@ module PatientZero
|
|
39
55
|
end
|
40
56
|
|
41
57
|
def page_impressions
|
42
|
-
analytical_data['page_impressions']
|
43
|
-
|
58
|
+
analytical_data['page_impressions']
|
59
|
+
end
|
60
|
+
|
61
|
+
def total_page_impressions
|
62
|
+
find_impressions 'Total'
|
63
|
+
end
|
64
|
+
|
65
|
+
def find_impressions type
|
66
|
+
page_impressions.find do |impressions_hash|
|
67
|
+
impressions_hash['key'] == type
|
44
68
|
end['values'].each_value.reduce(:+)
|
45
69
|
end
|
46
70
|
end
|
@@ -12,6 +12,14 @@ module PatientZero
|
|
12
12
|
def reach
|
13
13
|
@reach ||= (0.12 * analytical_data['followers'].to_i).round
|
14
14
|
end
|
15
|
+
|
16
|
+
def followers
|
17
|
+
analytical_data['followers'].to_i
|
18
|
+
end
|
19
|
+
|
20
|
+
def likes
|
21
|
+
analytical_data['total_favorites'].to_i
|
22
|
+
end
|
15
23
|
end
|
16
24
|
end
|
17
25
|
end
|
data/lib/patient_zero/version.rb
CHANGED
@@ -15,7 +15,11 @@ module PatientZero
|
|
15
15
|
'clicks' => 38 }
|
16
16
|
end
|
17
17
|
let(:messages) { [ message ] }
|
18
|
-
let(:page_impressions)
|
18
|
+
let(:page_impressions) do
|
19
|
+
[ { 'key'=>'Total', 'values'=> { '2010-10-10'=> 99 }},
|
20
|
+
{ 'key'=>'Organic', 'values'=> { '2010-10-10'=> 100 }},
|
21
|
+
{ 'key'=>'Paid', 'values'=> { '2010-10-10'=> 101 }}]
|
22
|
+
end
|
19
23
|
let(:impressions_by_city) { [{"title"=>"Atlanta, GA", "count"=>16_000}, {"title"=>"Los Angeles, CA", "count"=>15_000}, {"title"=>"San Diego, CA", "count"=>14_000}] }
|
20
24
|
let(:impressions_by_age) { [{"key"=>"Users", "values"=>age_data}] }
|
21
25
|
let(:impressions_by_gender) { {"F"=>100_000, "M"=>70_000, "U"=>10_000} }
|
@@ -76,6 +80,18 @@ module PatientZero
|
|
76
80
|
expect(facebook_analytics.reach).to eq 4567
|
77
81
|
end
|
78
82
|
end
|
83
|
+
|
84
|
+
describe '#organic_posts' do
|
85
|
+
it 'returns the sum of organic_posts' do
|
86
|
+
expect(facebook_analytics.organic_posts).to eq 100
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
describe '#promoted_posts' do
|
91
|
+
it 'returns the sum of promoted_posts' do
|
92
|
+
expect(facebook_analytics.promoted_posts).to eq 101
|
93
|
+
end
|
94
|
+
end
|
79
95
|
end
|
80
96
|
end
|
81
97
|
end
|
@@ -32,10 +32,16 @@ module PatientZero
|
|
32
32
|
end
|
33
33
|
|
34
34
|
describe '#reach' do
|
35
|
-
it 'returns 12% of the number of
|
35
|
+
it 'returns 12% of the number of followers, rounded to the nearest whole' do
|
36
36
|
expect(twitter_analytics.reach).to eq (followers * 0.12).round
|
37
37
|
end
|
38
38
|
end
|
39
|
+
|
40
|
+
describe '#followers' do
|
41
|
+
it 'returns the number of followers from the analytical_data hash' do
|
42
|
+
expect(twitter_analytics.followers).to eq followers
|
43
|
+
end
|
44
|
+
end
|
39
45
|
end
|
40
46
|
end
|
41
47
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: patient_zero
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Zaninovich
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-05-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|