twitter_client 1.2.1 → 1.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/twitter_client.rb +18 -16
- metadata +11 -17
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f72b516a6b8c21ae4e7e5ba55ac9eee2f15c5306
|
4
|
+
data.tar.gz: 7ace4529c66f1ff55ea5deed4ed52155b4bea15e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: bdbb27b0c83993dc1e0d413250a34d60bb738e45b83256e41c99cad5f3d92e771842da970cb53fe413e6d02c9451b3a0d75263b29ab0c3cadffb1394257b68f4
|
7
|
+
data.tar.gz: ba292edae10626d655f930cf209ac8e9be363d47084284becbeeea3995aaf6c221db35375d7de3566ec46b2c11914fab57a200109538b4d54d02796decf0a1c5
|
data/lib/twitter_client.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
require 'oauth'
|
2
2
|
require 'twitter_oauth'
|
3
|
-
require 'twitter_client'
|
4
3
|
|
5
4
|
class TwitterClient
|
6
5
|
attr_accessor :api, :settings
|
@@ -9,10 +8,10 @@ class TwitterClient
|
|
9
8
|
|
10
9
|
def initialize
|
11
10
|
self.api = TwitterOAuth::Client.new(
|
12
|
-
:
|
13
|
-
:
|
14
|
-
:
|
15
|
-
:
|
11
|
+
consumer_key: settings[:consumer_key],
|
12
|
+
consumer_secret: settings[:consumer_secret],
|
13
|
+
token: settings[:token],
|
14
|
+
secret: settings[:token_secret]
|
16
15
|
)
|
17
16
|
end
|
18
17
|
|
@@ -29,10 +28,13 @@ class TwitterClient
|
|
29
28
|
Rails.logger.info("Twitter error: #{err.message} (status: #{message})")
|
30
29
|
end
|
31
30
|
|
32
|
-
def friends(
|
33
|
-
|
31
|
+
def friends(reload = false)
|
32
|
+
Rails.cache.delete("twitter_friends") if reload
|
33
|
+
Rails.cache.fetch("twitter_friends", expires_in: 12.hours) do
|
34
|
+
api.all_friends
|
35
|
+
end
|
34
36
|
end
|
35
|
-
|
37
|
+
|
36
38
|
def follow(screen_name)
|
37
39
|
api.send(:post, "/friendships/create.json?screen_name=#{screen_name}&follow=true")
|
38
40
|
end
|
@@ -43,20 +45,20 @@ class TwitterClient
|
|
43
45
|
|
44
46
|
def self.authenticate
|
45
47
|
consumer = OAuth::Consumer.new(settings[:consumer_key], settings[:consumer_secret],
|
46
|
-
:
|
47
|
-
:
|
48
|
-
:
|
49
|
-
:
|
48
|
+
site: "https://api.twitter.com",
|
49
|
+
request_token_path: "/oauth/request_token",
|
50
|
+
authorize_path: "/oauth/authorize",
|
51
|
+
access_token_path: "/oauth/access_token"
|
50
52
|
)
|
51
53
|
|
52
|
-
rt = consumer.get_request_token({:
|
54
|
+
rt = consumer.get_request_token({oauth_callback: "oob"})
|
53
55
|
print "Goto following url then enter verification code\n"
|
54
56
|
print rt.authorize_url + "\n"
|
55
57
|
print "Enter verification code: "
|
56
58
|
code = $stdin.gets.strip
|
57
|
-
access_token = rt.get_access_token(:
|
59
|
+
access_token = rt.get_access_token(oauth_verifier: code)
|
58
60
|
|
59
|
-
data = settings.merge(:
|
61
|
+
data = settings.merge(token: access_token.params[:oauth_token], token_secret: access_token.params[:oauth_token_secret])
|
60
62
|
|
61
63
|
File.open(config_file, "w") {|f|f.write(YAML.dump(data))}
|
62
64
|
puts "Token saved"
|
@@ -72,7 +74,7 @@ class TwitterClient
|
|
72
74
|
end
|
73
75
|
"#{message} #{url}"
|
74
76
|
end
|
75
|
-
|
77
|
+
|
76
78
|
private
|
77
79
|
def self.settings
|
78
80
|
@settings ||= YAML.load_file(config_file)
|
metadata
CHANGED
@@ -1,46 +1,41 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: twitter_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
5
|
-
prerelease:
|
4
|
+
version: 1.2.3
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Olivier Ruffin
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2015-01-14 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: oauth
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - ">="
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '0'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - ">="
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '0'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: twitter_oauth
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - ">="
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: '0'
|
38
34
|
type: :runtime
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - ">="
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: '0'
|
46
41
|
description:
|
@@ -53,26 +48,25 @@ files:
|
|
53
48
|
- lib/twitter_client.rb
|
54
49
|
homepage: http://muweb.fr
|
55
50
|
licenses: []
|
51
|
+
metadata: {}
|
56
52
|
post_install_message:
|
57
53
|
rdoc_options: []
|
58
54
|
require_paths:
|
59
55
|
- lib
|
60
56
|
required_ruby_version: !ruby/object:Gem::Requirement
|
61
|
-
none: false
|
62
57
|
requirements:
|
63
|
-
- -
|
58
|
+
- - ">="
|
64
59
|
- !ruby/object:Gem::Version
|
65
60
|
version: '0'
|
66
61
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
67
|
-
none: false
|
68
62
|
requirements:
|
69
|
-
- -
|
63
|
+
- - ">="
|
70
64
|
- !ruby/object:Gem::Version
|
71
65
|
version: '0'
|
72
66
|
requirements: []
|
73
67
|
rubyforge_project:
|
74
|
-
rubygems_version:
|
68
|
+
rubygems_version: 2.2.2
|
75
69
|
signing_key:
|
76
|
-
specification_version:
|
70
|
+
specification_version: 4
|
77
71
|
summary: Minimalist twitter client for my specific use
|
78
72
|
test_files: []
|