patient_zero 0.5.4 → 0.5.5

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: 2d4a80fc330778657a0a34ba390b9aeaa0304346
4
- data.tar.gz: ed9f4a9d3e1ddef6d04f5c8d4c3d45542cf6c048
3
+ metadata.gz: 03269ba3e5c9a827db9b792e661a832ae788e935
4
+ data.tar.gz: b132a2af9830d3916c4d6fe1bad35b226387fdbf
5
5
  SHA512:
6
- metadata.gz: 4ec9eda3e118858e6c240a160e10805408ff304b7d3355fdef2cda9eeb4ddba03b81378b86905099301edc0e4dae20f0680d117aea1b35c530b084f0540f64c6
7
- data.tar.gz: 90dfa1e51ecf8ee3b38bfdc0f4241ba854669c967c13c5846f98ccef8f81bd4f239476ae78091f8524fb1ee0fb0b91b66d3ed89ceb2f4e82353aa379c01e29ae
6
+ metadata.gz: 9ca2d5e5f070ac5055f6bfc71d0e0cb35a0da384a2bb67b5bceb9d055c1ddf2d0f69ddf76e754969e6dc01c4e948c8cea006a353df691341c7b9fd8a67be93ef
7
+ data.tar.gz: 8eeed15f2a9325b4db810528e896646e1fbe7d064d43728d2accb6238d39e5308ee0458a2580d2457ef504e3c0b9a7aa49ef9f0284fca9c1a464be58f9077423
@@ -21,7 +21,11 @@ module PatientZero
21
21
  end
22
22
 
23
23
  def messages
24
- analytical_data['messages'].map { |message| Message.for_platform message['platform'], message }
24
+ analytical_data['messages'].map { |message| Message.for_platform message['platform'], message }.compact
25
+ end
26
+
27
+ def total_posts
28
+ messages.count
25
29
  end
26
30
 
27
31
  private
@@ -0,0 +1,25 @@
1
+ module PatientZero
2
+ module Analytics
3
+ class Tumblr < Base
4
+ def messages
5
+ []
6
+ end
7
+
8
+ def total_posts
9
+ analytical_data.fetch('total_posts').to_i
10
+ end
11
+
12
+ def engagements
13
+ likes
14
+ end
15
+
16
+ def followers
17
+ analytical_data.fetch('total_followers').to_i
18
+ end
19
+
20
+ def likes
21
+ analytical_data.fetch('total_likes').to_i
22
+ end
23
+ end
24
+ end
25
+ end
@@ -2,15 +2,19 @@ require 'patient_zero/analytics/base'
2
2
  require 'patient_zero/analytics/twitter'
3
3
  require 'patient_zero/analytics/facebook'
4
4
  require 'patient_zero/analytics/instagram'
5
+ require 'patient_zero/analytics/tumblr'
5
6
 
6
7
  module PatientZero
7
8
  module Analytics
8
9
  SOURCE_TYPES = {'twitter' => Twitter,
9
10
  'facebook' => Facebook,
10
- 'instagram' => Instagram}
11
+ 'instagram' => Instagram,
12
+ 'tumblr' => Tumblr}
11
13
 
12
14
  def self.for_platform platform, params={}
13
15
  SOURCE_TYPES[platform].new params
16
+ rescue NoMethodError
17
+ nil
14
18
  end
15
19
  end
16
20
  end
@@ -11,6 +11,8 @@ module PatientZero
11
11
 
12
12
  def self.for_platform platform, params={}
13
13
  SOURCE_TYPES[platform].new params
14
+ rescue NoMethodError
15
+ nil
14
16
  end
15
17
  end
16
18
  end
@@ -1,3 +1,3 @@
1
1
  module PatientZero
2
- VERSION = '0.5.4'
2
+ VERSION = '0.5.5'
3
3
  end
@@ -6,7 +6,7 @@ module PatientZero
6
6
  let(:source_id) { "12345##{platform}#1234567890" }
7
7
  let(:name) { 'account_name' }
8
8
  let(:platform) { 'account_type' }
9
- let(:messages) { [ { 'platform' => 'FB' } ] }
9
+ let(:messages) { [ { 'platform' => 'FB' }, { 'platform' => '??' } ] }
10
10
  let(:token) { 'token-shmoken' }
11
11
  let(:analytical_data) { { 'stats' => [ { 'id' => source_id, 'platform' => platform, 'name' => name, 'messages' => messages } ] } }
12
12
  subject(:analytics_base) { Base.new token: token, source_id: source_id }
@@ -49,6 +49,12 @@ module PatientZero
49
49
  end
50
50
  end
51
51
  end
52
+
53
+ describe '#total_posts' do
54
+ it 'returns the count of messages' do
55
+ expect(analytics_base.total_posts).to be 1
56
+ end
57
+ end
52
58
  end
53
59
  end
54
60
  end
@@ -0,0 +1,47 @@
1
+ require 'spec_helper'
2
+
3
+ module PatientZero
4
+ module Analytics
5
+ describe Tumblr do
6
+ let(:source_id) { "12345##{platform}#1234567890" }
7
+ let(:platform) { 'tumblr' }
8
+ let(:token) { 'token-shmoken' }
9
+ let(:followers) { '26' }
10
+ let(:likes) { '89' }
11
+ let(:posts) { '45' }
12
+ let(:analytical_data) { { 'total_posts'=>posts, 'total_followers'=>followers, 'total_likes'=>likes } }
13
+ let(:tumblr_analytics) { Tumblr.new token: token, source_id: source_id }
14
+ before{ allow(tumblr_analytics).to receive(:analytical_data).and_return analytical_data }
15
+
16
+ describe '#messages' do
17
+ it 'returns an empty array' do
18
+ expect(tumblr_analytics.messages).to eq []
19
+ end
20
+ end
21
+
22
+ describe '#total_posts' do
23
+ it 'returns the number of posts from the analytical_data hash' do
24
+ expect(tumblr_analytics.total_posts).to eq posts.to_i
25
+ end
26
+ end
27
+
28
+ describe '#engagements' do
29
+ it 'returns the sum of likes from the analytical_data hash' do
30
+ expect(tumblr_analytics.engagements).to eq likes.to_i
31
+ end
32
+ end
33
+
34
+ describe '#followers' do
35
+ it 'returns the number of followers from the analytical_data hash' do
36
+ expect(tumblr_analytics.followers).to eq followers.to_i
37
+ end
38
+ end
39
+
40
+ describe '#likes' do
41
+ it 'returns the number of likes from the analytical_data hash' do
42
+ expect(tumblr_analytics.likes).to eq likes.to_i
43
+ end
44
+ end
45
+ end
46
+ end
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
4
+ version: 0.5.5
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-05-04 00:00:00.000000000 Z
12
+ date: 2015-05-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -128,6 +128,7 @@ files:
128
128
  - lib/patient_zero/analytics/base.rb
129
129
  - lib/patient_zero/analytics/facebook.rb
130
130
  - lib/patient_zero/analytics/instagram.rb
131
+ - lib/patient_zero/analytics/tumblr.rb
131
132
  - lib/patient_zero/analytics/twitter.rb
132
133
  - lib/patient_zero/authorization.rb
133
134
  - lib/patient_zero/client.rb
@@ -148,6 +149,7 @@ files:
148
149
  - spec/patient_zero/analytics/base_spec.rb
149
150
  - spec/patient_zero/analytics/facebook_spec.rb
150
151
  - spec/patient_zero/analytics/instagram_spec.rb
152
+ - spec/patient_zero/analytics/tumblr_spec.rb
151
153
  - spec/patient_zero/analytics/twitter_spec.rb
152
154
  - spec/patient_zero/analytics_spec.rb
153
155
  - spec/patient_zero/authorization_spec.rb
@@ -189,6 +191,7 @@ test_files:
189
191
  - spec/patient_zero/analytics/base_spec.rb
190
192
  - spec/patient_zero/analytics/facebook_spec.rb
191
193
  - spec/patient_zero/analytics/instagram_spec.rb
194
+ - spec/patient_zero/analytics/tumblr_spec.rb
192
195
  - spec/patient_zero/analytics/twitter_spec.rb
193
196
  - spec/patient_zero/analytics_spec.rb
194
197
  - spec/patient_zero/authorization_spec.rb