latest_tweets 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/latest_tweets/twitter_setup.rb +16 -0
- data/lib/latest_tweets/twitter_timeline.rb +30 -0
- data/lib/latest_tweets/version.rb +3 -0
- data/lib/latest_tweets.rb +14 -0
- metadata +106 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 23a0c0b73a838ddf67e570958bcb675692709a8d
|
4
|
+
data.tar.gz: f470264006518cd26cb4f97a7cf8a408697117b7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e14e6ba68793c58054c391c24479f9d4f5ef13d04ac04d7627bc45748fb07ee7aa49d72c3450a99fe9132604605fc79c564c76cd86d7b9716c65c503f70ba8d6
|
7
|
+
data.tar.gz: 891a8e7aee72e2c20ac540c64b4877b1839edcf1b0cd3b1c018043e7e9aa1f526194d53f412e05cb68d7022e8d8095d23a4a7ea0d6cd858b37df3576a0f02190
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module TwitterSetup
|
2
|
+
class << self
|
3
|
+
def config(config = config_from_environment_variables)
|
4
|
+
Twitter::REST::Client.new(config)
|
5
|
+
end
|
6
|
+
|
7
|
+
private def config_from_environment_variables
|
8
|
+
{
|
9
|
+
:consumer_key => ENV['TWITTER_CONSUMER_KEY'],
|
10
|
+
:consumer_secret => ENV['TWITTER_CONSUMER_SECRET'],
|
11
|
+
:access_token => ENV['TWITTER_ACCESS_TOKEN'],
|
12
|
+
:access_token_secret => ENV['TWITTER_ACCESS_TOKEN_SECRET']
|
13
|
+
}
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module LatestTweets
|
2
|
+
class TwitterTimeline
|
3
|
+
attr_accessor :options, :client
|
4
|
+
|
5
|
+
def initialize(options)
|
6
|
+
@client = config_twitter
|
7
|
+
@options = default_options.merge(options)
|
8
|
+
if (@options[:account] && @options[:query]) || (!@options[:account] && !@options[:query])
|
9
|
+
raise "You must supply :account OR :query"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def tweets
|
14
|
+
if options[:account]
|
15
|
+
client.user_timeline(options[:account], count: options[:count])
|
16
|
+
elsif options[:query]
|
17
|
+
client.search(options[:query], count: options[:count]).to_a
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
def default_options
|
23
|
+
{count: 3}
|
24
|
+
end
|
25
|
+
|
26
|
+
def config_twitter
|
27
|
+
@client = TwitterSetup.config
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'twitter'
|
2
|
+
require 'latest_tweets/version'
|
3
|
+
require 'latest_tweets/twitter_setup'
|
4
|
+
require 'latest_tweets/twitter_timeline'
|
5
|
+
|
6
|
+
module LatestTweets
|
7
|
+
def self.from_account(account, count = 3)
|
8
|
+
LatestTweets::TwitterTimeline.new({account: account, count: count}).tweets
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.from_query(query, count = 3)
|
12
|
+
LatestTweets::TwitterTimeline.new({query: query, count: count}).tweets
|
13
|
+
end
|
14
|
+
end
|
metadata
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: latest_tweets
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jamie Allen
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-04-23 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.5'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.5'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.1'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.1'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.14'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.14'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: twitter
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '5.7'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '5.7'
|
69
|
+
description: Simple twitter gem wrapper for grabbing the latest tweets from an account
|
70
|
+
or query.
|
71
|
+
email:
|
72
|
+
- jamie@factore.ca
|
73
|
+
executables: []
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- lib/latest_tweets.rb
|
78
|
+
- lib/latest_tweets/twitter_setup.rb
|
79
|
+
- lib/latest_tweets/twitter_timeline.rb
|
80
|
+
- lib/latest_tweets/version.rb
|
81
|
+
homepage: https://github.com/eimaj/latest_tweets
|
82
|
+
licenses:
|
83
|
+
- MIT
|
84
|
+
metadata: {}
|
85
|
+
post_install_message:
|
86
|
+
rdoc_options: []
|
87
|
+
require_paths:
|
88
|
+
- lib
|
89
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
90
|
+
requirements:
|
91
|
+
- - ">="
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
95
|
+
requirements:
|
96
|
+
- - ">="
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
99
|
+
requirements: []
|
100
|
+
rubyforge_project:
|
101
|
+
rubygems_version: 2.2.2
|
102
|
+
signing_key:
|
103
|
+
specification_version: 4
|
104
|
+
summary: Simple twitter gem wrapper for grabbing the latest tweets from an account
|
105
|
+
or query.
|
106
|
+
test_files: []
|