neo4apis-twitter 0.0.1
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 +7 -0
- data/Gemfile +14 -0
- data/README.md +17 -0
- data/lib/neo4apis-twitter.rb +4 -0
- data/lib/neo4apis/twitter.rb +55 -0
- data/lib/neo4apis/twitter/version.rb +6 -0
- data/neo4apis-twitter.gemspec +25 -0
- metadata +65 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f9ac29686dd644899a2f184a99f653f1b15d1b78
|
4
|
+
data.tar.gz: cb662fae49dd85790bdd8af896f87ea3f3ebe7a0
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 33f5489c963868868b654557145dfa2858d6419977a42031a04ced7e93a2286ddf600d0552ee98629c2a9f5e9fde2a36f8ad914a7b1b52ddf8e9c4c09f5eb2f5
|
7
|
+
data.tar.gz: c9eca1f76eaf51cabec63e3c87ee15418ae134a189e2c6cc6a75227e4a3a86273cce39c5931460efafad402f590b76f4e3c1cad4882349b3a27dd520b820529f
|
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
|
2
|
+
neo4apis-twitter is a ruby gem for making importing data from twitter to neo4j easy
|
3
|
+
|
4
|
+
The `twitter` gem is used and thus the methods in this API try to match that API as closely as possible
|
5
|
+
|
6
|
+
```ruby
|
7
|
+
|
8
|
+
twitter_client = Twitter::REST::Client.new ...
|
9
|
+
|
10
|
+
neo4japis_twitter = Neo4Apis::Twitter.new(Neo4j::Session.open, twitter_client: twitter_client)
|
11
|
+
|
12
|
+
neo4japis_twitter.batch do
|
13
|
+
neo4japis_twitter.import_search("ebola", :result_type => "recent")
|
14
|
+
end
|
15
|
+
|
16
|
+
```
|
17
|
+
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'neo4apis'
|
2
|
+
|
3
|
+
module Neo4Apis
|
4
|
+
class Twitter < Base
|
5
|
+
PREFIX = 'twitter'
|
6
|
+
|
7
|
+
def initialize(neo4j_client, options = {})
|
8
|
+
@client = options[:twitter_client]
|
9
|
+
|
10
|
+
raise ArgumentError, "Invalid client: #{@client.inspect}" if not @client.is_a?(::Twitter::REST::Client)
|
11
|
+
|
12
|
+
options[:uuids] = (options[:uuids] || {}).merge({
|
13
|
+
Tweet: :id,
|
14
|
+
User: :id
|
15
|
+
})
|
16
|
+
|
17
|
+
super(neo4j_client, options)
|
18
|
+
end
|
19
|
+
|
20
|
+
def import_search(*args)
|
21
|
+
@client.search(*args).take(100).each do |tweet|
|
22
|
+
add_tweet(tweet)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def add_tweet(tweet)
|
29
|
+
user_node = add_user(tweet.user)
|
30
|
+
retweeted_tweet_node = add_tweet(tweet.retweeted_tweet) if tweet.retweeted_tweet?
|
31
|
+
|
32
|
+
node = add_node :Tweet, {
|
33
|
+
id: tweet.id,
|
34
|
+
text: tweet.text,
|
35
|
+
}
|
36
|
+
|
37
|
+
add_relationship(:tweeted, user_node, node)
|
38
|
+
add_relationship(:retweets, node, retweeted_tweet_node) if tweet.retweeted_tweet?
|
39
|
+
|
40
|
+
node
|
41
|
+
end
|
42
|
+
|
43
|
+
def add_user(user)
|
44
|
+
add_node :User, {
|
45
|
+
id: user.id,
|
46
|
+
screen_name: user.screen_name,
|
47
|
+
name: user.name,
|
48
|
+
location: user.location,
|
49
|
+
profile_image_url: user.profile_image_url.to_s
|
50
|
+
}
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
@@ -0,0 +1,25 @@
|
|
1
|
+
lib = File.expand_path('../lib/', __FILE__)
|
2
|
+
$:.unshift lib unless $:.include?(lib)
|
3
|
+
|
4
|
+
require 'neo4apis/twitter/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = "neo4apis-twitter"
|
8
|
+
s.version = Neo4Apis::Twitter::VERSION
|
9
|
+
s.required_ruby_version = ">= 1.9.1"
|
10
|
+
|
11
|
+
s.authors = "Brian Underwood"
|
12
|
+
s.email = 'public@brian-underwood.codes'
|
13
|
+
s.homepage = "https://github.com/neo4jrb/neo4apis-twitter/"
|
14
|
+
s.summary = "An ruby gem to import twitter data to neo4j"
|
15
|
+
s.license = 'MIT'
|
16
|
+
s.description = <<-EOF
|
17
|
+
A ruby gem using neo4apis to make importing twitter data to neo4j easy
|
18
|
+
EOF
|
19
|
+
|
20
|
+
s.require_path = 'lib'
|
21
|
+
s.files = Dir.glob("{bin,lib,config}/**/*") + %w(README.md Gemfile neo4apis-twitter.gemspec)
|
22
|
+
|
23
|
+
s.add_dependency('neo4apis', "~> 0.0.1")
|
24
|
+
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: neo4apis-twitter
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Brian Underwood
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-10-30 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: neo4apis
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.0.1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.0.1
|
27
|
+
description: |
|
28
|
+
A ruby gem using neo4apis to make importing twitter data to neo4j easy
|
29
|
+
email: public@brian-underwood.codes
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- Gemfile
|
35
|
+
- README.md
|
36
|
+
- lib/neo4apis-twitter.rb
|
37
|
+
- lib/neo4apis/twitter.rb
|
38
|
+
- lib/neo4apis/twitter/version.rb
|
39
|
+
- neo4apis-twitter.gemspec
|
40
|
+
homepage: https://github.com/neo4jrb/neo4apis-twitter/
|
41
|
+
licenses:
|
42
|
+
- MIT
|
43
|
+
metadata: {}
|
44
|
+
post_install_message:
|
45
|
+
rdoc_options: []
|
46
|
+
require_paths:
|
47
|
+
- lib
|
48
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: 1.9.1
|
53
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '0'
|
58
|
+
requirements: []
|
59
|
+
rubyforge_project:
|
60
|
+
rubygems_version: 2.2.2
|
61
|
+
signing_key:
|
62
|
+
specification_version: 4
|
63
|
+
summary: An ruby gem to import twitter data to neo4j
|
64
|
+
test_files: []
|
65
|
+
has_rdoc:
|