da_face 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +2 -1
- data/Gemfile.lock +1 -1
- data/lib/da_face/datasift/da_object.rb +3 -2
- data/lib/da_face/datasift/parser.rb +6 -6
- data/lib/da_face/datasift/twitter.rb +3 -3
- data/lib/da_face/version.rb +1 -1
- data/spec/da_face/datasift/da_object_spec.rb +15 -4
- data/spec/da_face/datasift/twitter_spec.rb +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4fd1da0946492f15183e9eeb679d72952ed6f275
|
4
|
+
data.tar.gz: 94128e1c3a3f8043b765116f3817b8689356ffc9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 93a718f1ca33395ac395f0c072c45eb113811a058f46e78924e0505ffc14ce5b7096c063c36cf7862e4b0a06201bd278b3869fd22d7f560d5ec9111994a30b5e
|
7
|
+
data.tar.gz: e751bd90a27a94a987d42d5b44619017b976fb8fc35b36f6a9c52d5af8dc97cca10ba0b2c2262435a7ca08e3909bc8ef9865674b048f3fd94777eaa7af64937b
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
@@ -5,9 +5,10 @@ module DaFace
|
|
5
5
|
TWITTER_DELETE_NOTIFICATION = :delete_notification
|
6
6
|
TWITTER_USER_NOTIFICATION = :user_notification
|
7
7
|
|
8
|
-
attr_reader :interaction, :demographic, :links, :twitter, :salience, :language, :kind
|
8
|
+
attr_reader :interaction, :demographic, :links, :twitter, :salience, :language, :kind, :raw
|
9
9
|
|
10
|
-
def initialize data={}
|
10
|
+
def initialize data={}, raw_data={}
|
11
|
+
@raw = raw_data
|
11
12
|
if data[:deleted]
|
12
13
|
@twitter = DaFace::Datasift::TwitterDeleteNotification.new(data)
|
13
14
|
else
|
@@ -4,12 +4,13 @@ module DaFace
|
|
4
4
|
include DaFace::Utilities
|
5
5
|
|
6
6
|
def build_object data
|
7
|
-
|
7
|
+
symbolized_data = symbolize_keys(data.keys, data)
|
8
|
+
DaFace::Datasift::DaObject.new symbolized_data, data
|
8
9
|
end
|
9
10
|
|
10
11
|
def build_objects data
|
11
12
|
objects = []
|
12
|
-
data[
|
13
|
+
data['interactions'].each do |object_data|
|
13
14
|
objects << build_object(object_data)
|
14
15
|
end
|
15
16
|
|
@@ -20,15 +21,14 @@ module DaFace
|
|
20
21
|
raise DaFace::Datasift::MissingJson unless json
|
21
22
|
|
22
23
|
data = JSON.parse(json)
|
23
|
-
|
24
|
-
return build_objects(symbolized_data)
|
24
|
+
return build_objects(data)
|
25
25
|
end
|
26
26
|
|
27
27
|
def parse_from_json json=nil
|
28
28
|
raise DaFace::Datasift::MissingJson unless json
|
29
|
+
|
29
30
|
data = JSON.parse(json)
|
30
|
-
|
31
|
-
return build_object(symbolized_data)
|
31
|
+
return build_object(data)
|
32
32
|
end
|
33
33
|
end
|
34
34
|
end
|
@@ -3,7 +3,7 @@ module DaFace
|
|
3
3
|
class Twitter
|
4
4
|
include DaFace::Utilities
|
5
5
|
|
6
|
-
|
6
|
+
attr_reader :retweet, :retweeted, :tweet, :status
|
7
7
|
|
8
8
|
def self.new data
|
9
9
|
if data[:status]
|
@@ -30,12 +30,12 @@ module DaFace
|
|
30
30
|
|
31
31
|
private
|
32
32
|
def extract_retweet_info data
|
33
|
-
data[:retweet]
|
33
|
+
data[:retweet]
|
34
34
|
end
|
35
35
|
|
36
36
|
def extract_tweet_info data
|
37
37
|
if data[:retweet]
|
38
|
-
data[:retweeted]
|
38
|
+
data[:retweeted].merge({:text => (data[:retweeted][:text] || data[:retweet][:text])})
|
39
39
|
else
|
40
40
|
data
|
41
41
|
end
|
data/lib/da_face/version.rb
CHANGED
@@ -3,13 +3,13 @@ require 'spec_helper'
|
|
3
3
|
describe DaFace::Datasift::DaObject do
|
4
4
|
before do
|
5
5
|
@parser = DaFace::Datasift::Parser.new
|
6
|
-
fixture = json_fixture('interactions/simple.json')
|
7
|
-
@interaction_data = @parser.symbolize_keys(fixture.keys, fixture)
|
6
|
+
@fixture = json_fixture('interactions/simple.json')
|
7
|
+
@interaction_data = @parser.symbolize_keys(@fixture.keys, @fixture)
|
8
8
|
end
|
9
9
|
|
10
10
|
describe '#new' do
|
11
11
|
it 'creates a DaObject object' do
|
12
|
-
obj = DaFace::Datasift::DaObject.new @interaction_data
|
12
|
+
obj = DaFace::Datasift::DaObject.new @interaction_data, @fixture
|
13
13
|
|
14
14
|
expect(obj.class).to eq(DaFace::Datasift::DaObject)
|
15
15
|
end
|
@@ -21,9 +21,20 @@ describe DaFace::Datasift::DaObject do
|
|
21
21
|
|
22
22
|
describe 'attributes' do
|
23
23
|
before do
|
24
|
-
@da_object = DaFace::Datasift::DaObject.new @interaction_data
|
24
|
+
@da_object = DaFace::Datasift::DaObject.new @interaction_data, @fixture
|
25
25
|
end
|
26
26
|
|
27
|
+
describe 'raw' do
|
28
|
+
it 'is present' do
|
29
|
+
expect(@da_object.raw).not_to eq(nil)
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'has string keys' do
|
33
|
+
expect(@da_object.raw.keys.map(&:class).uniq.size).to eq(1)
|
34
|
+
expect(@da_object.raw.keys.map(&:class).uniq.first).to eq(String)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
27
38
|
describe '#interaction' do
|
28
39
|
it 'is present' do
|
29
40
|
expect(@da_object.interaction).not_to eq(nil)
|
@@ -44,6 +44,7 @@ describe DaFace::Datasift::Twitter do
|
|
44
44
|
expect(@twitter.tweet.id).to eq(@data[:retweet][:id].to_i)
|
45
45
|
expect(@twitter.retweeted.id).to eq(@data[:retweeted][:id].to_i)
|
46
46
|
expect(@twitter.retweeted.id).not_to eq(@twitter.tweet.id)
|
47
|
+
expect(@twitter.tweet.text).to eq(@twitter.retweeted.text)
|
47
48
|
expect(@twitter.retweet?).to eq(true)
|
48
49
|
end
|
49
50
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: da_face
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rayko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-10-
|
11
|
+
date: 2014-10-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|