twat 0.4.2 → 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- data/TODO +6 -22
- data/doc/twat.1 +3 -0
- data/lib/twat.rb +1 -1
- data/lib/twat/actions.rb +40 -1
- data/lib/twat/argparse.rb +5 -1
- metadata +5 -5
data/TODO
CHANGED
@@ -1,33 +1,17 @@
|
|
1
|
-
twat -l -> <newsfeed>
|
2
|
-
twat -l [count] -> <count entries from newsfeed>
|
3
|
-
# Include who tweeted...
|
4
|
-
|
5
1
|
catch invalid options and return opts
|
6
2
|
|
7
|
-
|
8
|
-
CONFIG FILE
|
9
|
-
===========
|
10
|
-
|
11
|
-
This really does need to change, but I'm not sure where on the "Can piss off a userbase" scale I am, (ie, do I have one)
|
12
|
-
|
13
|
-
For now I'm going to leave it, and if it gets to 1.0 I'll fix it then.
|
14
|
-
|
15
3
|
COLORS!
|
16
4
|
=======
|
17
5
|
|
18
|
-
twat -l should dump colors to terminal (This should be configurable tho)
|
19
|
-
|
20
6
|
Refactor tweet printing code, unify throughout
|
21
7
|
|
22
|
-
MIGRATIONS
|
23
|
-
==========
|
24
|
-
|
25
|
-
Shouldn't run if config is up to date
|
26
8
|
|
27
9
|
TODO
|
28
10
|
====
|
29
11
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
12
|
+
Configurable polling interval
|
13
|
+
(which carries with it warnings if it's too short.. which means a warn
|
14
|
+
method.. which means abstracting it's output..)
|
15
|
+
|
16
|
+
On the upside, it'll make unit testing similar.
|
17
|
+
(Add unit tests)
|
data/doc/twat.1
CHANGED
@@ -22,6 +22,9 @@ account.
|
|
22
22
|
Delete speficied account.
|
23
23
|
.IP -h
|
24
24
|
Display a short summary of twat's options.
|
25
|
+
.IP -f
|
26
|
+
Watch your newsfeed in a similar manner to tail -f, updating as your feed does
|
27
|
+
(polling interval 60 seconds)
|
25
28
|
.IP -u USER
|
26
29
|
Retrieve a list of USER's recent tweets. Note this will retrieve all of their
|
27
30
|
tweets as opposed to just what would have appeared in your feed.
|
data/lib/twat.rb
CHANGED
data/lib/twat/actions.rb
CHANGED
@@ -66,12 +66,51 @@ module Twat
|
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
69
|
+
private
|
70
|
+
|
71
|
+
# @return last_id
|
72
|
+
def process_followed(tweets)
|
73
|
+
last_id = nil
|
74
|
+
tweets.reverse.each do |tweet|
|
75
|
+
format(tweet)
|
76
|
+
last_id = tweet.id
|
77
|
+
end
|
78
|
+
|
79
|
+
return last_id
|
80
|
+
end
|
81
|
+
|
82
|
+
public
|
83
|
+
|
84
|
+
def follow
|
85
|
+
# I can't see any way to poll the server for updates, so in the meantime
|
86
|
+
# we will have to retrieve a few tweets from the timeline, and then poll
|
87
|
+
# occasionally :/
|
88
|
+
twitter_auth
|
89
|
+
|
90
|
+
# Get 5 tweets
|
91
|
+
tweets = Twitter.home_timeline(:count => 5)
|
92
|
+
begin
|
93
|
+
while true do
|
94
|
+
last_id = process_followed(tweets) if tweets.any?
|
95
|
+
# Sleep 15 seconds between requests
|
96
|
+
# If left running at all times, that's 240 requests per hour, well
|
97
|
+
# under the limit
|
98
|
+
# sleep 15
|
99
|
+
# Disregard that, once per 60 seconds is plenty
|
100
|
+
sleep 60
|
101
|
+
tweets = Twitter.home_timeline(:since_id => last_id)
|
102
|
+
end
|
103
|
+
rescue Interrupt
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
69
107
|
def user_feed
|
70
108
|
twitter_auth
|
71
109
|
|
72
110
|
begin
|
73
|
-
Twitter.user_timeline(opts[:user]).
|
111
|
+
Twitter.user_timeline(opts[:user]).each_with_index do |tweet, idx|
|
74
112
|
puts "#{tweet.user.screen_name.bold.cyan}: #{tweet.text}"
|
113
|
+
break if idx == opts[:count]
|
75
114
|
end
|
76
115
|
rescue Twitter::NotFound
|
77
116
|
puts "#{opts[:user].bold.red} doesn't appear to be a valid user"
|
data/lib/twat/argparse.rb
CHANGED
@@ -14,8 +14,9 @@ module Twat
|
|
14
14
|
|
15
15
|
def getopts
|
16
16
|
options = Hash.new
|
17
|
+
options[:action] = :tweet
|
18
|
+
options[:count] = 1
|
17
19
|
@optparser = OptionParser.new do |opts|
|
18
|
-
options[:action] = :tweet
|
19
20
|
opts.banner = "Usage: twat <tweet>"
|
20
21
|
|
21
22
|
opts.on('-n', '--account ACCOUNT', 'Use ACCOUNT (or default)') do |acct| #{{{ --account ACCOUNT
|
@@ -37,6 +38,9 @@ module Twat
|
|
37
38
|
options[:count] = count || 10
|
38
39
|
options[:action] = :show
|
39
40
|
end #}}}
|
41
|
+
opts.on('-f', '--follow', 'Display tweets from your newsfeed indefinitely') do #{{{ --follow
|
42
|
+
options[:action] = :follow
|
43
|
+
end #}}}
|
40
44
|
opts.on('-v', '--version', 'Display version info') do #{{{ --version
|
41
45
|
options[:action] = :version
|
42
46
|
end #}}}
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: twat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2011-10-07 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: twitter
|
16
|
-
requirement: &
|
16
|
+
requirement: &14528640 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *14528640
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: oauth
|
27
|
-
requirement: &
|
27
|
+
requirement: &14528080 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *14528080
|
36
36
|
description: Command line tool for tweeting and whatnot
|
37
37
|
email:
|
38
38
|
- richo@psych0tik.net
|