termtter 1.0.1 → 1.0.2

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 CHANGED
@@ -1,3 +1,4 @@
1
+ # -*- coding: utf-8 -*-
1
2
  = termtter
2
3
 
3
4
  http://github.com/jugyo/termtter
@@ -63,10 +64,10 @@ http://wiki.github.com/jugyo/termtter/home (in Japanese)
63
64
 
64
65
  == TODO:
65
66
 
66
- - filter plugin を統一する
67
- - plugin => plugins (ディレクトリ名変更)
68
- - $HOME 以下に plugin 用のディレクトリを置けるようにする
69
- - コマンドラインオプションでいろいろ指定できるようにする
67
+ - Enhance the document and spec
68
+ - Finalize the Hook specification and integration
69
+ - Improve the UI(a status view, etc...)
70
+ - Build a logging function
70
71
 
71
72
  == LICENSE:
72
73
 
@@ -211,40 +211,11 @@ module Termtter
211
211
 
212
212
  def load_config
213
213
  legacy_config_support() if File.exist? Termtter::CONF_DIR
214
- if File.exist? Termtter::CONF_FILE
215
- load Termtter::CONF_FILE
216
- else
217
- ui = create_highline
218
- username = ui.ask('your twitter username: ')
219
- password = ui.ask('your twitter password: ') { |q| q.echo = false }
220
-
221
- Dir.mkdir(Termtter::CONF_DIR)
222
- File.open(Termtter::CONF_FILE, 'w') {|io|
223
- io.puts '# -*- coding: utf-8 -*-'
224
-
225
- plugins = Dir.glob(File.dirname(__FILE__) + "/../lib/plugins/*.rb").map {|f|
226
- f.match(%r|lib/plugin/(.*?).rb$|)[1]
227
- }
228
- plugins -= %w[stdout standard_plugins]
229
- plugins.each do |p|
230
- io.puts "#plugin '#{p}'"
231
- end
232
-
233
- io.puts
234
- io.puts "config.user_name = '#{username}'"
235
- io.puts "config.password = '#{password}'"
236
- io.puts "#config.update_interval = 120"
237
- io.puts "#config.proxy.host = 'proxy host'"
238
- io.puts "#config.proxy.port = '8080'"
239
- io.puts "#config.proxy.user_name = 'proxy user'"
240
- io.puts "#config.proxy.password = 'proxy password'"
241
- io.puts
242
- io.puts "# vim: set filetype=ruby"
243
- }
244
- puts "generated: ~/.termtter/config"
245
- puts "enjoy!"
246
- load Termtter::CONF_FILE
214
+ unless File.exist?(Termtter::CONF_FILE)
215
+ require 'termtter/config_setup'
216
+ ConfigSetup.run
247
217
  end
218
+ load Termtter::CONF_FILE
248
219
  end
249
220
 
250
221
  def legacy_config_support
@@ -307,6 +278,7 @@ module Termtter
307
278
  @@since_id = statuses[0].id
308
279
  end
309
280
  call_hooks(statuses, :update_friends_timeline)
281
+ Readline.refresh_line
310
282
  statuses
311
283
  rescue OpenURI::HTTPError => e
312
284
  if e.message == '401 Unauthorized'
@@ -374,20 +346,6 @@ module Termtter
374
346
  start_input_thread()
375
347
  end
376
348
 
377
- def create_highline
378
- HighLine.track_eof = false
379
- if $stdin.respond_to?(:getbyte) # for ruby1.9
380
- require 'delegate'
381
- stdin_for_highline = SimpleDelegator.new($stdin)
382
- def stdin_for_highline.getc
383
- getbyte
384
- end
385
- else
386
- stdin_for_highline = $stdin
387
- end
388
- HighLine.new(stdin_for_highline)
389
- end
390
-
391
349
  def handle_error(e)
392
350
  call_new_hooks("on_error", e)
393
351
  rescue => e
@@ -0,0 +1,53 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ module Termtter
4
+ module ConfigSetup
5
+ def run
6
+ ui = create_highline
7
+ username = ui.ask('your twitter username: ')
8
+ password = ui.ask('your twitter password: ') { |q| q.echo = false }
9
+
10
+ Dir.mkdir(Termtter::CONF_DIR) unless File.exists?(Termtter::CONF_DIR)
11
+ File.open(Termtter::CONF_FILE, 'w') {|io|
12
+ io.puts '# -*- coding: utf-8 -*-'
13
+
14
+ io.puts
15
+ io.puts "config.user_name = '#{username}'"
16
+ io.puts "config.password = '#{password}'"
17
+ io.puts "#config.update_interval = 120"
18
+ io.puts "#config.proxy.host = 'proxy host'"
19
+ io.puts "#config.proxy.port = '8080'"
20
+ io.puts "#config.proxy.user_name = 'proxy user'"
21
+ io.puts "#config.proxy.password = 'proxy password'"
22
+ io.puts
23
+ plugins = Dir.glob(File.expand_path(File.dirname(__FILE__) + "/../plugins/*.rb")).map {|f|
24
+ f.match(%r|lib/plugins/(.*?).rb$|)[1]
25
+ }
26
+ plugins -= %w[stdout standard_plugins]
27
+ plugins.each do |p|
28
+ io.puts "#plugin '#{p}'"
29
+ end
30
+ io.puts
31
+ io.puts "# vim: set filetype=ruby"
32
+ }
33
+ puts "generated: ~/.termtter/config"
34
+ puts "enjoy!"
35
+ end
36
+
37
+ module_function :run
38
+
39
+ def self.create_highline
40
+ HighLine.track_eof = false
41
+ if $stdin.respond_to?(:getbyte) # for ruby1.9
42
+ require 'delegate'
43
+ stdin_for_highline = SimpleDelegator.new($stdin)
44
+ def stdin_for_highline.getc
45
+ getbyte
46
+ end
47
+ else
48
+ stdin_for_highline = $stdin
49
+ end
50
+ HighLine.new(stdin_for_highline)
51
+ end
52
+ end
53
+ end
@@ -1,3 +1,21 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ require 'dl/import'
4
+ module Readline
5
+ begin
6
+ module LIBREADLINE
7
+ extend DL::Importable
8
+ dlload '/opt/local/lib/libreadline.dylib' # TODO: 環境によってパスを変える必要あり。どうやったらいいかはこれから調べる。
9
+ extern 'int rl_refresh_line(int, int)'
10
+ end
11
+ def self.refresh_line
12
+ LIBREADLINE.rl_refresh_line(0, 0)
13
+ end
14
+ rescue RuntimeError, NameError
15
+ def self.refresh_line;end
16
+ end
17
+ end
18
+
1
19
  def win?
2
20
  RUBY_PLATFORM.downcase =~ /mswin(?!ce)|mingw|bccwin/
3
21
  end
@@ -86,3 +104,11 @@ if win?
86
104
  STDOUT.puts
87
105
  end
88
106
  end
107
+
108
+ unless Symbol.instance_methods.include?('to_proc')
109
+ class Symbol
110
+ def to_proc
111
+ Proc.new { |*args| args.shift.__send__(self, *args) }
112
+ end
113
+ end
114
+ end
@@ -1,4 +1,4 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  module Termtter
3
- VERSION = '1.0.1'
3
+ VERSION = '1.0.2'
4
4
  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.0.1
4
+ version: 1.0.2
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-03-16 00:00:00 +09:00
13
+ date: 2009-03-18 00:00:00 +09:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -131,6 +131,7 @@ files:
131
131
  - lib/termtter/client.rb
132
132
  - lib/termtter/command.rb
133
133
  - lib/termtter/config.rb
134
+ - lib/termtter/config_setup.rb
134
135
  - lib/termtter/connection.rb
135
136
  - lib/termtter/hook.rb
136
137
  - lib/termtter/optparse.rb