twat 0.2.7 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/TODO +3 -0
- data/lib/twat/actions.rb +19 -11
- data/lib/twat/argparse.rb +19 -15
- data/lib/twat/exceptions.rb +1 -0
- data/lib/twat.rb +5 -2
- metadata +6 -6
data/TODO
CHANGED
data/lib/twat/actions.rb
CHANGED
@@ -5,16 +5,7 @@ module Twat
|
|
5
5
|
|
6
6
|
def tweet(opts)
|
7
7
|
# This is all broken, we should know what options we have before this happend
|
8
|
-
|
9
|
-
|
10
|
-
Twitter.configure do |twit|
|
11
|
-
conf.each do |key, value|
|
12
|
-
twit.send("#{key}=", value)
|
13
|
-
end
|
14
|
-
Config.consumer_info.each do |key, value|
|
15
|
-
twit.send("#{key}=", value)
|
16
|
-
end
|
17
|
-
end
|
8
|
+
twitter_auth(opts)
|
18
9
|
|
19
10
|
Twitter.update(opts.msg)
|
20
11
|
#puts opts.msg
|
@@ -53,7 +44,12 @@ module Twat
|
|
53
44
|
end
|
54
45
|
|
55
46
|
def show(opts)
|
56
|
-
|
47
|
+
twitter_auth(opts)
|
48
|
+
Twitter.home_timeline.each_with_index do |tweet, idx|
|
49
|
+
puts "#{tweet.user.screen_name}: #{tweet.text}"
|
50
|
+
|
51
|
+
break if idx == opts[:count]
|
52
|
+
end
|
57
53
|
end
|
58
54
|
|
59
55
|
def version(opts)
|
@@ -66,5 +62,17 @@ module Twat
|
|
66
62
|
@cf ||= Config.new
|
67
63
|
end
|
68
64
|
|
65
|
+
def twitter_auth(opts)
|
66
|
+
conf = cf[opts[:account]]
|
67
|
+
Twitter.configure do |twit|
|
68
|
+
conf.each do |key, value|
|
69
|
+
twit.send("#{key}=", value)
|
70
|
+
end
|
71
|
+
Config.consumer_info.each do |key, value|
|
72
|
+
twit.send("#{key}=", value)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
69
77
|
end
|
70
78
|
end
|
data/lib/twat/argparse.rb
CHANGED
@@ -16,31 +16,31 @@ module Twat
|
|
16
16
|
options[:action] = :tweet
|
17
17
|
options[:account] = :default
|
18
18
|
opts.banner = "Usage: twat <tweet>"
|
19
|
-
|
19
|
+
|
20
|
+
opts.on('-n', '--account ACCOUNT', 'Use ACCOUNT (or default)') do |acct| #{{{ --account ACCOUNT
|
20
21
|
options[:account] = acct.to_sym
|
21
|
-
end
|
22
|
-
opts.on('-a', '--add ACCOUNT', 'Configure and authorise ACCOUNT') do |acct|
|
22
|
+
end # }}}
|
23
|
+
opts.on('-a', '--add ACCOUNT', 'Configure and authorise ACCOUNT') do |acct| #{{{ --add ACCOUNT
|
23
24
|
options[:account] = acct.to_sym
|
24
25
|
options[:action] = :add
|
25
|
-
end
|
26
|
-
opts.on('-d', '--delete ACCOUNT', 'Delete ACCOUNT') do |acct|
|
26
|
+
end #}}}
|
27
|
+
opts.on('-d', '--delete ACCOUNT', 'Delete ACCOUNT') do |acct| #{{{ --delete ACCOUNT
|
27
28
|
options[:account] = acct.to_sym
|
28
29
|
options[:action] = :delete
|
29
|
-
end
|
30
|
-
|
31
|
-
#end
|
32
|
-
opts.on('-h', '--help', 'Display this screen') do
|
30
|
+
end #}}}
|
31
|
+
opts.on('-h', '--help', 'Display this screen') do #{{{ --help
|
33
32
|
puts opts
|
34
33
|
exit
|
35
|
-
end
|
36
|
-
opts.on('-l', '--list [COUNT]', 'Display [count] tweets from your newsfeed') do |count|
|
34
|
+
end #}}}
|
35
|
+
opts.on('-l', '--list [COUNT]', 'Display [count] tweets from your newsfeed') do |count| #{{{ --list ACCOUNT
|
37
36
|
options[:count] = count || 10
|
38
37
|
options[:action] = :show
|
39
|
-
end
|
40
|
-
opts.on('-v', '--version', 'Display version info') do
|
38
|
+
end #}}}
|
39
|
+
opts.on('-v', '--version', 'Display version info') do #{{{ --version
|
41
40
|
options[:action] = :version
|
42
|
-
end
|
41
|
+
end #}}}
|
43
42
|
end
|
43
|
+
|
44
44
|
@optparser.parse!
|
45
45
|
REQUIRED.each do |req|
|
46
46
|
usage unless options[req]
|
@@ -61,7 +61,11 @@ module Twat
|
|
61
61
|
end
|
62
62
|
|
63
63
|
def options
|
64
|
-
|
64
|
+
begin
|
65
|
+
@configthingfucken ||= getopts
|
66
|
+
rescue OptionParser::InvalidOption
|
67
|
+
usage "Unknown option"
|
68
|
+
end
|
65
69
|
end
|
66
70
|
|
67
71
|
end
|
data/lib/twat/exceptions.rb
CHANGED
data/lib/twat.rb
CHANGED
@@ -12,8 +12,8 @@ end
|
|
12
12
|
|
13
13
|
module Twat
|
14
14
|
VERSION_MAJOR = 0
|
15
|
-
VERSION_MINOR =
|
16
|
-
VERSION_PATCH =
|
15
|
+
VERSION_MINOR = 3
|
16
|
+
VERSION_PATCH = 0
|
17
17
|
|
18
18
|
VERSION = "#{VERSION_MAJOR}.#{VERSION_MINOR}.#{VERSION_PATCH}"
|
19
19
|
class Twat
|
@@ -33,6 +33,9 @@ module Twat
|
|
33
33
|
rescue NoConfigFile
|
34
34
|
puts "No config file, create one with twat -a [user|nick]"
|
35
35
|
opts.usage
|
36
|
+
rescue InvalidCredentials
|
37
|
+
puts "Invalid credentials, try reauthenticating with"
|
38
|
+
puts "twat -a #{opts[:account]}"
|
36
39
|
end
|
37
40
|
end
|
38
41
|
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
|
+
version: 0.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-09-
|
12
|
+
date: 2011-09-21 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: twitter
|
16
|
-
requirement: &
|
16
|
+
requirement: &74735110 !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: *74735110
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: oauth
|
27
|
-
requirement: &
|
27
|
+
requirement: &74734800 !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: *74734800
|
36
36
|
description: Command line tool for tweeting and whatnot
|
37
37
|
email:
|
38
38
|
- richo@psych0tik.net
|