damog-twitlink 0.0.1

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.
Files changed (4) hide show
  1. data/COPYING +14 -0
  2. data/README +9 -0
  3. data/bin/twitlink +68 -0
  4. metadata +58 -0
data/COPYING ADDED
@@ -0,0 +1,14 @@
1
+ DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
2
+ Version 2, December 2004
3
+
4
+ Copyright (C) 2008 David Moreno <david@axiombox.com>
5
+
6
+ Everyone is permitted to copy and distribute verbatim or modified
7
+ copies of this license document, and changing it is allowed as long
8
+ as the name is changed.
9
+
10
+ DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
11
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
12
+
13
+ 0. You just DO WHAT THE FUCK YOU WANT TO.
14
+
data/README ADDED
@@ -0,0 +1,9 @@
1
+ A very simple command-line utility to share links on Twitter.
2
+
3
+ usage:
4
+ twitlink.rb link_url [ custom_title ]
5
+
6
+ To authenticate with Twitter, you have to have a $HOME/.twitter/ directory
7
+ with two files, username and password, each one containing a single
8
+ string with such information.
9
+
data/bin/twitlink ADDED
@@ -0,0 +1,68 @@
1
+ #!/usr/bin/ruby
2
+
3
+ # David Moreno <david@axiombox.com>
4
+
5
+ $version = '0.1rc1'
6
+ require 'open-uri'
7
+
8
+ username_file = ENV["HOME"] + '/.twitter/username'
9
+ password_file = ENV["HOME"] + '/.twitter/password'
10
+
11
+ def usage
12
+ puts <<EOF
13
+ twitlink #{$version} - http://github.com/damog/twitlink
14
+ David Moreno <david@axiombox.com>
15
+ Raquel Hernández <raquel@axiombox.com>
16
+
17
+ usage:
18
+ #{__FILE__} link_url [ custom_title ]"
19
+
20
+ EOF
21
+ exit
22
+ end
23
+
24
+ unless ARGV[0]
25
+ usage()
26
+ end
27
+
28
+ begin
29
+ username = File.new(username_file).read.chomp
30
+ password = File.new(password_file).read.chomp
31
+ rescue
32
+ puts "It seems that you don't have the twitter authentication files .."
33
+ puts " Run twitlink-prompt to create the auth files."
34
+ exit
35
+ end
36
+
37
+ if ARGV[1]
38
+ title = ARGV[1]
39
+ else
40
+ html = open(ARGV[0]).read
41
+ html =~ /<title>(.+?)<\/title>/im
42
+ if $1
43
+ title = $1
44
+ else
45
+ title = "Check this out!"
46
+ puts "I couldn't find title"
47
+ end
48
+ end
49
+
50
+ status = "#{title} ☛ #{open("http://awbox.com/new?url=#{ARGV[0]}").read}"
51
+
52
+ url = URI.parse('http://twitter.com/statuses/update.xml')
53
+ req = Net::HTTP::Post.new(url.path)
54
+ req.basic_auth username, password
55
+ req.set_form_data({'status' => status, 'source' => 'twitlink'})
56
+
57
+ res = Net::HTTP.new(url.host, url.port).start {|http| http.request(req) }
58
+
59
+ # this is retarded and should parse correctly the XML
60
+ if res.body =~ /<error>/
61
+ puts "ERROR"
62
+ puts " twitter said:"
63
+ puts res.body
64
+ else
65
+ puts status
66
+ puts "OK."
67
+ end
68
+
metadata ADDED
@@ -0,0 +1,58 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: damog-twitlink
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - David Moreno <david@axiombox.com>
8
+ - "Raquel Hern\xC3\xA1ndez <raquel@axiombox.com>"
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2008-12-11 00:00:00 -08:00
14
+ default_executable:
15
+ dependencies: []
16
+
17
+ description: A very simple command-line utility to share links on your Twitter profile
18
+ email: rt@support.axiombox.com
19
+ executables: []
20
+
21
+ extensions: []
22
+
23
+ extra_rdoc_files:
24
+ - COPYING
25
+ - README
26
+ files:
27
+ - README
28
+ - COPYING
29
+ - bin/twitlink
30
+ has_rdoc: true
31
+ homepage: http://axiombox.com/twitlink
32
+ post_install_message:
33
+ rdoc_options:
34
+ - --main
35
+ - README
36
+ require_paths:
37
+ - lib
38
+ required_ruby_version: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: "0"
43
+ version:
44
+ required_rubygems_version: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: "0"
49
+ version:
50
+ requirements: []
51
+
52
+ rubyforge_project:
53
+ rubygems_version: 1.2.0
54
+ signing_key:
55
+ specification_version: 2
56
+ summary: A very simple command-line utility to share links on your Twitter profile
57
+ test_files: []
58
+