twat 0.3.1 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- data/TODO +13 -0
- data/bin/twat +1 -1
- data/lib/twat/actions.rb +20 -20
- data/lib/twat/config.rb +18 -3
- data/lib/twat.rb +20 -4
- metadata +6 -6
data/TODO
CHANGED
@@ -3,3 +3,16 @@ twat -l [count] -> <count entries from newsfeed>
|
|
3
3
|
# Include who tweeted...
|
4
4
|
|
5
5
|
catch invalid options and return opts
|
6
|
+
|
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
|
+
COLORS!
|
16
|
+
=======
|
17
|
+
|
18
|
+
twat -l should dump colors to terminal (This should be configurable tho)
|
data/bin/twat
CHANGED
data/lib/twat/actions.rb
CHANGED
@@ -3,15 +3,16 @@ module Twat
|
|
3
3
|
CONSUMER_TOKENS = [ :consumer_key, :consumer_secret ]
|
4
4
|
class Actions
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
attr_accessor :config, :opts
|
7
|
+
|
8
|
+
def tweet
|
9
|
+
twitter_auth
|
9
10
|
|
10
11
|
Twitter.update(opts.msg)
|
11
12
|
#puts opts.msg
|
12
13
|
end
|
13
14
|
|
14
|
-
def add
|
15
|
+
def add
|
15
16
|
v = Config.consumer_info.map do |key, value|
|
16
17
|
value
|
17
18
|
end
|
@@ -24,48 +25,43 @@ module Twat
|
|
24
25
|
pin = gets.chomp
|
25
26
|
begin
|
26
27
|
access_token = token_request.get_access_token(oauth_verifier: pin)
|
27
|
-
|
28
|
+
config[opts[:account]] = {
|
28
29
|
oauth_token: access_token.token,
|
29
30
|
oauth_token_secret: access_token.secret
|
30
31
|
}
|
31
|
-
|
32
|
+
config.save!
|
32
33
|
rescue OAuth::Unauthorized
|
33
34
|
puts "Couldn't authenticate you, did you enter the pin correctly?"
|
34
35
|
end
|
35
36
|
end
|
36
37
|
|
37
|
-
def delete
|
38
|
-
if
|
39
|
-
|
38
|
+
def delete
|
39
|
+
if config.delete(opts[:account])
|
40
|
+
config.save!
|
40
41
|
puts "Successfully deleted"
|
41
42
|
else
|
42
43
|
puts "No such account"
|
43
44
|
end
|
44
45
|
end
|
45
46
|
|
46
|
-
def show
|
47
|
-
twitter_auth
|
47
|
+
def show
|
48
|
+
twitter_auth
|
48
49
|
Twitter.home_timeline.each_with_index do |tweet, idx|
|
49
|
-
puts "#{tweet.user.screen_name}: #{tweet.text}"
|
50
|
+
puts "#{tweet.user.screen_name.bold.cyan}: #{tweet.text}"
|
50
51
|
|
51
52
|
break if idx == opts[:count]
|
52
53
|
end
|
53
54
|
end
|
54
55
|
|
55
|
-
def version
|
56
|
+
def version
|
56
57
|
puts "twat: #{VERSION_MAJOR}.#{VERSION_MINOR}.#{VERSION_PATCH}"
|
57
58
|
end
|
58
59
|
|
59
60
|
private
|
60
61
|
|
61
|
-
def
|
62
|
-
@cf ||= Config.new
|
63
|
-
end
|
64
|
-
|
65
|
-
def twitter_auth(opts)
|
66
|
-
conf = cf[opts[:account]]
|
62
|
+
def twitter_auth
|
67
63
|
Twitter.configure do |twit|
|
68
|
-
|
64
|
+
account.each do |key, value|
|
69
65
|
twit.send("#{key}=", value)
|
70
66
|
end
|
71
67
|
Config.consumer_info.each do |key, value|
|
@@ -74,5 +70,9 @@ module Twat
|
|
74
70
|
end
|
75
71
|
end
|
76
72
|
|
73
|
+
def account
|
74
|
+
@account ||= config[opts[:account]]
|
75
|
+
end
|
76
|
+
|
77
77
|
end
|
78
78
|
end
|
data/lib/twat/config.rb
CHANGED
@@ -1,7 +1,18 @@
|
|
1
|
-
require 'ostruct'
|
2
|
-
|
3
1
|
module Twat
|
4
|
-
class
|
2
|
+
class Twat
|
3
|
+
def configure(&block)
|
4
|
+
yield config
|
5
|
+
|
6
|
+
# If I understand correctly, I can check over what's
|
7
|
+
# happened here?
|
8
|
+
end
|
9
|
+
|
10
|
+
def config
|
11
|
+
@config ||= Config.new
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
class Config
|
5
16
|
|
6
17
|
def config_path
|
7
18
|
@config_path ||= ENV['TWAT_CONFIG'] || "#{ENV['HOME']}/.twatrc"
|
@@ -22,6 +33,10 @@ module Twat
|
|
22
33
|
end
|
23
34
|
end
|
24
35
|
|
36
|
+
def method_missing(meth)
|
37
|
+
self[meth]
|
38
|
+
end
|
39
|
+
|
25
40
|
def [](key)
|
26
41
|
raise NoSuchAccount unless config.include?(key)
|
27
42
|
config[key]
|
data/lib/twat.rb
CHANGED
@@ -10,18 +10,34 @@ require 'oauth'
|
|
10
10
|
require "twat/#{filename}"
|
11
11
|
end
|
12
12
|
|
13
|
+
class String
|
14
|
+
def red
|
15
|
+
"[31m#{self}[39m"
|
16
|
+
end
|
17
|
+
|
18
|
+
def cyan
|
19
|
+
"[36m#{self}[39m"
|
20
|
+
end
|
21
|
+
|
22
|
+
def bold
|
23
|
+
"[1m#{self}[22m"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
13
27
|
module Twat
|
14
28
|
VERSION_MAJOR = 0
|
15
29
|
VERSION_MINOR = 3
|
16
|
-
VERSION_PATCH =
|
30
|
+
VERSION_PATCH = 3
|
17
31
|
|
18
32
|
VERSION = "#{VERSION_MAJOR}.#{VERSION_MINOR}.#{VERSION_PATCH}"
|
19
33
|
class Twat
|
20
|
-
def
|
34
|
+
def cli_run
|
21
35
|
begin
|
22
|
-
action = Actions.new
|
23
36
|
opts = ArgParse.new
|
24
|
-
|
37
|
+
actor = Actions.new
|
38
|
+
actor.config = config
|
39
|
+
actor.opts = opts
|
40
|
+
actor.send(opts.options[:action])
|
25
41
|
rescue Usage
|
26
42
|
opts.usage
|
27
43
|
rescue NoSuchAccount
|
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.3.
|
4
|
+
version: 0.3.3
|
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-28 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: twitter
|
16
|
-
requirement: &
|
16
|
+
requirement: &15834040 !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: *15834040
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: oauth
|
27
|
-
requirement: &
|
27
|
+
requirement: &15831700 !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: *15831700
|
36
36
|
description: Command line tool for tweeting and whatnot
|
37
37
|
email:
|
38
38
|
- richo@psych0tik.net
|