Skip to content
This repository was archived by the owner on Sep 24, 2024. It is now read-only.

Commit e923d87

Browse files
committed
Merge remote-tracking branch 'orig_repo/master' into refactor-to-support-view-models
2 parents c386102 + 0099968 commit e923d87

7 files changed

Lines changed: 119 additions & 18 deletions

File tree

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
*.xlsx
2-
facebook_analysis.html
2+
facebook_data_analyzer.html
33
example/facebook-monaleigh/messages/*.json
44
# bundle gem
55
/.bundle/
@@ -15,4 +15,4 @@ example/facebook-monaleigh/messages/*.json
1515
.env
1616

1717
# rspec failure tracking
18-
.rspec_status
18+
.rspec_status

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
[![CircleCI](https://circleci.com/gh/Lackoftactics/facebook_data_analyzer.svg?style=svg)](https://circleci.com/gh/Lackoftactics/facebook_data_analyzer)
12
# facebook_data_analyzer
23

4+
35
Facebook data analyzer as seen on [I analyzed my facebook data and it's story of shyness, loneliness, and change](https://medium.com/@przemek_/i-analyzed-my-facebook-data-and-its-story-of-shyness-loneliness-and-change-7f4e0ec3a952)
46

57
Analyze Facebook copy of your data. Download zip file from Facebook and get info about friends, ranking by message, vocabulary, contacts, friends added statistics and more.

lib/facebook_data_analyzer.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,11 @@
2525

2626
module FacebookDataAnalyzer
2727
def self.run(options = {})
28+
file_output = 'facebook_data_analyzer'
2829
catalog = options.fetch(:catalog)
29-
xlsx = [options.fetch(:filename), 'xlsx'].join('.')
30-
html = [options.fetch(:filename), 'html'].join('.')
31-
parallel_usage = options.fetch(:parallel)
30+
xlsx = [options.fetch(:filename, file_output), 'xlsx'].join('.')
31+
html = [options.fetch(:filename, file_output), 'html'].join('.')
32+
parallel_usage = options.fetch(:parallel, false)
3233

3334
package = Axlsx::Package.new
3435

spec/lib/facebook_data_analyzer/analyzeables/contacts_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
let(:contact) { subject.contacts.first }
1212

1313
it 'should return proper @contacts details for first contact' do
14-
expect(contact.name).to eq("Lou Gregory")
15-
expect(contact.details).to eq("lgregory@gmail.com")
16-
expect(contact.name).to_not eq("Cindy Walker")
14+
expect(contact.name).to eq('Lou Gregory')
15+
expect(contact.details).to eq('lgregory@gmail.com')
16+
expect(contact.name).to_not eq('Cindy Walker')
1717
expect(subject.contacts.count).to eq(10)
1818
end
1919
end

spec/lib/facebook_data_analyzer/analyzeables/friends_spec.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@
3030

3131
it "should count adding friends correctly" do
3232
expect(counted[:year][2017]).to eq(7)
33-
expect(counted[:day_of_week]["Sunday"]).to eq(23)
34-
expect(counted[:month]["August"]).to eq(15)
33+
expect(counted[:day_of_week]['Sunday']).to eq(23)
34+
expect(counted[:month]['August']).to eq(15)
3535
expect(counted[:weekend][:working]).to eq(51)
36-
expect(counted[:week_year]["week 14 of 2015"]).to eq(2)
37-
expect(counted[:month_year]["October - 2016"]).to eq(10)
38-
expect(counted[:day]["2016-09-15"]).to eq(3)
36+
expect(counted[:week_year]['week 14 of 2015']).to eq(2)
37+
expect(counted[:month_year]['October - 2016']).to eq(10)
38+
expect(counted[:day]['2016-09-15']).to eq(3)
3939
end
4040
end
4141
end

spec/lib/facebook_data_analyzer/analyzeables/messages_spec.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313
it 'should return proper @messages' do
1414
expect(message.character_count).to eq(304)
1515
expect(message.word_count).to eq(53)
16-
expect(message.sender).to eq(:"Allison Walker")
17-
expect(message.words).to eq(["hello", "friends", "family", "and", "dance", "students", "please", "help", "me", "promote", "my", "wedding", "dance", "choreography", "page", "in", "this", "difficult", "economy", "i", "need", "to", "have", "as", "many", "likes", "as", "possible", "to", "get", "higher", "in", "the", "search", "engines", "so", "please", "go", "onto", "my", "page", "wedding", "dance", "choreography", "and", "like", "us", "i", "really", "appreciate", "it", "thanks", "allison"])
18-
expect(message.content).to eq("hello friends family and dance students please help me promote my wedding dance choreography page in this difficult economy i need to have as many likes as possible to get higher in the search engines so please go onto my page wedding dance choreography and like us i really appreciate it thanks allison")
19-
expect(message.conversation).to eq("Allison Walker")
20-
expect(message.date_sent.to_s).to eq("2012-01-29T14:55:00-05:00")
16+
expect(message.sender).to eq(:'Allison Walker')
17+
expect(message.words).to eq(['hello', 'friends', 'family', 'and', 'dance', 'students', 'please', 'help', 'me', 'promote', 'my', 'wedding', 'dance', 'choreography', 'page', 'in', 'this', 'difficult', 'economy', 'i', 'need', 'to', 'have', 'as', 'many', 'likes', 'as', 'possible', 'to', 'get', 'higher', 'in', 'the', 'search', 'engines', 'so', 'please', 'go', 'onto', 'my', 'page', 'wedding', 'dance', 'choreography', 'and', 'like', 'us', 'i', 'really', 'appreciate', 'it', 'thanks', 'allison'])
18+
expect(message.content).to eq('hello friends family and dance students please help me promote my wedding dance choreography page in this difficult economy i need to have as many likes as possible to get higher in the search engines so please go onto my page wedding dance choreography and like us i really appreciate it thanks allison')
19+
expect(message.conversation).to eq('Allison Walker')
20+
expect(message.date_sent.to_s).to eq('2012-01-29T14:55:00-05:00')
2121
end
2222
end
2323

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
RSpec.describe FacebookDataAnalyzer do
2+
before(:all) { described_class.run(catalog: test_catalog) }
3+
4+
describe '.run' do
5+
context '.xlsx' do
6+
let!(:workbook) { Workbook::Book.open 'facebook_data_analyzer.xlsx' }
7+
8+
it 'generates "Friends ranking" worksheet correctly' do
9+
sheet = workbook[0]
10+
table = sheet.table
11+
expect(table['B3'].value).to eq('Suzanne Nash')
12+
expect(table['C4'].value).to eq(22)
13+
expect(table['D5'].value).to eq(12)
14+
expect(table['E6'].value).to eq(4)
15+
expect(table['G7'].value).to eq(304)
16+
end
17+
18+
it 'generates "Most Talkative" worksheet correctly' do
19+
sheet = workbook[1]
20+
table = sheet.table
21+
expect(table['B2'].value).to eq('Kate Hunter')
22+
expect(table['C3'].value).to eq(12)
23+
expect(table['B5'].value).to eq('Cindi Gray')
24+
expect(table['C6'].value).to eq(1)
25+
end
26+
27+
it 'generates "My message statistics" worksheet correctly' do
28+
sheet = workbook[2]
29+
table = sheet.table
30+
expect(table['A2'].value).to eq('You sent in total 39 messages')
31+
expect(table['C12'].value).to eq(17)
32+
expect(table['B17'].value).to eq(31)
33+
expect(table['C29'].value + table['C30'].value).to eq(39)
34+
expect(table['B83'].value).to eq(9)
35+
end
36+
37+
it 'generates "Vocabulary statistics" worksheet correctly' do
38+
sheet = workbook[3]
39+
table = sheet.table
40+
expect(table['A2'].value).to eq('You used 212 unique words and 508 words in total')
41+
expect(table['B6'].value).to eq('morning')
42+
expect(table['C8'].value).to eq(5)
43+
end
44+
45+
it 'generates "Popular Words per Conversation" worksheet correctly' do
46+
sheet = workbook[4]
47+
table = sheet.table
48+
expect(table['A26'].value).to eq('Abbie Carter')
49+
expect(table['B39'].value).to eq('front')
50+
expect(table['C51'].value).to eq(3)
51+
end
52+
end
53+
54+
context '.html' do
55+
let!(:workbook) { Nokogiri::HTML open('facebook_data_analyzer.html') }
56+
57+
it 'generates "Friends ranking" html output correctly' do
58+
workbook.xpath('//table[1]').first.content
59+
expect(workbook.xpath('//table[1]//tr[2]/td[2]').first.content).to eq('Suzanne Nash')
60+
expect(workbook.xpath('//table[1]//tr[3]/td[3]').first.content).to eq('22')
61+
expect(workbook.xpath('//table[1]//tr[4]/td[4]').first.content).to eq('12')
62+
expect(workbook.xpath('//table[1]//tr[5]/td[5]').first.content).to eq('4')
63+
expect(workbook.xpath('//table[1]//tr[6]/td[7]').first.content).to eq('304')
64+
end
65+
66+
it 'generates "Most Talkative" html output correctly' do
67+
workbook.xpath('//table[2]').first.content
68+
expect(workbook.xpath('//table[2]//tr[1]/td[2]').first.content).to eq('Kate Hunter')
69+
expect(workbook.xpath('//table[2]//tr[2]/td[3]').first.content).to eq('12')
70+
expect(workbook.xpath('//table[2]//tr[4]/td[2]').first.content).to eq('Cindi Gray')
71+
expect(workbook.xpath('//table[2]//tr[5]/td[3]').first.content).to eq('1')
72+
end
73+
74+
it 'generates "My message statistics" html output correctly' do
75+
workbook.xpath('//table[3]').first.content
76+
expect(workbook.xpath('//table[3]//tr[1]/td[1]').first.content).to eq('You sent in total 39 messages')
77+
expect(workbook.xpath('//table[3]//tr[11]/td[3]').first.content).to eq('17')
78+
expect(workbook.xpath('//table[3]//tr[16]/td[2]').first.content).to eq('31')
79+
expect((workbook.xpath('//table[3]//tr[28]/td[3]').first.content.to_i)+(workbook.xpath('//table[3]//tr[29]/td[3]').first.content.to_i)).to eq(39)
80+
expect(workbook.xpath('//table[3]//tr[82]/td[2]').first.content).to eq('9')
81+
end
82+
83+
it 'generates "Vocabulary statistics" html output correctly' do
84+
workbook.xpath('//table[4]').first.content
85+
expect(workbook.xpath('//table[4]//tr[1]/td[1]').first.content).to eq('You used 212 unique words and 508 words in total')
86+
expect(workbook.xpath('//table[4]//tr[5]/td[2]').first.content).to eq('morning')
87+
expect(workbook.xpath('//table[4]//tr[7]/td[3]').first.content).to eq('5')
88+
end
89+
90+
it 'generates "Popular Words per Conversation" html output correctly' do
91+
workbook.xpath('//table[5]').first.content
92+
expect(workbook.xpath('//table[5]//tr[25]/td[1]').first.content).to eq('Abbie Carter')
93+
expect(workbook.xpath('//table[5]//tr[38]/td[2]').first.content).to eq('front')
94+
expect(workbook.xpath('//table[5]//tr[50]/td[3]').first.content).to eq('3')
95+
end
96+
end
97+
end
98+
end

0 commit comments

Comments
 (0)