twat 0.1.0 → 0.2.3

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/README CHANGED
@@ -10,7 +10,10 @@ Also as an excuse to learn more ruby in my spare time
10
10
 
11
11
  == Release status
12
12
 
13
- This is massively pre-alpha. I plan to do my best to leave it in a
14
- consistent-ish state so that I can use it for day to day use, but the config
15
- format is liable to change at short notice. If things suddenly fail, that's
16
- probably a good place to look.
13
+ Ok, so it's less pre-alpha now. I've pushed it to Rubygems and it seems to work
14
+ in the limited testing that I've done.
15
+
16
+ == Credits and thanks
17
+
18
+ I used a lot the structure from codeplane to work out how to structure it. It's
19
+ obviously not as neat, but the gemspec was shamelessly adapted from codeplane
data/lib/twat.rb CHANGED
@@ -12,8 +12,8 @@ end
12
12
 
13
13
  module Twat
14
14
  VERSION_MAJOR = 0
15
- VERSION_MINOR = 1
16
- VERSION_PATCH = 0
15
+ VERSION_MINOR = 2
16
+ VERSION_PATCH = 3
17
17
 
18
18
  VERSION = "#{VERSION_MAJOR}.#{VERSION_MINOR}.#{VERSION_PATCH}"
19
19
  class Twat
data/lib/twat/actions.rb CHANGED
@@ -31,14 +31,26 @@ module Twat
31
31
  token_request = oauth.get_request_token()
32
32
  puts "Please authenticate the application at #{token_request.authorize_url}, then enter pin"
33
33
  pin = gets.chomp
34
- access_token = token_request.get_access_token(oauth_verifier: pin)
35
- cf[opts[:account]] = {
36
- oauth_token: access_token.token,
37
- oauth_token_secret: access_token.secret
38
- }
39
- cf.save!
34
+ begin
35
+ access_token = token_request.get_access_token(oauth_verifier: pin)
36
+ cf[opts[:account]] = {
37
+ oauth_token: access_token.token,
38
+ oauth_token_secret: access_token.secret
39
+ }
40
+ cf.save!
41
+ rescue OAuth::Unauthorized
42
+ puts "Couldn't authenticate you, did you enter the pin correctly?"
43
+ end
40
44
  end
41
45
 
46
+ def delete(opts)
47
+ if cf.delete(opts[:account])
48
+ cf.save!
49
+ puts "Successfully deleted"
50
+ else
51
+ puts "No such account"
52
+ end
53
+ end
42
54
 
43
55
  private
44
56
 
data/lib/twat/argparse.rb CHANGED
@@ -14,14 +14,19 @@ module Twat
14
14
  options = Hash.new
15
15
  @optparser = OptionParser.new do |opts|
16
16
  options[:action] = :tweet
17
- opts.banner = "Usage: #{$0} -a ACCOUNT <tweet>"
18
- opts.on('-n', '--account ACCOUNT', 'Tweet from ACCOUNT') do |acct|
17
+ options[:account] = :default
18
+ opts.banner = "Usage: twat <tweet>"
19
+ opts.on('-n', '--account ACCOUNT', 'Tweet from ACCOUNT (or default)') do |acct|
19
20
  options[:account] = acct.to_sym
20
21
  end
21
22
  opts.on('-a', '--add ACCOUNT', 'Configure and authorise ACCOUNT') do |acct|
22
23
  options[:account] = acct.to_sym
23
24
  options[:action] = :add
24
25
  end
26
+ opts.on('-d', '--delete ACCOUNT', 'Delete ACCOUNT') do |acct|
27
+ options[:account] = acct.to_sym
28
+ options[:action] = :delete
29
+ end
25
30
  #opts.on( '-a' '--add ACCOUNT' ) do |acct|
26
31
  #end
27
32
  opts.on('-h', '--help', 'Display this screen') do
data/lib/twat/config.rb CHANGED
@@ -13,6 +13,7 @@ module Twat
13
13
 
14
14
  def save!
15
15
  File.open(config_path, 'w') do |conf|
16
+ conf.chmod(0600)
16
17
  conf.puts(@config.to_yaml)
17
18
  end
18
19
  end
@@ -26,6 +27,10 @@ module Twat
26
27
  config[key] = value
27
28
  end
28
29
 
30
+ def delete(key)
31
+ config.delete(key)
32
+ end
33
+
29
34
  def self.consumer_info
30
35
  {
31
36
  consumer_key: "jtI2q3Z4NIJAehBG4ntPIQ",
data/twat.gemspec ADDED
@@ -0,0 +1,20 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "twat"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "twat"
7
+ s.version = Twat::VERSION
8
+ s.authors = ["Rich Healey"]
9
+ s.email = ["richo@psych0tik.net"]
10
+ s.homepage = "http://github.com/richoH/twat"
11
+ s.summary = "Command line tool for tweeting and whatnot"
12
+ s.description = s.summary
13
+
14
+ s.add_dependency "twitter"
15
+ s.add_dependency "oauth"
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+ 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.1.0
4
+ version: 0.2.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2011-08-27 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: twitter
16
- requirement: &15376060 !ruby/object:Gem::Requirement
16
+ requirement: &14664640 !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: *15376060
24
+ version_requirements: *14664640
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: oauth
27
- requirement: &15373000 !ruby/object:Gem::Requirement
27
+ requirement: &14662940 !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: *15373000
35
+ version_requirements: *14662940
36
36
  description: Command line tool for tweeting and whatnot
37
37
  email:
38
38
  - richo@psych0tik.net
@@ -50,6 +50,7 @@ files:
50
50
  - lib/twat/argparse.rb
51
51
  - lib/twat/config.rb
52
52
  - lib/twat/exceptions.rb
53
+ - twat.gemspec
53
54
  homepage: http://github.com/richoH/twat
54
55
  licenses: []
55
56
  post_install_message: