jmazzi-tweet 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
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.
@@ -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"
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ abort("Usage: tweet 'command'") unless ARGV.length >= 1
4
+
5
+ require File.dirname(__FILE__)+'/../lib/tweet'
6
+ Tweet.create_status(ARGV.join(' '))
@@ -0,0 +1,46 @@
1
+ require 'net/http'
2
+ module TinyUrl
3
+ class << self
4
+ def create(url)
5
+ uri = 'http://tinyurl.com/api-create.php?url=' + url
6
+ uri = URI.parse(uri)
7
+ tiny_url = Net::HTTP.get_response(uri).body
8
+ end
9
+
10
+ # taken from rails
11
+ def auto_link_urls(text)
12
+ auto_link_re = %r{
13
+ ( # leading text
14
+ <\w+.*?>| # leading HTML tag, or
15
+ [^=!:'"/]| # leading punctuation, or
16
+ ^ # beginning of line
17
+ )
18
+ (
19
+ (?:https?://)| # protocol spec, or
20
+ (?:www\.) # www.*
21
+ )
22
+ (
23
+ [-\w]+ # subdomain or domain
24
+ (?:\.[-\w]+)* # remaining subdomains or domain
25
+ (?::\d+)? # port
26
+ (?:/(?:[~\w\+@%=\(\)-]|(?:[,.;:'][^\s$]))*)* # path
27
+ (?:\?[\w\+@%&=.;-]+)? # query string
28
+ (?:\#[\w\-]*)? # trailing anchor
29
+ )
30
+ ([[:punct:]]|<|$|) # trailing text
31
+ }x
32
+
33
+ text.gsub(auto_link_re) do
34
+ all, a, b, c, d = $&, $1, $2, $3, $4
35
+ if a =~ /<a\s/i # don't replace URL's that are already linked
36
+ all
37
+ else
38
+ text = b + c
39
+ url = create("http://#{c}")
40
+ %(#{a}#{url})
41
+ end
42
+ end
43
+ end
44
+
45
+ end
46
+ end
@@ -0,0 +1,26 @@
1
+ $LOAD_PATH << File.dirname(__FILE__)
2
+ require 'rubygems'
3
+ require 'activesupport'
4
+ require 'rest_client'
5
+ require File.dirname(__FILE__)+'/../lib/tiny_url'
6
+
7
+ module Tweet
8
+ CONFIG_FILE = ENV['HOME']+'/.tweet'
9
+
10
+ class << self
11
+ attr_accessor :username, :password
12
+
13
+ def create_status(status)
14
+ get_credentials!
15
+ status = TinyUrl.auto_link_urls(status)
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
+ end
19
+
20
+ def get_credentials!
21
+ abort "You must create a #{CONFIG_FILE} file to use this CLI." unless File.exist?(CONFIG_FILE)
22
+ config = YAML.load(File.read(CONFIG_FILE)).symbolize_keys
23
+ @username, @password = config[:username], config[:password]
24
+ end
25
+ end
26
+ 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: jmazzi-tweet
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.3
5
+ platform: ruby
6
+ authors:
7
+ - James Golick
8
+ - Justin Mazzi
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2008-12-12 00:00:00 -08:00
14
+ default_executable:
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: technoweenie-rest-client
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
24
+ version:
25
+ description: ""
26
+ email: james@giraffesoft.ca
27
+ executables:
28
+ - tweet
29
+ extensions: []
30
+
31
+ extra_rdoc_files: []
32
+
33
+ files:
34
+ - lib/tweet.rb
35
+ - lib/tiny_url.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
+