jugyo-termtter 0.5.1 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
data/Manifest.txt CHANGED
@@ -14,6 +14,7 @@ lib/termtter/uri-open.rb
14
14
  lib/termtter/growl.rb
15
15
  lib/termtter/say.rb
16
16
  lib/termtter/english.rb
17
+ lib/termtter/completion.rb
17
18
  test/test_termtter.rb
18
19
  test/friends_timeline.json
19
20
  test/search.json
data/example_dot_termtter CHANGED
@@ -3,6 +3,7 @@
3
3
  #require 'termtter/notify-send'
4
4
  #require 'termtter/uri-open'
5
5
  #require 'termtter/growl'
6
+ #require 'termtter/completion'
6
7
 
7
8
  configatron.user_name = 'USERNAME'
8
9
  configatron.password = 'PASSWORD'
@@ -0,0 +1,59 @@
1
+ require 'set'
2
+
3
+ class Termtter::Client
4
+
5
+ public_storage[:users] ||= Set.new
6
+
7
+ add_hook do |statuses, event, t|
8
+ if !statuses.empty?
9
+ case event
10
+ when :update_friends_timeline, :replies, :list_user_timeline
11
+ statuses.each do |s|
12
+ public_storage[:users].add(s.user_screen_name)
13
+ s.text.scan(/@[a-zA-Z_0-9]*/).each do |u| # reply
14
+ public_storage[:users].add(u.gsub("@","")) unless u == "@"
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
20
+
21
+ end
22
+
23
+ module Termtter
24
+ module InputCompletor
25
+
26
+ Commands = %w[exit help list pause update resume replies search show uri-open]
27
+
28
+ CompletionProc = proc {|input|
29
+ case input
30
+ when /^l(ist)? +(.*)/
31
+ username = $2
32
+ if username.empty?
33
+ Termtter::Client.public_storage[:users].to_a
34
+ else
35
+ Termtter::Client.public_storage[:users].to_a.
36
+ grep(/^#{Regexp.quote username}/).map{|u| "list #{u}"}
37
+ end
38
+ when /^uri-open +(.*)/
39
+ uri_open_com = $1
40
+ if uri_open_com.empty?
41
+ %w[clear list]
42
+ else
43
+ %w[clear list].
44
+ grep(/^#{Regexp.quote uri_open_com}/).map{|c| "uri-open #{c}"}
45
+ end
46
+ else
47
+ Commands.grep(/^#{Regexp.quote input}/)
48
+ end
49
+ }
50
+
51
+ end
52
+ end
53
+
54
+ Readline.basic_word_break_characters= "\t\n\"\\'`><=;|&{("
55
+ Readline.completion_proc = Termtter::InputCompletor::CompletionProc
56
+
57
+ # author: bubbles
58
+ #
59
+ # see also: http://d.hatena.ne.jp/bubbles/20090105/1231145823
data/lib/termtter.rb CHANGED
@@ -10,7 +10,7 @@ $:.unshift(File.dirname(__FILE__)) unless
10
10
  $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
11
11
 
12
12
  module Termtter
13
- VERSION = '0.5.1'
13
+ VERSION = '0.5.2'
14
14
 
15
15
  class Twitter
16
16
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jugyo-termtter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - jugyo
@@ -68,6 +68,7 @@ files:
68
68
  - lib/termtter/growl.rb
69
69
  - lib/termtter/say.rb
70
70
  - lib/termtter/english.rb
71
+ - lib/termtter/completion.rb
71
72
  - test/test_termtter.rb
72
73
  - test/friends_timeline.json
73
74
  - test/search.json