termtter 1.2.0 → 1.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.
Files changed (76) hide show
  1. data/ChangeLog +115 -0
  2. data/README.rdoc +25 -10
  3. data/Rakefile +53 -34
  4. data/lib/plugins/cool.rb +2 -5
  5. data/lib/plugins/curry.rb +43 -0
  6. data/lib/plugins/db.rb +91 -0
  7. data/lib/plugins/{auto_reload.rb → defaults/auto_reload.rb} +0 -0
  8. data/lib/plugins/defaults/command_line.rb +111 -0
  9. data/lib/plugins/{exec.rb → defaults/exec.rb} +2 -7
  10. data/lib/plugins/{fib.rb → defaults/fib.rb} +1 -4
  11. data/lib/plugins/defaults/retweet.rb +34 -0
  12. data/lib/plugins/{standard_commands.rb → defaults/standard_commands.rb} +60 -136
  13. data/lib/plugins/defaults/standard_completion.rb +67 -0
  14. data/lib/plugins/{stdout.rb → defaults/stdout.rb} +30 -19
  15. data/lib/plugins/defaults.rb +14 -0
  16. data/lib/plugins/en2ja.rb +11 -5
  17. data/lib/plugins/english.rb +2 -2
  18. data/lib/plugins/expand-tinyurl.rb +27 -6
  19. data/lib/plugins/github-issues.rb +192 -0
  20. data/lib/plugins/group.rb +30 -4
  21. data/lib/plugins/growl.rb +10 -1
  22. data/lib/plugins/http_server/favicon.ico +0 -0
  23. data/lib/plugins/http_server/index.html +117 -0
  24. data/lib/plugins/http_server.rb +82 -0
  25. data/lib/plugins/irb.rb +6 -0
  26. data/lib/plugins/l2.rb +1 -1
  27. data/lib/plugins/list_with_opts.rb +0 -3
  28. data/lib/plugins/log.rb +6 -9
  29. data/lib/plugins/modify_arg_hook_sample.rb +3 -5
  30. data/lib/plugins/multi_reply.rb +0 -5
  31. data/lib/plugins/notify-send.rb +1 -1
  32. data/lib/plugins/notify-send2.rb +1 -1
  33. data/lib/plugins/notify-send3.rb +11 -3
  34. data/lib/plugins/open_url.rb +0 -8
  35. data/lib/plugins/otsune.rb +3 -9
  36. data/lib/plugins/outputz.rb +1 -1
  37. data/lib/plugins/pool.rb +30 -0
  38. data/lib/plugins/quicklook.rb +1 -1
  39. data/lib/plugins/saykanji.rb +81 -0
  40. data/lib/plugins/shell.rb +1 -6
  41. data/lib/plugins/sl.rb +8 -8
  42. data/lib/plugins/tinyurl.rb +26 -7
  43. data/lib/plugins/trends.rb +84 -0
  44. data/lib/plugins/twitpic.rb +46 -0
  45. data/lib/plugins/uri-open.rb +1 -1
  46. data/lib/plugins/wassr.rb +0 -3
  47. data/lib/plugins/whois.rb +45 -0
  48. data/lib/plugins/yhara.rb +2 -6
  49. data/lib/termtter/client.rb +73 -100
  50. data/lib/termtter/config.rb +4 -6
  51. data/lib/termtter/config_setup.rb +1 -1
  52. data/lib/termtter/hook.rb +2 -2
  53. data/lib/termtter/optparse.rb +14 -1
  54. data/lib/termtter/system_extensions.rb +3 -2
  55. data/lib/termtter/task_manager.rb +1 -5
  56. data/lib/termtter/version.rb +1 -1
  57. data/spec/plugins/cool_spec.rb +1 -1
  58. data/spec/plugins/curry_spec.rb +13 -0
  59. data/spec/plugins/db_spec.rb +62 -0
  60. data/spec/plugins/english_spec.rb +2 -2
  61. data/spec/plugins/fib_spec.rb +2 -2
  62. data/spec/plugins/filter_spec.rb +2 -2
  63. data/spec/plugins/pause_spec.rb +1 -1
  64. data/spec/plugins/primes_spec.rb +2 -2
  65. data/spec/plugins/shell_spec.rb +1 -1
  66. data/spec/plugins/sl_spec.rb +1 -1
  67. data/spec/plugins/{standard_plugins_spec.rb → standard_commands_spec.rb} +2 -2
  68. data/spec/plugins/whois_spec.rb +20 -0
  69. data/spec/termtter/client_spec.rb +114 -37
  70. data/spec/termtter/config_spec.rb +10 -0
  71. data/spec/termtter/optparse_spec.rb +16 -0
  72. data/spec/termtter_spec.rb +7 -8
  73. metadata +39 -19
  74. data/History.txt +0 -4
  75. data/lib/plugins/direct_messages.rb +0 -36
  76. data/lib/plugins/retweet.rb +0 -46
@@ -14,16 +14,12 @@ module Termtter
14
14
  @commands = {}
15
15
  @filters = []
16
16
  @since_id = nil
17
- @input_thread = nil
18
17
  @task_manager = Termtter::TaskManager.new
19
18
 
20
19
  config.set_default(:logger, nil)
21
20
  config.set_default(:update_interval, 300)
22
21
  config.set_default(:prompt, '> ')
23
22
  config.set_default(:devel, false)
24
- config.set_default(:stdout, true)
25
- config.set_default(:standard_commands, true)
26
- config.set_default(:auto_reload, true)
27
23
 
28
24
  Thread.abort_on_exception = true
29
25
 
@@ -31,11 +27,14 @@ module Termtter
31
27
 
32
28
  attr_reader :commands, :hooks
33
29
 
30
+ # plug :: Name -> (Hash) -> IO () where NAME = String | Symbol | [NAME]
34
31
  def plug(name, options = {})
35
- unless options.empty?
36
- options.each do |key, value|
37
- config.plugins.__refer__(name.to_sym).__assign__(key.to_sym, value)
38
- end
32
+ if Array === name # Obviously `name.respond_to?(:each)` is better, but for 1.8.6 compatibility we cannot.
33
+ name.each {|i| plug(i, options) }
34
+ return
35
+ end
36
+ options.each do |key, value|
37
+ config.plugins.__refer__(name.gsub(/-/, '_').to_sym).__assign__(key.to_sym, value)
39
38
  end
40
39
  load "plugins/#{name}.rb"
41
40
  rescue Exception => e
@@ -55,14 +54,19 @@ module Termtter
55
54
  @filters.clear
56
55
  end
57
56
 
58
- def register_hook(arg)
57
+ def register_hook(arg, opts = {}, &block)
59
58
  hook = case arg
60
59
  when Hook
61
60
  arg
62
61
  when Hash
63
62
  Hook.new(arg)
63
+ when String, Symbol
64
+ options = { :name => arg }
65
+ options.merge!(opts)
66
+ options[:exec_proc] = block
67
+ Hook.new(options)
64
68
  else
65
- raise ArgumentError, 'must be given Termtter::Hook or Hash'
69
+ raise ArgumentError, 'must be given Termtter::Hook, Hash, String or Symbol'
66
70
  end
67
71
  @hooks[hook.name] = hook
68
72
  end
@@ -72,6 +76,7 @@ module Termtter
72
76
  end
73
77
 
74
78
  def get_hooks(point)
79
+ # TODO: sort by alphabet
75
80
  @hooks.values.select do |hook|
76
81
  hook.match?(point)
77
82
  end
@@ -83,13 +88,13 @@ module Termtter
83
88
  arg
84
89
  when Hash
85
90
  Command.new(arg)
86
- when String
91
+ when String, Symbol
87
92
  options = { :name => arg }
88
93
  options.merge!(opts)
89
94
  options[:exec_proc] = block
90
95
  Command.new(options)
91
96
  else
92
- raise ArgumentError, 'must be given Termtter::Command, Hash or String with block'
97
+ raise ArgumentError, 'must be given Termtter::Command, Hash or String(Symbol) with block'
93
98
  end
94
99
  @commands[command.name] = command
95
100
  end
@@ -135,7 +140,7 @@ module Termtter
135
140
  def output(statuses, event)
136
141
  return if statuses.nil? || statuses.empty?
137
142
 
138
- statuses = statuses.sort_by{|s|s.id}
143
+ statuses = statuses.sort_by(&:id)
139
144
  call_hooks(:pre_filter, statuses, event)
140
145
 
141
146
  filtered = apply_filters_for_hook(:filter_for_output, statuses.map(&:dup), event)
@@ -154,10 +159,9 @@ module Termtter
154
159
  end
155
160
 
156
161
  def apply_filters_for_hook(hook_name, statuses, event)
157
- get_hooks(hook_name).each do |hook|
158
- statuses = hook.call(statuses, event)
159
- end
160
- statuses
162
+ get_hooks(hook_name).inject(statuses) {|s, hook|
163
+ hook.call(s, event)
164
+ }
161
165
  end
162
166
 
163
167
  # return last hook return value
@@ -171,36 +175,41 @@ module Termtter
171
175
  end
172
176
 
173
177
  def call_commands(text)
174
- return if text.empty?
175
-
176
- commands = find_commands(text)
177
- raise CommandNotFound, text if commands.empty?
178
-
179
- commands.each do |command|
180
- command_found = true
181
- command_str, command_arg = Command.split_command_line(text)
178
+ @task_manager.invoke_and_wait do
179
+ call_hooks("pre_command", text)
180
+ # FIXME: This block can become Maybe Monad
181
+ get_hooks("pre_command").each {|hook|
182
+ break if text == nil # interrupt if hook returns nil
183
+ text = hook.call(text)
184
+ }
185
+ return if text.empty?
186
+
187
+ commands = find_commands(text)
188
+ raise CommandNotFound, text if commands.empty?
189
+
190
+ commands.each do |command|
191
+ command_str, command_arg = Command.split_command_line(text)
192
+
193
+ modified_arg = command_arg
194
+ # FIXME: This block can become Maybe Monad
195
+ get_hooks("modify_arg_for_#{command.name.to_s}").each {|hook|
196
+ break if modified_arg == false # interrupt if hook return false
197
+ modified_arg = hook.call(command_str, modified_arg)
198
+ }
182
199
 
183
- modified_arg = call_hooks(
184
- "modify_arg_for_#{command.name.to_s}",
185
- command_str,
186
- command_arg) || command_arg || ''
187
-
188
- @task_manager.invoke_and_wait do
189
200
  begin
190
201
  call_hooks("pre_exec_#{command.name.to_s}", command, modified_arg)
191
- # exec command
192
- result = command.call(command_str, modified_arg, text)
193
- if result
194
- call_hooks("post_exec_#{command.name.to_s}", command_str, modified_arg, result)
195
- end
202
+ result = command.call(command_str, modified_arg, text) # exec command
203
+ call_hooks("post_exec_#{command.name.to_s}", command_str, modified_arg, result)
196
204
  rescue CommandCanceled
197
205
  end
198
206
  end
207
+ call_hooks("post_command", text)
199
208
  end
200
209
  end
201
210
 
202
211
  def find_commands(text)
203
- @commands.values.select { |command| command.match?(text) }
212
+ @commands.values.select {|command| command.match?(text) }
204
213
  end
205
214
 
206
215
  def pause
@@ -217,10 +226,8 @@ module Termtter
217
226
 
218
227
  def exit
219
228
  puts 'finalizing...'
220
-
221
229
  call_hooks(:exit)
222
230
  @task_manager.kill
223
- @input_thread.kill if @input_thread
224
231
  end
225
232
 
226
233
  def load_config
@@ -251,56 +258,6 @@ module Termtter
251
258
  Termtter::CONF_FILE)
252
259
  end
253
260
 
254
- def setup_readline
255
- if Readline.respond_to?(:basic_word_break_characters=)
256
- Readline.basic_word_break_characters= "\t\n\"\\'`><=;|&{("
257
- end
258
- Readline.completion_proc = lambda {|input|
259
- begin
260
- @commands.map {|name, command| command.complement(input) }.flatten.compact
261
- rescue => e
262
- handle_error(e)
263
- end
264
- }
265
- vi_or_emacs = config.editing_mode
266
- unless vi_or_emacs.empty?
267
- Readline.__send__("#{vi_or_emacs}_editing_mode")
268
- end
269
- end
270
-
271
- def trap_setting()
272
- begin
273
- stty_save = `stty -g`.chomp
274
- trap("INT") do
275
- begin
276
- system "stty", stty_save
277
- ensure
278
- exit
279
- end
280
- end
281
- rescue Errno::ENOENT
282
- end
283
- end
284
-
285
- def start_input_thread
286
- setup_readline()
287
- trap_setting()
288
- @input_thread = Thread.new do
289
- while buf = Readline.readline(ERB.new(config.prompt).result(API.twitter.__send__(:binding)), true)
290
- Readline::HISTORY.pop if buf.empty?
291
- begin
292
- call_commands(buf)
293
- rescue CommandNotFound => e
294
- warn "Unknown command \"#{e}\""
295
- warn 'Enter "help" for instructions'
296
- rescue => e
297
- handle_error e
298
- end
299
- end
300
- end
301
- @input_thread.join
302
- end
303
-
304
261
  def logger
305
262
  @logger
306
263
  end
@@ -311,7 +268,7 @@ module Termtter
311
268
 
312
269
  def default_logger
313
270
  logger = Logger.new(STDOUT)
314
- logger.formatter = lambda { |severity, time, progname, message|
271
+ logger.formatter = lambda {|severity, time, progname, message|
315
272
  color =
316
273
  case severity
317
274
  when /^DEBUG/
@@ -343,14 +300,9 @@ module Termtter
343
300
 
344
301
  @init_block.call(self) if @init_block
345
302
 
346
- plug 'stdout' if config.stdout
347
- plug 'standard_commands' if config.standard_commands
348
- plug 'auto_reload' if config.auto_reload
303
+ plug 'defaults'
349
304
  plug 'devel' if config.devel
350
-
351
- config.system.load_plugins.each do |plugin|
352
- plug plugin
353
- end
305
+ plug config.system.load_plugins
354
306
 
355
307
  config.system.eval_scripts.each do |script|
356
308
  begin
@@ -360,12 +312,12 @@ module Termtter
360
312
  end
361
313
  end
362
314
 
363
- config.system.run_commands.each { |cmd| call_commands(cmd) }
315
+ config.system.run_commands.each {|cmd| call_commands(cmd) }
364
316
 
365
317
  unless config.system.cmd_mode
366
- call_hooks(:initialize)
367
318
  @task_manager.run()
368
- start_input_thread()
319
+ call_hooks(:initialize)
320
+ call_hooks(:launched)
369
321
  end
370
322
  end
371
323
 
@@ -381,6 +333,27 @@ module Termtter
381
333
  puts "Error: #{e}"
382
334
  puts e.backtrace.join("\n")
383
335
  end
336
+
337
+ def confirm(message, default_yes = true, &block)
338
+ pause # TODO: TaskManager から呼ばれるならこれいらないなぁ
339
+
340
+ result = # Boolean in duck typing
341
+ if default_yes
342
+ prompt = "\"#{message}".strip + "\" [Y/n] "
343
+ /^y?$/i =~ Readline.readline(prompt, false)
344
+ else
345
+ prompt = "\"#{message}".strip + "\" [N/y] "
346
+ /^n?$/i =~ Readline.readline(prompt, false)
347
+ end
348
+
349
+ if result && block
350
+ block.call
351
+ end
352
+
353
+ result
354
+ ensure
355
+ resume # TODO: TaskManager から呼ばれるならこれいらないなぁ
356
+ end
384
357
  end
385
358
  end
386
359
  end
@@ -19,7 +19,10 @@ module Termtter
19
19
  tmp.__assign__(last.to_sym, value)
20
20
  end
21
21
  else
22
- __assign__(name.to_sym, value) if __refer__(name.to_sym).empty?
22
+ current_value = __refer__(name.to_sym)
23
+ if current_value.kind_of?(self.class) && current_value.empty?
24
+ __assign__(name.to_sym, value)
25
+ end
23
26
  end
24
27
  end
25
28
 
@@ -65,8 +68,3 @@ def config
65
68
  Termtter::Config.instance
66
69
  end
67
70
 
68
- def configatron
69
- # remove this method until Termtter-1.2.0
70
- warn "configatron method will be removed. Use config instead. (#{caller.first})"
71
- Termtter::Config.instance
72
- end
@@ -19,7 +19,7 @@ module Termtter
19
19
  config = ERB.new(template, nil, '-').result(binding) # trim_mode => '-'
20
20
 
21
21
  Dir.mkdir(Termtter::CONF_DIR) unless File.exists?(Termtter::CONF_DIR)
22
- File.open(Termtter::CONF_FILE, 'w') {|io|
22
+ File.open(Termtter::CONF_FILE, 'w', 0600) {|io|
23
23
  io << config
24
24
  }
25
25
 
data/lib/termtter/hook.rb CHANGED
@@ -12,7 +12,7 @@ module Termtter
12
12
  end
13
13
 
14
14
  def match?(point)
15
- !points.select{|pt|
15
+ points.any? {|pt|
16
16
  case pt
17
17
  when String, Symbol
18
18
  pt.to_s == point.to_s
@@ -21,7 +21,7 @@ module Termtter
21
21
  else
22
22
  false
23
23
  end
24
- }.empty?
24
+ }
25
25
  end
26
26
 
27
27
  def call(*args)
@@ -10,7 +10,7 @@ OptionParser.new { |opt|
10
10
  end
11
11
 
12
12
  opt.on('-d', '--devel', 'Start in developer mode') do |flg|
13
- config.system.__assign__(:devel, true) if flg
13
+ config.__assign__(:devel, true) if flg
14
14
  end
15
15
 
16
16
  config.system.cmd_mode = false
@@ -33,6 +33,19 @@ OptionParser.new { |opt|
33
33
  config.system.eval_scripts << script
34
34
  end
35
35
 
36
+ config.system.eval_scripts = []
37
+ opt.on('-m', '--monochrome', 'No shell escapes for color highlightings') do |script|
38
+ require 'termcolor'
39
+ module TermColor
40
+ class << self
41
+ alias parse_orig parse
42
+ def parse(o)
43
+ o.gsub(/<.+?>(.*?)<\/.+?>/, '\1')
44
+ end
45
+ end
46
+ end
47
+ end
48
+
36
49
  opt.version = Termtter::VERSION
37
50
  opt.parse!(ARGV)
38
51
  }
@@ -108,8 +108,9 @@ if win?
108
108
  str.to_s.gsub("\xef\xbd\x9e", "\xe3\x80\x9c").split(/(\e\[\d*[a-zA-Z])/).each do |token|
109
109
  case token
110
110
  when /\e\[(\d+)m/
111
- $wSetConsoleTextAttribute.call $hStdOut, $colorMap[$1.to_i].to_i
112
- when /\e\[\d*[a-zA-Z]/
111
+ color = $1.to_i > 90 ? ($1.to_i % 60) : $1.to_i
112
+ $wSetConsoleTextAttribute.call $hStdOut, $colorMap[color].to_i
113
+ when /\e\[\d*[a-zA-Z]/
113
114
  # do nothing
114
115
  else
115
116
  loop do
@@ -51,11 +51,7 @@ module Termtter
51
51
 
52
52
  def invoke_and_wait(&block)
53
53
  synchronize do
54
- begin
55
- yield
56
- rescue Exception => e
57
- Termtter::Client.handle_error(e)
58
- end
54
+ yield
59
55
  end
60
56
  end
61
57
 
@@ -1,4 +1,4 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  module Termtter
3
- VERSION = '1.2.0'
3
+ VERSION = '1.3.0'
4
4
  end
@@ -5,6 +5,6 @@ require File.dirname(__FILE__) + '/../spec_helper'
5
5
  describe Termtter::Client, 'when the plugin cool is loaded' do
6
6
  it 'should add something about cool' do
7
7
  Termtter::Client.should_receive(:register_macro)
8
- plugin 'cool'
8
+ Termtter::Client.plug 'cool'
9
9
  end
10
10
  end
@@ -0,0 +1,13 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ require File.dirname(__FILE__) + '/../spec_helper'
4
+
5
+ describe Termtter::Client, 'when the plugin curry is loaded' do
6
+ it 'should add command curry' do
7
+ Termtter::Client.should_receive(:register_command).twice
8
+ Termtter::Client.should_receive(:register_hook).twice
9
+ Termtter::Client.plug 'curry'
10
+ end
11
+ end
12
+
13
+ # FIXME: Lack of specs
@@ -0,0 +1,62 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ require File.dirname(__FILE__) + '/../spec_helper'
4
+
5
+ describe 'db' do
6
+ DB_PATH = '/tmp/termtter.db'
7
+
8
+ before(:each) do
9
+ File.delete(DB_PATH) if File.exists?(DB_PATH)
10
+ config.plugins.db.path = DB_PATH
11
+ load 'plugins/db.rb'
12
+ end
13
+
14
+ after do
15
+ File.delete(DB_PATH) if File.exists?(DB_PATH)
16
+ end
17
+
18
+ it 'should created db file' do
19
+ File.exists?(DB_PATH)
20
+ end
21
+
22
+ it 'saves statuses' do
23
+ now = Time.now.to_s
24
+ Status << {:user_id => 1, :text => 'foo', :created_at => now}
25
+ dataset = Status.all
26
+ dataset.size.should == 1
27
+ dataset[0].user_id.should == 1
28
+ dataset[0].text.should == 'foo'
29
+ dataset[0].created_at.should == now
30
+ end
31
+
32
+ it 'saves users' do
33
+ User << {:screen_name => 'jugyo'}
34
+ dataset = User.all
35
+ dataset.size.should == 1
36
+ dataset[0].screen_name.should == 'jugyo'
37
+ end
38
+
39
+ it 'calls hook' do
40
+ user_struct = Struct.new(:id, :screen_name)
41
+ user_1 = user_struct.new(1, 'jugyo')
42
+ user_2 = user_struct.new(2, 'oyguj')
43
+
44
+ status_struct = Struct.new(:id, :text, :source, :user, :in_reply_to_status_id,
45
+ :in_reply_to_user_id, :created_at)
46
+ statuses = []
47
+ statuses << status_struct.new(1, 'foo', 'termtter', user_1, 100, Time.now.to_s)
48
+ statuses << status_struct.new(2, 'bar', 'termtter', user_1, nil, nil, Time.now.to_s)
49
+ statuses << status_struct.new(3, 'xxx', 'web', user_2, nil, nil, Time.now.to_s)
50
+
51
+ Termtter::Client.hooks[:collect_statuses_for_db].call(statuses, :update_friends_timeline)
52
+
53
+ dataset = User.all
54
+ dataset.size.should == 2
55
+
56
+ dataset = Status.all
57
+ dataset.size.should == 3
58
+
59
+ User[:id => 1].statuses.size.should == 2
60
+ Status[:id => 1].user.id.should == 1
61
+ end
62
+ end
@@ -5,7 +5,7 @@ require File.dirname(__FILE__) + '/../spec_helper'
5
5
  describe Termtter do
6
6
  it 'english? method' do
7
7
  Termtter::Client.should_receive(:add_filter)
8
- plugin 'english'
8
+ Termtter::Client.plug 'english'
9
9
  Termtter::English.english?('This is a pen.').should be_true
10
10
  Termtter::English.english?('これはペンです.').should be_false
11
11
  Termtter::English.english?('これはpenです.').should be_false
@@ -13,7 +13,7 @@ describe Termtter do
13
13
 
14
14
  it 'apply filter english only update_friends_timeline'
15
15
  # NOTE: when below code is evaluated,
16
- # plugin 'english', :only => [:update_friends_timeline]
16
+ # t.plug 'english', :only => [:update_friends_timeline]
17
17
  # in update_friends_timeline there are English posts only but in replies there are both Japanese posts and English posts.
18
18
  # It's too difficult for me to write that spec, so this spec is pending now. Please write this spec, hey, you, a cool hacker!
19
19
  end
@@ -5,11 +5,11 @@ require File.dirname(__FILE__) + '/../spec_helper'
5
5
  describe Termtter::Client, 'when the plugin fib is loaded' do
6
6
  it 'should add command fib' do
7
7
  Termtter::Client.should_receive(:register_command).twice
8
- plugin 'fib'
8
+ Termtter::Client.plug 'defaults/fib'
9
9
  end
10
10
 
11
11
  it 'should define fib method' do
12
- plugin 'fib'
12
+ Termtter::Client.plug 'defaults/fib'
13
13
  (0..10).map {|i| fib i }.should == [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55]
14
14
  end
15
15
  end
@@ -6,11 +6,11 @@ module Termtter
6
6
  describe Client, 'when the filter plugin is loaded' do
7
7
  it 'should add command filter, filters and unfilter' do
8
8
  Termtter::Client.should_receive(:register_command).exactly(3)
9
- plugin 'filter'
9
+ Termtter::Client.plug 'filter'
10
10
  end
11
11
 
12
12
  it 'should set public_storage[:filters]' do
13
- plugin 'filter'
13
+ Termtter::Client.plug 'filter'
14
14
  Client::public_storage.keys.should be_include(:filters)
15
15
  end
16
16
  end
@@ -3,6 +3,6 @@ require File.dirname(__FILE__) + '/../spec_helper'
3
3
  describe Termtter do
4
4
  it 'pause plugin' do
5
5
  Termtter::Client.should_receive(:pause)
6
- plugin 'pause'
6
+ Termtter::Client.plug 'pause'
7
7
  end
8
8
  end
@@ -5,11 +5,11 @@ require File.dirname(__FILE__) + '/../spec_helper'
5
5
  describe Termtter::Client, 'when the plugin primes is loaded' do
6
6
  it 'should add command primes' do
7
7
  Termtter::Client.should_receive(:register_command).once
8
- plugin 'primes'
8
+ Termtter::Client.plug 'primes'
9
9
  end
10
10
 
11
11
  it 'should define primes method' do
12
- plugin 'primes'
12
+ Termtter::Client.plug 'primes'
13
13
  (0..10).map {|i| primes i }.should == ["", "", "", "2, 3", "2, 3", "2, 3, 5", "2, 3, 5", "2, 3, 5, 7", "2, 3, 5, 7", "2, 3, 5, 7", "2, 3, 5, 7"]
14
14
  end
15
15
  end
@@ -5,6 +5,6 @@ require File.dirname(__FILE__) + '/../spec_helper'
5
5
  describe Termtter::Client, 'when the plugin shell is loaded' do
6
6
  it 'should add command shell' do
7
7
  Termtter::Client.should_receive(:register_command)
8
- plugin 'shell'
8
+ Termtter::Client.plug 'shell'
9
9
  end
10
10
  end
@@ -3,6 +3,6 @@ require File.dirname(__FILE__) + '/../spec_helper'
3
3
  describe Termtter do
4
4
  it 'plugin sl' do
5
5
  Termtter::Client.should_receive(:register_command).exactly(4).times
6
- plugin 'sl'
6
+ Termtter::Client.plug 'sl'
7
7
  end
8
8
  end
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
3
  require File.dirname(__FILE__) + '/../spec_helper'
4
- plugin 'standard_commands'
4
+ Termtter::Client.plug 'defaults/standard_commands'
5
5
 
6
6
  module Termtter
7
7
  describe Client do
@@ -12,7 +12,7 @@ module Termtter
12
12
  [:search, [:s]], [:replies, [:r]],
13
13
  [:show, [ ]], [:shows, [ ]],
14
14
  [:limit, [:lm]], [:pause, [ ]],
15
- [:resume, [ ]], [:exit, [:e]],
15
+ [:resume, [ ]], [:exit, [:quit]],
16
16
  ].each do |name, aliases|
17
17
  command = Client.get_command(name)
18
18
  command.name.should == name
@@ -0,0 +1,20 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ require File.dirname(__FILE__) + '/../spec_helper'
4
+
5
+ describe Termtter::Client, 'when the plugin whois is loaded' do
6
+ it 'should add command whois' do
7
+ Termtter::Client.should_receive(:register_command).once
8
+ Termtter::Client.plug 'whois'
9
+ end
10
+
11
+ it 'should be whois define' do
12
+ Termtter::Client.plug 'whois'
13
+ name = "jp-in-f104.google.com"
14
+ ip = "66.249.89.104"
15
+
16
+ whois?(name).should == ip
17
+ whois?(ip).should == name
18
+ end
19
+
20
+ end