twat 0.4.14 → 0.4.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/TODO +0 -8
- data/lib/twat.rb +6 -34
- data/lib/twat/actions.rb +6 -1
- data/lib/twat/exceptions.rb +40 -0
- data/man/twat.1 +5 -0
- metadata +6 -6
data/TODO
CHANGED
@@ -20,14 +20,6 @@ On the upside, it'll make unit testing similar.
|
|
20
20
|
|
21
21
|
Split config and options out into submodules
|
22
22
|
|
23
|
-
Wrap all of the exception handling into a submodule, ie
|
24
|
-
with_handled_exceptions do
|
25
|
-
<perform actions assuming everything went well>
|
26
|
-
end
|
27
|
-
|
28
|
-
(With handled exceptions contains the logic for yelling at the user for
|
29
|
-
being stupid, etc)
|
30
|
-
|
31
23
|
Allow upload of media files with the tweet via some kind of --attach
|
32
24
|
(Has implications for other endpoints because we need that data from the user or to infer it somehow)
|
33
25
|
|
data/lib/twat.rb
CHANGED
@@ -45,48 +45,20 @@ end
|
|
45
45
|
module Twat
|
46
46
|
VERSION_MAJOR = 0
|
47
47
|
VERSION_MINOR = 4
|
48
|
-
VERSION_PATCH =
|
48
|
+
VERSION_PATCH = 15
|
49
49
|
|
50
50
|
VERSION = "#{VERSION_MAJOR}.#{VERSION_MINOR}.#{VERSION_PATCH}"
|
51
51
|
class Twat
|
52
|
+
|
53
|
+
include HandledExceptions
|
54
|
+
|
52
55
|
def cli_run
|
53
|
-
|
54
|
-
|
56
|
+
# FIXME Handing in the opts like this feels dirty
|
57
|
+
with_handled_exceptions(ArgParse.new) do |opts|
|
55
58
|
actor = Actions.new
|
56
59
|
actor.config = config
|
57
60
|
actor.opts = opts
|
58
61
|
actor.send(opts.options[:action])
|
59
|
-
rescue Usage
|
60
|
-
opts.usage
|
61
|
-
rescue NoSuchAccount
|
62
|
-
puts "No such account"
|
63
|
-
opts.usage
|
64
|
-
rescue NoDefaultAccount
|
65
|
-
puts "No default account configured."
|
66
|
-
rescue NoSuchCommand
|
67
|
-
puts "No such command"
|
68
|
-
opts.usage
|
69
|
-
rescue NoConfigFile
|
70
|
-
puts "No config file, create one with twat -a [user|nick]"
|
71
|
-
opts.usage
|
72
|
-
rescue InvalidSetOpt
|
73
|
-
puts "There is no such configurable option"
|
74
|
-
opts.usage
|
75
|
-
rescue RequiresOptVal
|
76
|
-
puts "--set must take an option=value pair as arguments"
|
77
|
-
rescue InvalidCredentials
|
78
|
-
puts "Invalid credentials, try reauthenticating with"
|
79
|
-
puts "twat -a #{opts[:account]}"
|
80
|
-
rescue ConfigVersionIncorrect
|
81
|
-
puts "Your config file is out of date. Run with --update-config to rememdy"
|
82
|
-
rescue InvalidBool
|
83
|
-
puts "Invalid value, valid values are #{Options::BOOL_VALID.join("|")}"
|
84
|
-
rescue InvalidInt
|
85
|
-
puts "Invalid value, must be an integer"
|
86
|
-
rescue Errno::ECONNRESET
|
87
|
-
puts "Connection was reset by third party."
|
88
|
-
rescue TweetTooLong
|
89
|
-
puts "Twitter enforces a maximum status length of 140 characters"
|
90
62
|
end
|
91
63
|
end
|
92
64
|
end
|
data/lib/twat/actions.rb
CHANGED
@@ -176,7 +176,12 @@ module Twat
|
|
176
176
|
end
|
177
177
|
|
178
178
|
def account
|
179
|
-
@account
|
179
|
+
@account ||= config.accounts[account_name]
|
180
|
+
unless @account
|
181
|
+
raise NoSuchAccount
|
182
|
+
else
|
183
|
+
return @account
|
184
|
+
end
|
180
185
|
end
|
181
186
|
|
182
187
|
def account_name
|
data/lib/twat/exceptions.rb
CHANGED
@@ -11,4 +11,44 @@ module Twat
|
|
11
11
|
class InvalidBool < Exception; end
|
12
12
|
class InvalidInt < Exception; end
|
13
13
|
class TweetTooLong < Exception; end
|
14
|
+
|
15
|
+
module HandledExceptions
|
16
|
+
def with_handled_exceptions(opts)
|
17
|
+
begin
|
18
|
+
# FIXME
|
19
|
+
yield opts
|
20
|
+
rescue Usage
|
21
|
+
opts.usage
|
22
|
+
rescue NoSuchAccount
|
23
|
+
puts "No such account"
|
24
|
+
opts.usage
|
25
|
+
rescue NoDefaultAccount
|
26
|
+
puts "No default account configured."
|
27
|
+
rescue NoSuchCommand
|
28
|
+
puts "No such command"
|
29
|
+
opts.usage
|
30
|
+
rescue NoConfigFile
|
31
|
+
puts "No config file, create one with twat -a [user|nick]"
|
32
|
+
opts.usage
|
33
|
+
rescue InvalidSetOpt
|
34
|
+
puts "There is no such configurable option"
|
35
|
+
opts.usage
|
36
|
+
rescue RequiresOptVal
|
37
|
+
puts "--set must take an option=value pair as arguments"
|
38
|
+
rescue InvalidCredentials
|
39
|
+
puts "Invalid credentials, try reauthenticating with"
|
40
|
+
puts "twat -a #{opts[:account]}"
|
41
|
+
rescue ConfigVersionIncorrect
|
42
|
+
puts "Your config file is out of date. Run with --update-config to rememdy"
|
43
|
+
rescue InvalidBool
|
44
|
+
puts "Invalid value, valid values are #{Options::BOOL_VALID.join("|")}"
|
45
|
+
rescue InvalidInt
|
46
|
+
puts "Invalid value, must be an integer"
|
47
|
+
rescue Errno::ECONNRESET
|
48
|
+
puts "Connection was reset by third party."
|
49
|
+
rescue TweetTooLong
|
50
|
+
puts "Twitter enforces a maximum status length of 140 characters"
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
14
54
|
end
|
data/man/twat.1
CHANGED
@@ -49,3 +49,8 @@ config to the latest version.
|
|
49
49
|
.IP ~/.twatrc
|
50
50
|
yaml file containing a mapping of account nicknames to oauth credentials.
|
51
51
|
Should always be readable only to you.
|
52
|
+
.SH AUTHOR
|
53
|
+
twat was written by Rich Healey <richo@psych0tik.net>
|
54
|
+
.SH CREDIT
|
55
|
+
twat was inspired by (and began life as a 6 line script invoking) the Twitter
|
56
|
+
gem by John Nunemaker.
|
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.15
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2011-10-17 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: twitter
|
16
|
-
requirement: &
|
16
|
+
requirement: &17618920 !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: *17618920
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: oauth
|
27
|
-
requirement: &
|
27
|
+
requirement: &17618180 !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: *17618180
|
36
36
|
description: Command line tool for tweeting and whatnot
|
37
37
|
email:
|
38
38
|
- richo@psych0tik.net
|
@@ -77,7 +77,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
77
77
|
version: '0'
|
78
78
|
requirements: []
|
79
79
|
rubyforge_project:
|
80
|
-
rubygems_version: 1.8.
|
80
|
+
rubygems_version: 1.8.6
|
81
81
|
signing_key:
|
82
82
|
specification_version: 3
|
83
83
|
summary: Command line tool for tweeting and whatnot
|