francois-tweet 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (6) hide show
  1. data/LICENSE +22 -0
  2. data/README.rdoc +16 -0
  3. data/bin/tweet +11 -0
  4. data/lib/tweet.rb +27 -0
  5. data/test/test_helper.rb +2 -0
  6. metadata +67 -0
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2008 James Golick, GiraffeSoft Inc.
2
+
3
+ Permission is hereby granted, free of charge, to any person
4
+ obtaining a copy of this software and associated documentation
5
+ files (the "Software"), to deal in the Software without
6
+ restriction, including without limitation the rights to use,
7
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the
9
+ Software is furnished to do so, subject to the following
10
+ conditions:
11
+
12
+ The above copyright notice and this permission notice shall be
13
+ included in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
+ OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,16 @@
1
+ = Tweet
2
+
3
+ This is a CLI for sending tweets to twitter.
4
+
5
+ == Configuration:
6
+
7
+ Add a file at ~/.tweet that contains your tempo credentials in YAML form.
8
+
9
+ i.e.
10
+
11
+ username: james
12
+ password: swordfish
13
+
14
+ == Usage:
15
+
16
+ $ tweet "going to walk the dog"
data/bin/tweet ADDED
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ case ARGV.first
4
+ when nil, "--help", "-h", "help"
5
+ abort "Usage: tweet STATUS\nRequires a ~/.tweet YAML file with two keys: username and password."
6
+ when "-v", "--version", "version"
7
+ puts File.read(File.dirname(__FILE__) + "/../tweet.gemspec").split("\n").grep(/version/)
8
+ else
9
+ require File.dirname(__FILE__)+'/../lib/tweet'
10
+ Tweet.create_status(ARGV.join(' '))
11
+ end
data/lib/tweet.rb ADDED
@@ -0,0 +1,27 @@
1
+ $LOAD_PATH << File.dirname(__FILE__)
2
+ require 'rubygems'
3
+ require 'activesupport'
4
+ require 'rest_client'
5
+
6
+ module Tweet
7
+ CONFIG_FILE = ENV['HOME']+'/.tweet'
8
+
9
+ class << self
10
+ attr_accessor :username, :password
11
+
12
+ def create_status(status)
13
+ len = status.length
14
+ abort "Message limit is 140 characters. You currently have #{len}" if len > 140
15
+ get_credentials!
16
+ resource = RestClient::Resource.new 'http://twitter.com/statuses/update.xml', username, password
17
+ resource.post(:status => status, :source => 'tweetgem', :content_type => 'application/xml', :accept => 'application/xml')
18
+ puts "#{len} chars" + (len == 140 ? "!\nYou rock!" : '.')
19
+ end
20
+
21
+ def get_credentials!
22
+ abort "You must create a #{CONFIG_FILE} file to use this CLI." unless File.exist?(CONFIG_FILE)
23
+ config = YAML.load(File.read(CONFIG_FILE)).symbolize_keys
24
+ @username, @password = config[:username], config[:password]
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,2 @@
1
+ require File.dirname(__FILE__)+'/../lib/tweet'
2
+ require 'expectations'
metadata ADDED
@@ -0,0 +1,67 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: francois-tweet
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.3
5
+ platform: ruby
6
+ authors:
7
+ - James Golick
8
+ - Mathieu Martin
9
+ - Francois Beausoleil
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+
14
+ date: 2008-12-19 00:00:00 -08:00
15
+ default_executable:
16
+ dependencies:
17
+ - !ruby/object:Gem::Dependency
18
+ name: technoweenie-rest-client
19
+ version_requirement:
20
+ version_requirements: !ruby/object:Gem::Requirement
21
+ requirements:
22
+ - - ">="
23
+ - !ruby/object:Gem::Version
24
+ version: "0"
25
+ version:
26
+ description: ""
27
+ email: james@giraffesoft.ca
28
+ executables:
29
+ - tweet
30
+ extensions: []
31
+
32
+ extra_rdoc_files: []
33
+
34
+ files:
35
+ - lib/tweet.rb
36
+ - bin/tweet
37
+ - README.rdoc
38
+ - LICENSE
39
+ - test/test_helper.rb
40
+ has_rdoc: false
41
+ homepage: http://twitter.com
42
+ post_install_message:
43
+ rdoc_options: []
44
+
45
+ require_paths:
46
+ - lib
47
+ required_ruby_version: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ version: "0"
52
+ version:
53
+ required_rubygems_version: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: "0"
58
+ version:
59
+ requirements: []
60
+
61
+ rubyforge_project:
62
+ rubygems_version: 1.2.0
63
+ signing_key:
64
+ specification_version: 2
65
+ summary: Update your twitter status from the command line.
66
+ test_files: []
67
+