twat 0.2.7 → 0.3.0

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 CHANGED
@@ -1,2 +1,5 @@
1
1
  twat -l -> <newsfeed>
2
2
  twat -l [count] -> <count entries from newsfeed>
3
+ # Include who tweeted...
4
+
5
+ catch invalid options and return opts
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
- conf = cf[opts[:account]]
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
- puts "#{opts[:count]} Tweets XD"
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
- opts.on('-n', '--account ACCOUNT', 'Tweet from ACCOUNT (or default)') do |acct|
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
- #opts.on( '-a' '--add ACCOUNT' ) do |acct|
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
- @configthingfucken ||= getopts
64
+ begin
65
+ @configthingfucken ||= getopts
66
+ rescue OptionParser::InvalidOption
67
+ usage "Unknown option"
68
+ end
65
69
  end
66
70
 
67
71
  end
@@ -2,4 +2,5 @@ module Twat
2
2
  class NoSuchAccount < Exception; end
3
3
  class NoConfigFile < Exception; end
4
4
  class Usage < Exception; end
5
+ class InvalidCredentials < Exception; end
5
6
  end
data/lib/twat.rb CHANGED
@@ -12,8 +12,8 @@ end
12
12
 
13
13
  module Twat
14
14
  VERSION_MAJOR = 0
15
- VERSION_MINOR = 2
16
- VERSION_PATCH = 7
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.2.7
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-19 00:00:00.000000000Z
12
+ date: 2011-09-21 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: twitter
16
- requirement: &11627540 !ruby/object:Gem::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: *11627540
24
+ version_requirements: *74735110
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: oauth
27
- requirement: &11626400 !ruby/object:Gem::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: *11626400
35
+ version_requirements: *74734800
36
36
  description: Command line tool for tweeting and whatnot
37
37
  email:
38
38
  - richo@psych0tik.net