webmat-tweet 0.0.2 → 0.0.5
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/bin/tweet +12 -4
- data/lib/tweet.rb +15 -4
- metadata +6 -4
data/bin/tweet
CHANGED
@@ -1,7 +1,15 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
|
3
|
+
THIS_FILE = File.symlink?(__FILE__) ? File.readlink(__FILE__) : __FILE__
|
4
|
+
require "#{File.dirname(THIS_FILE)}/../lib/tweet"
|
4
5
|
|
5
|
-
|
6
|
-
|
7
|
-
|
6
|
+
case ARGV.first
|
7
|
+
when nil, "--help", "-h"
|
8
|
+
abort "Usage: tweet STATUS\nRequires a ~/.tweet YAML file with two keys: username and password."
|
9
|
+
when "-v", "--version"
|
10
|
+
puts Gem.loaded_specs["tweet"].version
|
11
|
+
when '-c', '--count'
|
12
|
+
Tweet.create_status(ARGV.join(' '), true)
|
13
|
+
else
|
14
|
+
Tweet.create_status(ARGV.join(' '))
|
15
|
+
end
|
data/lib/tweet.rb
CHANGED
@@ -9,19 +9,30 @@ module Tweet
|
|
9
9
|
class << self
|
10
10
|
attr_accessor :username, :password
|
11
11
|
|
12
|
-
def create_status(status)
|
12
|
+
def create_status(status, just_count = false)
|
13
13
|
len = status.length
|
14
|
+
if just_count
|
15
|
+
puts "Counting... #{len} chars"
|
16
|
+
exit 0
|
17
|
+
end
|
18
|
+
|
14
19
|
abort "Message limit is 140 characters. You currently have #{len}" if len > 140
|
15
20
|
get_credentials!
|
16
|
-
|
17
|
-
|
21
|
+
|
22
|
+
if @debug
|
23
|
+
puts "Would have tweeted:", status
|
24
|
+
else
|
25
|
+
resource = RestClient::Resource.new 'http://twitter.com/statuses/update.xml', username, password
|
26
|
+
resource.post(:status => status, :source => 'tweetgem', :content_type => 'application/xml', :accept => 'application/xml')
|
27
|
+
end
|
18
28
|
puts "#{len} chars" + (len == 140 ? "!\nYou rock!" : '.')
|
19
29
|
end
|
20
30
|
|
21
31
|
def get_credentials!
|
22
32
|
abort "You must create a #{CONFIG_FILE} file to use this CLI." unless File.exist?(CONFIG_FILE)
|
23
33
|
config = YAML.load(File.read(CONFIG_FILE)).symbolize_keys
|
24
|
-
@username, @password = config[:username], config[:password]
|
34
|
+
@username, @password, @debug = config[:username], config[:password], config[:debug]
|
35
|
+
warn " debug mode (not really posting)" if @debug
|
25
36
|
end
|
26
37
|
end
|
27
38
|
end
|
metadata
CHANGED
@@ -1,20 +1,22 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: webmat-tweet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Golick
|
8
8
|
- Mathieu Martin
|
9
|
+
- Francois Beausoleil
|
9
10
|
autorequire:
|
10
11
|
bindir: bin
|
11
12
|
cert_chain: []
|
12
13
|
|
13
|
-
date:
|
14
|
+
date: 2009-02-20 00:00:00 -08:00
|
14
15
|
default_executable:
|
15
16
|
dependencies:
|
16
17
|
- !ruby/object:Gem::Dependency
|
17
18
|
name: technoweenie-rest-client
|
19
|
+
type: :runtime
|
18
20
|
version_requirement:
|
19
21
|
version_requirements: !ruby/object:Gem::Requirement
|
20
22
|
requirements:
|
@@ -22,7 +24,7 @@ dependencies:
|
|
22
24
|
- !ruby/object:Gem::Version
|
23
25
|
version: "0"
|
24
26
|
version:
|
25
|
-
description:
|
27
|
+
description: Tweet from the command-line
|
26
28
|
email: james@giraffesoft.ca
|
27
29
|
executables:
|
28
30
|
- tweet
|
@@ -37,7 +39,7 @@ files:
|
|
37
39
|
- LICENSE
|
38
40
|
- test/test_helper.rb
|
39
41
|
has_rdoc: false
|
40
|
-
homepage: http://twitter.com
|
42
|
+
homepage: http://twitter.com/
|
41
43
|
post_install_message:
|
42
44
|
rdoc_options: []
|
43
45
|
|