termtter 1.4.0 → 1.5.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/README.rdoc +19 -29
- data/lib/plugins/defaults/eval.rb +6 -0
- data/lib/plugins/defaults/standard_commands.rb +10 -3
- data/lib/plugins/defaults/stdout.rb +1 -1
- data/lib/plugins/irc_gw.rb +9 -4
- data/lib/termtter.rb +2 -4
- data/lib/termtter/api.rb +5 -10
- data/lib/termtter/client.rb +8 -3
- data/lib/termtter/config_setup.rb +1 -28
- data/lib/termtter/config_template.erb +2 -2
- data/lib/termtter/system_extensions.rb +11 -0
- data/lib/termtter/version.rb +1 -1
- data/spec/plugins/whois_spec.rb +6 -0
- metadata +4 -4
- data/lib/plugins/devel.rb +0 -18
data/README.rdoc
CHANGED
@@ -1,20 +1,18 @@
|
|
1
|
-
=
|
2
|
-
|
3
|
-
http://termtter.org/
|
4
|
-
|
5
|
-
== DESCRIPTION:
|
1
|
+
= Termtter
|
6
2
|
|
7
3
|
Termtter is a terminal based Twitter client.
|
8
4
|
|
9
|
-
|
5
|
+
For more information, see http://termtter.org/ and http://lingr.com/room/termtter
|
10
6
|
|
11
|
-
==
|
7
|
+
== INSTALL:
|
8
|
+
|
9
|
+
% sudo gem install termtter
|
12
10
|
|
13
|
-
|
11
|
+
== Run:
|
14
12
|
|
15
13
|
% termtter
|
16
14
|
|
17
|
-
|
15
|
+
== Commands:
|
18
16
|
|
19
17
|
Show help
|
20
18
|
|
@@ -32,17 +30,6 @@ Search
|
|
32
30
|
|
33
31
|
> search termtter
|
34
32
|
|
35
|
-
== REQUIREMENTS:
|
36
|
-
|
37
|
-
* json_pure or json
|
38
|
-
* termcolor
|
39
|
-
* rubytter
|
40
|
-
* highline
|
41
|
-
|
42
|
-
== INSTALL:
|
43
|
-
|
44
|
-
% sudo gem install termtter
|
45
|
-
|
46
33
|
== CONFIGURATION:
|
47
34
|
|
48
35
|
If you would like to use proxy server, add configurations like this:
|
@@ -61,15 +48,6 @@ You can to load plugins in this way:
|
|
61
48
|
|
62
49
|
To update the config, just restart your termtter proccess.
|
63
50
|
|
64
|
-
== FORUM:
|
65
|
-
|
66
|
-
http://groups.google.co.jp/group/termtter
|
67
|
-
|
68
|
-
== TODO:
|
69
|
-
|
70
|
-
- Enhance the document and spec
|
71
|
-
- Improve the UI(a status view, etc...)
|
72
|
-
|
73
51
|
== ADVANCED USAGE:
|
74
52
|
|
75
53
|
t.plug 'curry'
|
@@ -90,6 +68,18 @@ You can also type `<` as curry.
|
|
90
68
|
> < u
|
91
69
|
u >
|
92
70
|
|
71
|
+
== REQUIREMENTS:
|
72
|
+
|
73
|
+
* json_pure or json
|
74
|
+
* termcolor
|
75
|
+
* rubytter
|
76
|
+
* highline
|
77
|
+
|
78
|
+
== TODO:
|
79
|
+
|
80
|
+
- Enhance the document and spec
|
81
|
+
- Improve the UI(a status view, etc...)
|
82
|
+
|
93
83
|
== LICENSE:
|
94
84
|
|
95
85
|
(The MIT License)
|
@@ -139,20 +139,27 @@ module Termtter::Client
|
|
139
139
|
register_command(
|
140
140
|
:name => :list, :aliases => [:l],
|
141
141
|
:exec_proc => lambda {|arg|
|
142
|
+
if arg =~ /\-([\d]+)/
|
143
|
+
options = {:count => $1}
|
144
|
+
arg = arg.gsub(/\-([\d]+)/, '')
|
145
|
+
else
|
146
|
+
options = {}
|
147
|
+
end
|
148
|
+
|
142
149
|
if arg.empty?
|
143
150
|
event = :list_friends_timeline
|
144
|
-
statuses = Termtter::API.twitter.friends_timeline
|
151
|
+
statuses = Termtter::API.twitter.friends_timeline(options)
|
145
152
|
else
|
146
153
|
event = :list_user_timeline
|
147
154
|
statuses = []
|
148
155
|
Array(arg.split).each do |user|
|
149
156
|
user_name = normalize_as_user_name(user)
|
150
|
-
statuses += Termtter::API.twitter.user_timeline(user_name)
|
157
|
+
statuses += Termtter::API.twitter.user_timeline(user_name, options)
|
151
158
|
end
|
152
159
|
end
|
153
160
|
output(statuses, event)
|
154
161
|
},
|
155
|
-
:help => ["list,l [USERNAME]", "List the posts"]
|
162
|
+
:help => ["list,l [USERNAME] [-COUNT]", "List the posts"]
|
156
163
|
)
|
157
164
|
|
158
165
|
class SearchEvent; attr_reader :query; def initialize(query); @query = query end; end
|
@@ -12,7 +12,7 @@ config.plugins.stdout.set_default(
|
|
12
12
|
)
|
13
13
|
config.plugins.stdout.set_default(:time_format_today, '%H:%M:%S')
|
14
14
|
config.plugins.stdout.set_default(:time_format_not_today, '%y/%m/%d %H:%M')
|
15
|
-
config.plugins.stdout.set_default(:enable_pager,
|
15
|
+
config.plugins.stdout.set_default(:enable_pager, false)
|
16
16
|
config.plugins.stdout.set_default(:pager, 'less -R -f +G')
|
17
17
|
config.plugins.stdout.set_default(:window_height, 50)
|
18
18
|
config.plugins.stdout.set_default(:typable_ids, ('aa'..'zz').to_a)
|
data/lib/plugins/irc_gw.rb
CHANGED
@@ -74,10 +74,12 @@ class TermtterIrcGateway < Net::IRC::Server::Session
|
|
74
74
|
|
75
75
|
def on_message(m)
|
76
76
|
termtter_command = m.command.downcase + ' ' + m.params.join(' ')
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
77
|
+
return if Termtter::Client.find_commands(termtter_command).empty?
|
78
|
+
post '#termtter', NOTICE, main_channel, '> ' + termtter_command
|
79
|
+
Termtter::Client.call_commands(termtter_command)
|
80
|
+
rescue Exception => e
|
81
|
+
post '#termtter', NOTICE, main_channel, "#{e.class.to_s}: #{e.message}"
|
82
|
+
Termtter::Client.handle_error(e)
|
81
83
|
end
|
82
84
|
|
83
85
|
def on_user(m)
|
@@ -92,6 +94,9 @@ class TermtterIrcGateway < Net::IRC::Server::Session
|
|
92
94
|
target, message = *m.params
|
93
95
|
Termtter::Client.call_commands('update ' + message)
|
94
96
|
post @prefix, TOPIC, main_channel, message
|
97
|
+
rescue Exception => e
|
98
|
+
post '#termtter', NOTICE, main_channel, "#{e.class.to_s}: #{e.message}"
|
99
|
+
Termtter::Client.handle_error(e)
|
95
100
|
end
|
96
101
|
|
97
102
|
def log(str)
|
data/lib/termtter.rb
CHANGED
@@ -14,7 +14,8 @@ require 'net/https'
|
|
14
14
|
require 'open-uri'
|
15
15
|
require 'optparse'
|
16
16
|
require 'readline'
|
17
|
-
|
17
|
+
gem 'rubytter', '>= 0.9.2'
|
18
|
+
require 'rubytter'
|
18
19
|
|
19
20
|
require 'termtter/config'
|
20
21
|
require 'termtter/version'
|
@@ -37,7 +38,4 @@ module Termtter
|
|
37
38
|
config.system.set_default :conf_file, CONF_DIR + '/config'
|
38
39
|
CONF_FILE = config.system.conf_file
|
39
40
|
$:.unshift(Termtter::CONF_DIR)
|
40
|
-
|
41
|
-
CONSUMER_KEY = 'O80mRgLxHgpzB5yVOnxmiA'
|
42
|
-
CONSUMER_SECRET = 'jylXMjnIbfaNKpEQjgcVeZWJFTaKXFnj1RA4qTeEM'
|
43
41
|
end
|
data/lib/termtter/api.rb
CHANGED
@@ -1,6 +1,4 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
|
-
gem 'rubytter', '>= 0.6.5'
|
3
|
-
require 'rubytter'
|
4
2
|
|
5
3
|
config.set_default(:host, 'twitter.com')
|
6
4
|
config.proxy.set_default(:port, '8080')
|
@@ -16,14 +14,11 @@ module Termtter
|
|
16
14
|
attr_reader :connection, :twitter
|
17
15
|
def setup
|
18
16
|
@connection = Connection.new
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
@twitter = OAuthRubytter.new(access_token, twitter_option)
|
25
|
-
config.user_name = @twitter.verify_credentials[:name]
|
26
|
-
end
|
17
|
+
|
18
|
+
ui = create_highline
|
19
|
+
config.user_name = ui.ask('Username: ') if config.user_name.empty?
|
20
|
+
config.password = ui.ask('Password: ') { |q| q.echo = false} if config.password.empty?
|
21
|
+
@twitter = Rubytter.new(config.user_name, config.password, twitter_option)
|
27
22
|
end
|
28
23
|
|
29
24
|
def restore_user
|
data/lib/termtter/client.rb
CHANGED
@@ -16,7 +16,7 @@ module Termtter
|
|
16
16
|
@task_manager = Termtter::TaskManager.new
|
17
17
|
|
18
18
|
config.set_default(:logger, nil)
|
19
|
-
config.set_default(:update_interval,
|
19
|
+
config.set_default(:update_interval, 120)
|
20
20
|
config.set_default(:prompt, '> ')
|
21
21
|
config.set_default(:devel, false)
|
22
22
|
|
@@ -297,7 +297,6 @@ module Termtter
|
|
297
297
|
|
298
298
|
def load_plugins
|
299
299
|
plug 'defaults'
|
300
|
-
plug 'devel' if config.devel
|
301
300
|
plug config.system.load_plugins
|
302
301
|
end
|
303
302
|
|
@@ -351,7 +350,13 @@ module Termtter
|
|
351
350
|
else
|
352
351
|
"\"#{message}".strip + "\" [N/y] "
|
353
352
|
end
|
354
|
-
|
353
|
+
readline = Readline.readline(prompt, false)
|
354
|
+
result =
|
355
|
+
if !!(/^$/ =~ readline)
|
356
|
+
default_yes
|
357
|
+
else
|
358
|
+
!!(/^y/i =~ readline)
|
359
|
+
end
|
355
360
|
|
356
361
|
if result && block
|
357
362
|
block.call
|
@@ -5,32 +5,9 @@ require 'erb'
|
|
5
5
|
module Termtter
|
6
6
|
module ConfigSetup
|
7
7
|
module_function
|
8
|
-
# TODO: move this method to suitable place
|
9
|
-
def open_brawser(url)
|
10
|
-
case RUBY_PLATFORM
|
11
|
-
when /linux/
|
12
|
-
system 'firefox', url
|
13
|
-
when /mswin(?!ce)|mingw|bccwin/
|
14
|
-
system 'explorer', url
|
15
|
-
else
|
16
|
-
system 'open', url
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
8
|
def run
|
21
|
-
puts 'connecting to twitter...'
|
22
|
-
|
23
|
-
consumer = OAuth::Consumer.new(CONSUMER_KEY, CONSUMER_SECRET, :site => 'http://twitter.com')
|
24
|
-
request_token = consumer.get_request_token
|
25
|
-
|
26
|
-
open_brawser(request_token.authorize_url)
|
27
|
-
sleep 2
|
28
|
-
|
29
9
|
ui = create_highline
|
30
|
-
|
31
|
-
access_token = request_token.get_access_token(:oauth_verifier => pin)
|
32
|
-
token = access_token.token
|
33
|
-
secret = access_token.secret
|
10
|
+
user_name = ui.ask('your twitter user name: ')
|
34
11
|
|
35
12
|
plugins = Dir.glob(File.expand_path(File.dirname(__FILE__) + "/../plugins/*.rb")).map {|f|
|
36
13
|
f.match(%r|lib/plugins/(.*?).rb$|)[1]
|
@@ -46,10 +23,6 @@ module Termtter
|
|
46
23
|
}
|
47
24
|
|
48
25
|
puts "generated: ~/.termtter/config"
|
49
|
-
puts "enjoy!"
|
50
|
-
rescue OAuth::Unauthorized
|
51
|
-
puts 'failed to authentication!'
|
52
|
-
exit 1
|
53
26
|
end
|
54
27
|
end
|
55
28
|
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
|
3
|
-
config.
|
4
|
-
config.access_token_secret = '<%= secret %>'
|
3
|
+
config.user_name = '<%= user_name %>'
|
5
4
|
#config.update_interval = 120
|
5
|
+
#config.enable_ssl = true
|
6
6
|
#config.proxy.host = 'proxy host'
|
7
7
|
#config.proxy.port = '8080'
|
8
8
|
#config.proxy.user_name = 'proxy user'
|
@@ -157,3 +157,14 @@ def create_highline
|
|
157
157
|
end
|
158
158
|
HighLine.new($stdin)
|
159
159
|
end
|
160
|
+
|
161
|
+
def open_brawser(url)
|
162
|
+
case RUBY_PLATFORM
|
163
|
+
when /linux/
|
164
|
+
system 'firefox', url
|
165
|
+
when /mswin(?!ce)|mingw|bccwin/
|
166
|
+
system 'explorer', url
|
167
|
+
else
|
168
|
+
system 'open', url
|
169
|
+
end
|
170
|
+
end
|
data/lib/termtter/version.rb
CHANGED
data/spec/plugins/whois_spec.rb
CHANGED
@@ -9,6 +9,7 @@ describe Termtter::Client, 'when the plugin whois is loaded' do
|
|
9
9
|
end
|
10
10
|
|
11
11
|
it 'should be whois define' do # What does "be whois define" mean?
|
12
|
+
pending "This spec doesn't pass in Japan too"
|
12
13
|
Termtter::Client.plug 'whois'
|
13
14
|
name = 'jp-in-f104.google.com'
|
14
15
|
ip = '66.249.89.104'
|
@@ -16,5 +17,10 @@ describe Termtter::Client, 'when the plugin whois is loaded' do
|
|
16
17
|
whois?(name).should == ip
|
17
18
|
whois?(ip).should == name
|
18
19
|
# FIXME: This spec doesn't pass in Canada
|
20
|
+
# 1)
|
21
|
+
# 'Termtter::Client when the plugin whois is loaded should be whois define' FAILED
|
22
|
+
# expected: "66.249.89.104",
|
23
|
+
# got: "no address for jp-in-f104.google.com" (using ==)
|
24
|
+
# ./spec/plugins/whois_spec.rb:16:
|
19
25
|
end
|
20
26
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: termtter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- jugyo
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2009-10-
|
13
|
+
date: 2009-10-24 00:00:00 +09:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -90,6 +90,7 @@ files:
|
|
90
90
|
- lib/plugins/defaults/alias.rb
|
91
91
|
- lib/plugins/defaults/auto_reload.rb
|
92
92
|
- lib/plugins/defaults/command_line.rb
|
93
|
+
- lib/plugins/defaults/eval.rb
|
93
94
|
- lib/plugins/defaults/exec.rb
|
94
95
|
- lib/plugins/defaults/fib.rb
|
95
96
|
- lib/plugins/defaults/retweet.rb
|
@@ -97,7 +98,6 @@ files:
|
|
97
98
|
- lib/plugins/defaults/standard_completion.rb
|
98
99
|
- lib/plugins/defaults/stdout.rb
|
99
100
|
- lib/plugins/defaults.rb
|
100
|
-
- lib/plugins/devel.rb
|
101
101
|
- lib/plugins/en2ja.rb
|
102
102
|
- lib/plugins/english.rb
|
103
103
|
- lib/plugins/erb.rb
|
@@ -258,7 +258,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
258
258
|
requirements: []
|
259
259
|
|
260
260
|
rubyforge_project: termtter
|
261
|
-
rubygems_version: 1.3.
|
261
|
+
rubygems_version: 1.3.5
|
262
262
|
signing_key:
|
263
263
|
specification_version: 3
|
264
264
|
summary: Terminal based Twitter client.
|
data/lib/plugins/devel.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
|
3
|
-
begin
|
4
|
-
require 'ruby-debug'
|
5
|
-
rescue LoadError
|
6
|
-
end
|
7
|
-
|
8
|
-
module Termtter::Client
|
9
|
-
register_command(
|
10
|
-
:name => :eval,
|
11
|
-
:aliases => [],
|
12
|
-
:exec_proc => lambda {|arg|
|
13
|
-
result = eval(arg) unless arg.empty?
|
14
|
-
puts "=> #{result.inspect}"
|
15
|
-
},
|
16
|
-
:help => ['eval EXPR', 'evaluate expression']
|
17
|
-
)
|
18
|
-
end
|