tweetline 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/tl +5 -0
- data/lib/tweetline.rb +59 -8
- data/tweetline.gemspec +3 -1
- metadata +36 -4
data/bin/tl
CHANGED
data/lib/tweetline.rb
CHANGED
@@ -1,9 +1,50 @@
|
|
1
1
|
require 'thor'
|
2
2
|
require 'twitter'
|
3
3
|
require 'json'
|
4
|
+
require 'oauth'
|
5
|
+
require 'shortly'
|
4
6
|
|
5
7
|
module Tweetline
|
8
|
+
CONSUMER_KEY = "cbaTxnPKFhGAngIYDqsNyg"
|
9
|
+
CONSUMER_SECRET = "FTrMluAB5pMPEZZRoGmOf2AH3md2KSqW6PNwD7TAzc"
|
10
|
+
|
6
11
|
class << self
|
12
|
+
|
13
|
+
def authorize_user
|
14
|
+
api_url = "https://api.twitter.com"
|
15
|
+
consumer = OAuth::Consumer.new(Tweetline::CONSUMER_KEY, Tweetline::CONSUMER_SECRET, :site => api_url)
|
16
|
+
request_token = consumer.get_request_token
|
17
|
+
|
18
|
+
request = consumer.create_signed_request(:get, consumer.authorize_path, request_token, {:oauth_callback => 'oob'})
|
19
|
+
params = request['Authorization'].sub(/^OAuth\s+/, '').split(/,\s+/).map { |p|
|
20
|
+
k, v = p.split('=')
|
21
|
+
v =~ /"(.*?)"/
|
22
|
+
"#{k}=#{CGI::escape($1)}"
|
23
|
+
}.join('&')
|
24
|
+
auth_url = "#{api_url}#{request.path}?#{params}"
|
25
|
+
|
26
|
+
#bitly = Bitly.new("tweetline", "R_c27cfa45caf4f11cea7fb224056fb7f5")
|
27
|
+
bitly = Shortly::Clients::Bitly
|
28
|
+
|
29
|
+
puts
|
30
|
+
puts "Follow these steps to access your twitter account."
|
31
|
+
puts
|
32
|
+
puts "1) Navigate to the following url..."
|
33
|
+
puts
|
34
|
+
puts bitly.shorten(auth_url, {:apiKey => 'R_c27cfa45caf4f11cea7fb224056fb7f5', :login => 'tweetline'}).url
|
35
|
+
puts
|
36
|
+
puts "2) Allow Tweet-line access to your twitter account..."
|
37
|
+
puts
|
38
|
+
puts "3) Enter your pin number..."
|
39
|
+
puts
|
40
|
+
pin = gets
|
41
|
+
puts
|
42
|
+
|
43
|
+
access_token = request_token.get_access_token(:oauth_verifier => pin.chomp)
|
44
|
+
File.open(rc_file_name, "w") do |f|
|
45
|
+
f.write({:oauth_token => access_token.token, :oauth_token_secret => access_token.secret}.to_yaml)
|
46
|
+
end
|
47
|
+
end
|
7
48
|
|
8
49
|
def cat_tweet(tweet_id, created_at, name, screen_name, text)
|
9
50
|
Tweetline.put_tweet(tweet_id, created_at, name, screen_name, text)
|
@@ -17,14 +58,19 @@ module Tweetline
|
|
17
58
|
end
|
18
59
|
|
19
60
|
def configure_twitter
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
61
|
+
if File.exist?(rc_file_name)
|
62
|
+
Twitter.configure do |config|
|
63
|
+
File.open(rc_file_name) do |yaml|
|
64
|
+
options = YAML.load(yaml)
|
65
|
+
config.consumer_key = options[:consumer_key] || Tweetline::CONSUMER_KEY
|
66
|
+
config.consumer_secret = options[:consumer_secret] || Tweetline::CONSUMER_SECRET
|
67
|
+
config.oauth_token = options[:oauth_token]
|
68
|
+
config.oauth_token_secret = options[:oauth_token_secret]
|
69
|
+
end
|
27
70
|
end
|
71
|
+
else
|
72
|
+
Tweetline.authorize_user
|
73
|
+
configure_twitter
|
28
74
|
end
|
29
75
|
end
|
30
76
|
|
@@ -77,6 +123,11 @@ module Tweetline
|
|
77
123
|
|
78
124
|
return time.strftime(format)
|
79
125
|
end
|
80
|
-
|
126
|
+
|
127
|
+
private
|
128
|
+
|
129
|
+
def rc_file_name
|
130
|
+
File.expand_path('~/.tweetlinerc')
|
131
|
+
end
|
81
132
|
end
|
82
133
|
end
|
data/tweetline.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.platform = Gem::Platform::RUBY
|
3
3
|
s.name = "tweetline"
|
4
|
-
s.version = "0.0.
|
4
|
+
s.version = "0.0.7"
|
5
5
|
s.summary = "Command line client for Twitter."
|
6
6
|
s.description = "Tweetline is a command line Twitter client for those who can't imagine a better interface to anything than the command line. Also, some folks may find it useful for automating Twitter interactions."
|
7
7
|
|
@@ -24,4 +24,6 @@ Gem::Specification.new do |s|
|
|
24
24
|
s.add_dependency('twitter', '~> 1.2.0')
|
25
25
|
s.add_dependency('json', '~> 1.5.1')
|
26
26
|
s.add_dependency('thor', '~> 0.14.6')
|
27
|
+
s.add_dependency('oauth', '~> 0.4.4')
|
28
|
+
s.add_dependency('shortly', '~> 0.3.2')
|
27
29
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tweetline
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 17
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 7
|
10
|
+
version: 0.0.7
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Anthony Crumley
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-04-
|
18
|
+
date: 2011-04-23 00:00:00 -05:00
|
19
19
|
default_executable: tl
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -66,6 +66,38 @@ dependencies:
|
|
66
66
|
version: 0.14.6
|
67
67
|
type: :runtime
|
68
68
|
version_requirements: *id003
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: oauth
|
71
|
+
prerelease: false
|
72
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
hash: 7
|
78
|
+
segments:
|
79
|
+
- 0
|
80
|
+
- 4
|
81
|
+
- 4
|
82
|
+
version: 0.4.4
|
83
|
+
type: :runtime
|
84
|
+
version_requirements: *id004
|
85
|
+
- !ruby/object:Gem::Dependency
|
86
|
+
name: shortly
|
87
|
+
prerelease: false
|
88
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ~>
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
hash: 23
|
94
|
+
segments:
|
95
|
+
- 0
|
96
|
+
- 3
|
97
|
+
- 2
|
98
|
+
version: 0.3.2
|
99
|
+
type: :runtime
|
100
|
+
version_requirements: *id005
|
69
101
|
description: Tweetline is a command line Twitter client for those who can't imagine a better interface to anything than the command line. Also, some folks may find it useful for automating Twitter interactions.
|
70
102
|
email: anthony.crumley@gmail.com
|
71
103
|
executables:
|