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: d17b44ae67ad5b2e363276699a2a8fe992656f1c
4
- data.tar.gz: 64251331a17c0ce70a3892310d4827fbcc4a0680
3
+ metadata.gz: 59aa916f1590ba751b0b050dfa280aa3ebee6f3e
4
+ data.tar.gz: 0ce2b9f49f60014408c7ea68b9c15a210baea24c
5
5
  SHA512:
6
- metadata.gz: b0c50246531082bd81fa56d78d6df50f5121a28042e83a34b059a93022e0790ea3cdbf52c0187b9f158148625d1dfed2c217c25d4c54f9f64b88385f804fb830
7
- data.tar.gz: 102564843acccaaab44324fcd0e1d4bfdd8187596870ce4c12f72b73ead9fed8f7d1cb038b94def060d2882c2c029486427e3bfb9af56617f20c7d1fc8bae8a7
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 ||= page_impressions + message_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'].find do |impressions_hash|
43
- impressions_hash['key'] == 'Total'
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
@@ -1,3 +1,3 @@
1
1
  module PatientZero
2
- VERSION = '0.5.2'
2
+ VERSION = '0.5.3'
3
3
  end
@@ -15,7 +15,11 @@ module PatientZero
15
15
  'clicks' => 38 }
16
16
  end
17
17
  let(:messages) { [ message ] }
18
- let(:page_impressions) { [ { 'key'=>'Total', 'values'=> { '2010-10-10'=> 99 } } ] }
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 follers, rounded to the nearest whole' do
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.2
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-04-23 00:00:00.000000000 Z
12
+ date: 2015-05-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler