tweetwine 0.2.12 → 0.3.0
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/CHANGELOG.rdoc +7 -0
- data/Gemfile +17 -0
- data/README.md +57 -47
- data/Rakefile +17 -26
- data/bin/tweetwine +11 -12
- data/contrib/tweetwine-completion.bash +2 -3
- data/example/application_behavior_example.rb +173 -0
- data/example/example_helper.rb +44 -28
- data/example/fixture/config.yaml +8 -0
- data/example/fixture/shorten_rubygems.html +5 -0
- data/example/fixture/shorten_rubylang.html +5 -0
- data/example/fixture/update_utf8.json +1 -0
- data/example/fixture/update_with_urls.json +1 -0
- data/example/fixture/{update.json → update_without_urls.json} +0 -0
- data/example/search_statuses_example.rb +49 -16
- data/example/show_followers_example.rb +7 -8
- data/example/show_friends_example.rb +7 -8
- data/example/show_home_example.rb +19 -16
- data/example/show_mentions_example.rb +8 -9
- data/example/show_user_example.rb +16 -13
- data/example/update_status_example.rb +143 -26
- data/example/use_http_proxy_example.rb +40 -20
- data/lib/tweetwine/basic_object.rb +19 -0
- data/lib/tweetwine/character_encoding.rb +59 -0
- data/lib/tweetwine/cli.rb +354 -230
- data/lib/tweetwine/config.rb +65 -0
- data/lib/tweetwine/http.rb +120 -0
- data/lib/tweetwine/oauth.rb +104 -0
- data/lib/tweetwine/obfuscate.rb +21 -0
- data/lib/tweetwine/option_parser.rb +31 -0
- data/lib/tweetwine/promise.rb +39 -0
- data/lib/tweetwine/twitter.rb +211 -0
- data/lib/tweetwine/{io.rb → ui.rb} +30 -21
- data/lib/tweetwine/url_shortener.rb +15 -9
- data/lib/tweetwine/util.rb +30 -15
- data/lib/tweetwine.rb +72 -12
- data/man/tweetwine.7 +43 -69
- data/man/tweetwine.7.ronn +57 -47
- data/test/character_encoding_test.rb +87 -0
- data/test/cli_test.rb +19 -6
- data/test/config_test.rb +244 -0
- data/test/fixture/oauth.rb +21 -0
- data/test/fixture/test_config.yaml +4 -4
- data/test/http_test.rb +199 -0
- data/test/oauth_test.rb +77 -0
- data/test/obfuscate_test.rb +16 -0
- data/test/option_parser_test.rb +60 -0
- data/test/promise_test.rb +56 -0
- data/test/test_helper.rb +76 -8
- data/test/twitter_test.rb +625 -0
- data/test/{io_test.rb → ui_test.rb} +92 -74
- data/test/url_shortener_test.rb +115 -135
- data/test/util_test.rb +136 -85
- data/tweetwine.gemspec +53 -0
- metadata +112 -56
- data/example/show_metadata_example.rb +0 -86
- data/lib/tweetwine/client.rb +0 -187
- data/lib/tweetwine/meta.rb +0 -5
- data/lib/tweetwine/options.rb +0 -24
- data/lib/tweetwine/retrying_http.rb +0 -99
- data/lib/tweetwine/startup_config.rb +0 -50
- data/man/tweetwine.1 +0 -109
- data/man/tweetwine.1.ronn +0 -69
- data/test/client_test.rb +0 -544
- data/test/options_test.rb +0 -45
- data/test/retrying_http_test.rb +0 -147
- data/test/startup_config_test.rb +0 -162
@@ -2,30 +2,36 @@
|
|
2
2
|
|
3
3
|
module Tweetwine
|
4
4
|
class UrlShortener
|
5
|
-
def initialize(
|
6
|
-
|
7
|
-
options = Options.new(options, "URL shortening")
|
5
|
+
def initialize(options)
|
6
|
+
raise "UrlShortener should be disabled" if options[:disable]
|
8
7
|
@method = (options[:method] || :get).to_sym
|
9
|
-
|
10
|
-
|
11
|
-
|
8
|
+
unless [:get, :post].include? @method
|
9
|
+
raise CommandLineError, "Unsupported HTTP request method for URL shortening: #{@method}"
|
10
|
+
end
|
11
|
+
@service_url = require_option options, :service_url
|
12
|
+
@url_param_name = require_option options, :url_param_name
|
13
|
+
@xpath_selector = require_option options, :xpath_selector
|
14
|
+
@extra_params = options[:extra_params] || {}
|
12
15
|
if @method == :get
|
13
16
|
tmp = []
|
14
17
|
@extra_params.each_pair { |k, v| tmp << "#{k}=#{v}" }
|
15
18
|
@extra_params = tmp
|
16
19
|
end
|
17
|
-
@xpath_selector = options.require :xpath_selector
|
18
20
|
end
|
19
21
|
|
20
22
|
def shorten(url)
|
21
23
|
require "nokogiri"
|
22
|
-
response =
|
24
|
+
response = CLI.http.send(@method, *get_service_url_and_params(url))
|
23
25
|
doc = Nokogiri::HTML(response)
|
24
26
|
doc.xpath(@xpath_selector).first.to_s
|
25
27
|
end
|
26
28
|
|
27
29
|
private
|
28
30
|
|
31
|
+
def require_option(options, key)
|
32
|
+
options[key] or raise RequiredOptionError.new(key, :url_shortener)
|
33
|
+
end
|
34
|
+
|
29
35
|
def get_service_url_and_params(url_to_shorten)
|
30
36
|
case @method
|
31
37
|
when :get
|
@@ -38,7 +44,7 @@ module Tweetwine
|
|
38
44
|
params = @extra_params.merge({ @url_param_name.to_sym => url_to_shorten })
|
39
45
|
[service_url, params]
|
40
46
|
else
|
41
|
-
raise "Unrecognized HTTP request method"
|
47
|
+
raise "Unrecognized HTTP request method; should have been supported"
|
42
48
|
end
|
43
49
|
end
|
44
50
|
end
|
data/lib/tweetwine/util.rb
CHANGED
@@ -6,7 +6,13 @@ require "uri"
|
|
6
6
|
|
7
7
|
module Tweetwine
|
8
8
|
module Util
|
9
|
-
|
9
|
+
extend self
|
10
|
+
|
11
|
+
def blank?(str)
|
12
|
+
str.nil? || str.empty?
|
13
|
+
end
|
14
|
+
|
15
|
+
def humanize_time_diff(from, to)
|
10
16
|
from = Time.parse(from.to_s) unless from.is_a? Time
|
11
17
|
to = Time.parse(to.to_s) unless to.is_a? Time
|
12
18
|
|
@@ -22,16 +28,15 @@ module Tweetwine
|
|
22
28
|
[value, pluralize_unit(value, unit)]
|
23
29
|
end
|
24
30
|
|
25
|
-
def
|
26
|
-
hash
|
27
|
-
value = pair.last
|
28
|
-
value = symbolize_hash_keys(value) if value.is_a? Hash
|
29
|
-
result[pair.first.to_sym] = value
|
30
|
-
result
|
31
|
-
end
|
31
|
+
def stringify_hash_keys(hash)
|
32
|
+
recursive_copy_hash(hash) { |key, value| [key.to_s, value] }
|
32
33
|
end
|
33
34
|
|
34
|
-
def
|
35
|
+
def symbolize_hash_keys(hash)
|
36
|
+
recursive_copy_hash(hash) { |key, value| [key.to_sym, value] }
|
37
|
+
end
|
38
|
+
|
39
|
+
def parse_int_gt(value, default, min, name_for_error)
|
35
40
|
if value
|
36
41
|
value = value.to_i
|
37
42
|
if value >= min
|
@@ -44,7 +49,7 @@ module Tweetwine
|
|
44
49
|
end
|
45
50
|
end
|
46
51
|
|
47
|
-
def
|
52
|
+
def str_gsub_by_group(str, regexp)
|
48
53
|
dup_str = str.dup
|
49
54
|
str_pos, dup_pos = 0, 0
|
50
55
|
while str_pos < str.size && (match_data = regexp.match(str[str_pos..-1]))
|
@@ -64,15 +69,15 @@ module Tweetwine
|
|
64
69
|
dup_str
|
65
70
|
end
|
66
71
|
|
67
|
-
def
|
72
|
+
def percent_encode(str)
|
68
73
|
URI.escape(str.to_s, /[^#{URI::PATTERN::UNRESERVED}]/)
|
69
74
|
end
|
70
75
|
|
71
|
-
def
|
76
|
+
def unescape_html(str)
|
72
77
|
CGI.unescapeHTML(str.gsub(' ', ' '))
|
73
78
|
end
|
74
79
|
|
75
|
-
def
|
80
|
+
def find_hash_path(hash, path)
|
76
81
|
return nil if hash.nil?
|
77
82
|
path = [path] unless path.is_a? Array
|
78
83
|
path.inject(hash) do |result, key|
|
@@ -83,14 +88,24 @@ module Tweetwine
|
|
83
88
|
|
84
89
|
private
|
85
90
|
|
86
|
-
def
|
91
|
+
def recursive_copy_hash(hash, &pair_modifier)
|
92
|
+
hash.inject({}) do |result, pair|
|
93
|
+
value = pair.last
|
94
|
+
value = recursive_copy_hash(value, &pair_modifier) if value.is_a? Hash
|
95
|
+
key, value = pair_modifier.call(pair.first, value)
|
96
|
+
result[key] = value
|
97
|
+
result
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
def pluralize_unit(value, unit)
|
87
102
|
if ["hour", "day"].include?(unit) && value > 1
|
88
103
|
unit = unit + "s"
|
89
104
|
end
|
90
105
|
unit
|
91
106
|
end
|
92
107
|
|
93
|
-
def
|
108
|
+
def indexes_of_filled_matches(match_data)
|
94
109
|
if match_data.size > 1
|
95
110
|
(1...match_data.size).to_a.reject { |i| match_data[i].nil? }
|
96
111
|
else
|
data/lib/tweetwine.rb
CHANGED
@@ -1,15 +1,75 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
3
|
+
gem 'oauth', '~> 0.4.4'
|
4
|
+
|
5
|
+
module Tweetwine
|
6
|
+
VERSION = '0.3.0'.freeze
|
7
|
+
|
8
|
+
class Error < StandardError
|
9
|
+
@status_code = 42
|
10
|
+
|
11
|
+
# Idea got from Bundler.
|
12
|
+
def self.status_code(code = nil)
|
13
|
+
return @status_code unless code
|
14
|
+
@status_code = code
|
15
|
+
end
|
16
|
+
|
17
|
+
def status_code
|
18
|
+
self.class.status_code
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
class CommandLineError < Error; status_code(13); end
|
23
|
+
class UnknownCommandError < Error; status_code(14); end
|
24
|
+
|
25
|
+
class RequiredOptionError < Error
|
26
|
+
status_code(15)
|
27
|
+
|
28
|
+
attr_reader :key, :owner
|
29
|
+
|
30
|
+
def initialize(key, owner)
|
31
|
+
@key, @owner = key, owner
|
32
|
+
end
|
33
|
+
|
34
|
+
def to_s
|
35
|
+
"#{key} is required for #{owner}"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
class ConnectionError < Error; status_code(21); end
|
40
|
+
class TimeoutError < Error; status_code(22); end
|
41
|
+
|
42
|
+
class HttpError < Error
|
43
|
+
status_code(25)
|
44
|
+
|
45
|
+
attr_reader :http_code, :http_message
|
46
|
+
|
47
|
+
def initialize(code, message)
|
48
|
+
@http_code, @http_message = code.to_i, message
|
49
|
+
end
|
50
|
+
|
51
|
+
def to_s
|
52
|
+
"#{http_code} #{http_message}"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
class TranscodeError < Error; status_code(31); end
|
57
|
+
class AuthorizationError < Error; status_code(32); end
|
58
|
+
|
59
|
+
lib_path = File.expand_path(File.dirname(__FILE__))
|
60
|
+
|
61
|
+
require "#{lib_path}/tweetwine/basic_object"
|
62
|
+
|
63
|
+
autoload :CharacterEncoding, "#{lib_path}/tweetwine/character_encoding"
|
64
|
+
autoload :CLI, "#{lib_path}/tweetwine/cli"
|
65
|
+
autoload :Config, "#{lib_path}/tweetwine/config"
|
66
|
+
autoload :Http, "#{lib_path}/tweetwine/http"
|
67
|
+
autoload :OAuth, "#{lib_path}/tweetwine/oauth"
|
68
|
+
autoload :Obfuscate, "#{lib_path}/tweetwine/obfuscate"
|
69
|
+
autoload :OptionParser, "#{lib_path}/tweetwine/option_parser"
|
70
|
+
autoload :Promise, "#{lib_path}/tweetwine/promise"
|
71
|
+
autoload :Twitter, "#{lib_path}/tweetwine/twitter"
|
72
|
+
autoload :UI, "#{lib_path}/tweetwine/ui"
|
73
|
+
autoload :UrlShortener, "#{lib_path}/tweetwine/url_shortener"
|
74
|
+
autoload :Util, "#{lib_path}/tweetwine/util"
|
15
75
|
end
|
data/man/tweetwine.7
CHANGED
@@ -1,16 +1,16 @@
|
|
1
|
-
.\" generated with Ronn/v0.
|
2
|
-
.\" http://github.com/rtomayko/ronn/
|
1
|
+
.\" generated with Ronn/v0.7.3
|
2
|
+
.\" http://github.com/rtomayko/ronn/tree/0.7.3
|
3
3
|
.
|
4
|
-
.TH "TWEETWINE" "7" "
|
4
|
+
.TH "TWEETWINE" "7" "November 2010" "Tuomas Kareinen" "Tweetwine Manual"
|
5
5
|
.
|
6
6
|
.SH "NAME"
|
7
|
-
\fBtweetwine\fR
|
7
|
+
\fBtweetwine\fR \- a simple Twitter command line agent
|
8
8
|
.
|
9
9
|
.SH "DESCRIPTION"
|
10
|
-
Tweetwine
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
Tweetwine is designed for checking the latest tweets from the command line quickly\.
|
11
|
+
.
|
12
|
+
.P
|
13
|
+
The program can show the home timeline of the authenticated user, the latest tweets of friends and followers, and the latest tweets that mention the user\. If that\'s not enough, Tweetwine can search statuses with arbitrary terms and send status updates\.
|
14
14
|
.
|
15
15
|
.P
|
16
16
|
Features:
|
@@ -22,8 +22,7 @@ Simple to use command line interface, with Bash completion support
|
|
22
22
|
ANSI coloring of statuses, but in discreet manner
|
23
23
|
.
|
24
24
|
.IP "\(bu" 4
|
25
|
-
Supports shortening URLs in a status update with a configurable shortening
|
26
|
-
service
|
25
|
+
Supports shortening URLs in a status update with a configurable shortening service
|
27
26
|
.
|
28
27
|
.IP "\(bu" 4
|
29
28
|
Configuration file for preferred settings
|
@@ -44,14 +43,13 @@ $ gem install tweetwine
|
|
44
43
|
.IP "" 0
|
45
44
|
.
|
46
45
|
.P
|
47
|
-
The program is
|
46
|
+
The program is tested with Ruby 1\.8\.7 and 1\.9\.2\.
|
48
47
|
.
|
49
48
|
.P
|
50
|
-
The program requires \
|
51
|
-
gem to be installed. In addition, the program needs \fIjson\fR gem on Ruby 1.8.
|
49
|
+
The program requires oauth \fIhttp://oauth\.rubyforge\.org/\fR gem to be installed\. In addition, the program needs json \fIhttp://json\.rubyforge\.org/\fR gem on Ruby 1\.8\.
|
52
50
|
.
|
53
51
|
.P
|
54
|
-
|
52
|
+
This documentation page is also provided as a manual page\. Use gem\-man \fIhttp://github\.com/defunkt/gem\-man\fR to see it:
|
55
53
|
.
|
56
54
|
.IP "" 4
|
57
55
|
.
|
@@ -70,139 +68,115 @@ In the command line, run the program by entering
|
|
70
68
|
.
|
71
69
|
.nf
|
72
70
|
|
73
|
-
$ tweetwine [
|
71
|
+
$ tweetwine [global_options\.\.] [command] [command_options\.\.\.]
|
74
72
|
.
|
75
73
|
.fi
|
76
74
|
.
|
77
75
|
.IP "" 0
|
78
76
|
.
|
79
77
|
.P
|
80
|
-
|
81
|
-
information can be supplied either via a configuration file or as an option
|
82
|
-
(\fB\-a USERNAME:PASSWORD\fR) to the program. It is recommended to use the former
|
83
|
-
method over the latter.
|
84
|
-
.
|
85
|
-
.P
|
86
|
-
The configuration file, in \fB~/.tweetwine\fR, is in YAML syntax. The program
|
87
|
-
recognizes the following basic settings:
|
78
|
+
For all the global options and commands, see:
|
88
79
|
.
|
89
80
|
.IP "" 4
|
90
81
|
.
|
91
82
|
.nf
|
92
83
|
|
93
|
-
|
94
|
-
password: <your_password>
|
95
|
-
colors: true|false
|
84
|
+
$ tweetwine help
|
96
85
|
.
|
97
86
|
.fi
|
98
87
|
.
|
99
88
|
.IP "" 0
|
100
89
|
.
|
101
90
|
.P
|
102
|
-
For
|
91
|
+
For information about a specific command and its options, enter:
|
103
92
|
.
|
104
93
|
.IP "" 4
|
105
94
|
.
|
106
95
|
.nf
|
107
96
|
|
108
|
-
$ tweetwine help
|
97
|
+
$ tweetwine help <command>
|
109
98
|
.
|
110
99
|
.fi
|
111
100
|
.
|
112
101
|
.IP "" 0
|
113
102
|
.
|
114
103
|
.P
|
115
|
-
|
104
|
+
In order to use to use the program, you must authorize it to access your account on Twitter\. This is done with OAuth \fIhttp://dev\.twitter\.com/pages/oauth_faq\fR protocol, and it is required when the program is launched for the first time\. After that, Tweetwine remembers the access you granted by storing the access token into \fB~/\.tweetwine\fR\. The file serves as your configuration file\.
|
105
|
+
.
|
106
|
+
.P
|
107
|
+
Because the access token is sensitive information, Tweetwine obfuscates it when storing it into the configuration file\. While this prevents simple plain text reading attempts of the access token, it is not secure\. You should restrict access to the file only to yourself\. If the configuration file does not exist before running the program, Tweetwine sets the file accessible only to you when storing the access token\.
|
108
|
+
.
|
109
|
+
.P
|
110
|
+
The configuration file is in YAML syntax\. In addition to the OAuth access token, the program recognizes the following settings:
|
116
111
|
.
|
117
112
|
.IP "" 4
|
118
113
|
.
|
119
114
|
.nf
|
120
115
|
|
121
|
-
|
116
|
+
colors: true|false
|
117
|
+
username: <your_username>
|
122
118
|
.
|
123
119
|
.fi
|
124
120
|
.
|
125
121
|
.IP "" 0
|
126
122
|
.
|
127
|
-
.SS "URL shortening for status update"
|
128
|
-
Before actually sending a status update, it is possible for the software to
|
129
|
-
shorten the URLs in the update by using an external web service. This can be
|
130
|
-
enabled via the \fBshorten_urls\fR key in configuration file; for example:
|
123
|
+
.SS "URL shortening for a status update"
|
124
|
+
Before actually sending a new status update, it is possible for the software to shorten the URLs in the tweet by using an external web service\. This can be enabled via \fBshorten_urls\fR field in the configuration file; for example:
|
131
125
|
.
|
132
126
|
.IP "" 4
|
133
127
|
.
|
134
128
|
.nf
|
135
129
|
|
136
130
|
username: spoonman
|
137
|
-
password: withyourhands
|
138
131
|
colors: true
|
139
132
|
shorten_urls:
|
140
|
-
|
141
|
-
service_url: http://is.gd/create.php
|
133
|
+
service_url: http://is\.gd/create\.php
|
142
134
|
method: post
|
143
135
|
url_param_name: URL
|
144
|
-
xpath_selector: //input[@id
|
136
|
+
xpath_selector: //input[@id=\'short_url\']/@value
|
137
|
+
disable: false # optional
|
145
138
|
.
|
146
139
|
.fi
|
147
140
|
.
|
148
141
|
.IP "" 0
|
149
142
|
.
|
150
143
|
.P
|
151
|
-
The supported methods (in \fBmethod\fR) are \fBget\fR and \fBpost\fR
|
152
|
-
affects whether parameters are passed as URL query parameters or as payload
|
153
|
-
in the HTTP request, respectively. Extra parameters can be given via \fBextra_params\fR key, as a hash.
|
144
|
+
The supported HTTP request methods (in \fBmethod\fR field) are \fBget\fR and \fBpost\fR\. The method chosen affects whether parameters are passed as URL query parameters or as payload in the HTTP request, respectively\. Extra parameters can be given via \fBextra_params\fR field, as a hash\.
|
154
145
|
.
|
155
146
|
.P
|
156
|
-
The \fBxpath_selector\fR is needed to
|
147
|
+
The \fBxpath_selector\fR field is needed to locate the HTML element which contains the shortened URL from the HTTP response\.
|
157
148
|
.
|
158
149
|
.P
|
159
|
-
URL shortening can be disabled by
|
160
|
-
.
|
161
|
-
.IP "\(bu" 4
|
162
|
-
not defining \fBshorten_urls\fR key in the configuration file,
|
163
|
-
.
|
164
|
-
.IP "\(bu" 4
|
165
|
-
setting key \fBenable\fR to \fBfalse\fR, or
|
166
|
-
.
|
167
|
-
.IP "\(bu" 4
|
168
|
-
using the command line option \fB\-\-no\-url\-shorten\fR.
|
169
|
-
.
|
170
|
-
.IP "" 0
|
150
|
+
URL shortening can be disabled by not defining \fBshorten_urls\fR field in the configuration file, or by setting optional field \fBdisable\fR to true\. In order to disable shortening only temporarily, use the command line option \fB\-\-no\-url\-shorten\fR\.
|
171
151
|
.
|
172
152
|
.P
|
173
|
-
\fINOTE:\fR The use of
|
174
|
-
to be installed.
|
153
|
+
\fINOTE:\fR The use of URL shortening requires nokogiri \fIhttp://nokogiri\.org/\fR gem to be installed\.
|
175
154
|
.
|
176
155
|
.SS "HTTP proxy setting"
|
177
|
-
If \fB$http_proxy\fR environment variable is set, Tweetwine attempts to use the
|
178
|
-
URL in the environment variable as HTTP proxy for all its HTTP connections.
|
179
|
-
This setting can be overridden with \fB\-\-http\-proxy\fR and \fB\-\-no\-http\-proxy\fR
|
180
|
-
command line options.
|
156
|
+
If \fB$http_proxy\fR environment variable is set, Tweetwine attempts to use the URL in the environment variable as HTTP proxy for its HTTP connections\. This setting can be overridden with \fB\-\-http\-proxy\fR and \fB\-\-no\-http\-proxy\fR command line options\.
|
181
157
|
.
|
182
158
|
.SS "Bash command line completion support"
|
183
|
-
Bash shell supports command line completion via tab character
|
184
|
-
enable Tweetwine specific completion with Bash, source the file \fBtweetwine\-completion.bash\fR, located in \fBcontrib\fR directory:
|
159
|
+
Bash shell supports command line completion via tab character\. If you want to enable Tweetwine specific completion with Bash, source the file \fBtweetwine\-completion\.bash\fR, located in \fBcontrib\fR directory:
|
185
160
|
.
|
186
161
|
.IP "" 4
|
187
162
|
.
|
188
163
|
.nf
|
189
164
|
|
190
|
-
|
165
|
+
\&\. contrib/tweetwine\-completion\.bash
|
191
166
|
.
|
192
167
|
.fi
|
193
168
|
.
|
194
169
|
.IP "" 0
|
195
170
|
.
|
196
171
|
.P
|
197
|
-
In order to do this automatically when your shell starts, insert the following
|
198
|
-
snippet to your Bash initialization script (such as \fB~/.bashrc\fR):
|
172
|
+
In order to do this automatically when your shell starts, insert the following snippet to your Bash initialization script (such as \fB~/\.bashrc\fR):
|
199
173
|
.
|
200
174
|
.IP "" 4
|
201
175
|
.
|
202
176
|
.nf
|
203
177
|
|
204
|
-
if [ \-f <path_to_tweetwine>/contrib/tweetwine\-completion
|
205
|
-
|
178
|
+
if [ \-f <path_to_tweetwine>/contrib/tweetwine\-completion\.bash ]; then
|
179
|
+
\. <path_to_tweetwine>/contrib/tweetwine\-completion\.bash
|
206
180
|
fi
|
207
181
|
.
|
208
182
|
.fi
|
@@ -210,7 +184,7 @@ fi
|
|
210
184
|
.IP "" 0
|
211
185
|
.
|
212
186
|
.SH "COPYRIGHT"
|
213
|
-
Tweetwine is Copyright (c) 2009\-2010 Tuomas Kareinen
|
187
|
+
Tweetwine is Copyright (c) 2009\-2010 Tuomas Kareinen\.
|
214
188
|
.
|
215
189
|
.SH "SEE ALSO"
|
216
|
-
|
190
|
+
\fIhttp://github\.com/tuomas/tweetwine\fR
|
data/man/tweetwine.7.ronn
CHANGED
@@ -3,10 +3,13 @@ tweetwine -- a simple Twitter command line agent
|
|
3
3
|
|
4
4
|
## DESCRIPTION
|
5
5
|
|
6
|
-
Tweetwine
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
Tweetwine is designed for checking the latest tweets from the command line
|
7
|
+
quickly.
|
8
|
+
|
9
|
+
The program can show the home timeline of the authenticated user, the latest
|
10
|
+
tweets of friends and followers, and the latest tweets that mention the user.
|
11
|
+
If that's not enough, Tweetwine can search statuses with arbitrary terms and
|
12
|
+
send status updates.
|
10
13
|
|
11
14
|
Features:
|
12
15
|
|
@@ -22,14 +25,14 @@ Install Tweetwine with RubyGems:
|
|
22
25
|
|
23
26
|
$ gem install tweetwine
|
24
27
|
|
25
|
-
The program is
|
28
|
+
The program is tested with Ruby 1.8.7 and 1.9.2.
|
26
29
|
|
27
|
-
The program requires [
|
28
|
-
|
29
|
-
|
30
|
+
The program requires [oauth](http://oauth.rubyforge.org/) gem to be installed.
|
31
|
+
In addition, the program needs [json](http://json.rubyforge.org/) gem on Ruby
|
32
|
+
1.8.
|
30
33
|
|
31
|
-
|
32
|
-
[gem-man](http://github.com/defunkt/gem-man) to see
|
34
|
+
This documentation page is also provided as a manual page. Use
|
35
|
+
[gem-man](http://github.com/defunkt/gem-man) to see it:
|
33
36
|
|
34
37
|
$ gem man tweetwine
|
35
38
|
|
@@ -37,19 +40,7 @@ Documentation is provided as gem man pages. Use
|
|
37
40
|
|
38
41
|
In the command line, run the program by entering
|
39
42
|
|
40
|
-
$ tweetwine [
|
41
|
-
|
42
|
-
The program needs the user's username and password for authentication. This
|
43
|
-
information can be supplied either via a configuration file or as an option
|
44
|
-
(`-a USERNAME:PASSWORD`) to the program. It is recommended to use the former
|
45
|
-
method over the latter.
|
46
|
-
|
47
|
-
The configuration file, in `~/.tweetwine`, is in YAML syntax. The program
|
48
|
-
recognizes the following basic settings:
|
49
|
-
|
50
|
-
username: <your_username>
|
51
|
-
password: <your_password>
|
52
|
-
colors: true|false
|
43
|
+
$ tweetwine [global_options..] [command] [command_options...]
|
53
44
|
|
54
45
|
For all the global options and commands, see:
|
55
46
|
|
@@ -57,46 +48,65 @@ For all the global options and commands, see:
|
|
57
48
|
|
58
49
|
For information about a specific command and its options, enter:
|
59
50
|
|
60
|
-
$ tweetwine help <
|
51
|
+
$ tweetwine help <command>
|
52
|
+
|
53
|
+
In order to use to use the program, you must authorize it to access your
|
54
|
+
account on Twitter. This is done with
|
55
|
+
[OAuth](http://dev.twitter.com/pages/oauth_faq) protocol, and it is required
|
56
|
+
when the program is launched for the first time. After that, Tweetwine
|
57
|
+
remembers the access you granted by storing the access token into
|
58
|
+
`~/.tweetwine`. The file serves as your configuration file.
|
61
59
|
|
62
|
-
|
60
|
+
Because the access token is sensitive information, Tweetwine obfuscates it
|
61
|
+
when storing it into the configuration file. While this prevents simple plain
|
62
|
+
text reading attempts of the access token, it is not secure. You should
|
63
|
+
restrict access to the file only to yourself. If the configuration file does
|
64
|
+
not exist before running the program, Tweetwine sets the file accessible only
|
65
|
+
to you when storing the access token.
|
63
66
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
+
The configuration file is in YAML syntax. In addition to the OAuth access
|
68
|
+
token, the program recognizes the following settings:
|
69
|
+
|
70
|
+
colors: true|false
|
71
|
+
username: <your_username>
|
72
|
+
|
73
|
+
### URL shortening for a status update
|
74
|
+
|
75
|
+
Before actually sending a new status update, it is possible for the software
|
76
|
+
to shorten the URLs in the tweet by using an external web service. This can be
|
77
|
+
enabled via `shorten_urls` field in the configuration file; for example:
|
67
78
|
|
68
79
|
username: spoonman
|
69
|
-
password: withyourhands
|
70
80
|
colors: true
|
71
81
|
shorten_urls:
|
72
|
-
enable: true
|
73
82
|
service_url: http://is.gd/create.php
|
74
83
|
method: post
|
75
84
|
url_param_name: URL
|
76
85
|
xpath_selector: //input[@id='short_url']/@value
|
86
|
+
disable: false # optional
|
77
87
|
|
78
|
-
The supported methods (in `method`) are `get` and `post`.
|
79
|
-
affects whether parameters are passed as URL query
|
80
|
-
in the HTTP request, respectively. Extra parameters
|
81
|
-
`extra_params`
|
82
|
-
|
83
|
-
The `xpath_selector` is needed to extract the shortened URL from the result.
|
88
|
+
The supported HTTP request methods (in `method` field) are `get` and `post`.
|
89
|
+
The method chosen affects whether parameters are passed as URL query
|
90
|
+
parameters or as payload in the HTTP request, respectively. Extra parameters
|
91
|
+
can be given via `extra_params` field, as a hash.
|
84
92
|
|
85
|
-
|
93
|
+
The `xpath_selector` field is needed to locate the HTML element which contains
|
94
|
+
the shortened URL from the HTTP response.
|
86
95
|
|
87
|
-
|
88
|
-
|
89
|
-
|
96
|
+
URL shortening can be disabled by not defining `shorten_urls` field in the
|
97
|
+
configuration file, or by setting optional field `disable` to true. In order
|
98
|
+
to disable shortening only temporarily, use the command line option
|
99
|
+
`--no-url-shorten`.
|
90
100
|
|
91
|
-
*NOTE:* The use of
|
92
|
-
to be installed.
|
101
|
+
*NOTE:* The use of URL shortening requires [nokogiri](http://nokogiri.org/)
|
102
|
+
gem to be installed.
|
93
103
|
|
94
104
|
### HTTP proxy setting
|
95
105
|
|
96
106
|
If `$http_proxy` environment variable is set, Tweetwine attempts to use the
|
97
|
-
URL in the environment variable as HTTP proxy for
|
98
|
-
|
99
|
-
|
107
|
+
URL in the environment variable as HTTP proxy for its HTTP connections. This
|
108
|
+
setting can be overridden with `--http-proxy` and `--no-http-proxy` command
|
109
|
+
line options.
|
100
110
|
|
101
111
|
### Bash command line completion support
|
102
112
|
|
@@ -115,8 +125,8 @@ snippet to your Bash initialization script (such as `~/.bashrc`):
|
|
115
125
|
|
116
126
|
## COPYRIGHT
|
117
127
|
|
118
|
-
Tweetwine is Copyright (c) 2009-2010 Tuomas Kareinen
|
128
|
+
Tweetwine is Copyright (c) 2009-2010 Tuomas Kareinen.
|
119
129
|
|
120
130
|
## SEE ALSO
|
121
131
|
|
122
|
-
|
132
|
+
<http://github.com/tuomas/tweetwine>
|