jugyo-termtter 0.8.2 → 0.8.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +9 -0
- data/Rakefile +46 -64
- data/lib/filter/url_addspace.rb +16 -0
- data/lib/plugin/april_fool.rb +1 -1
- data/lib/plugin/bomb.rb +1 -1
- data/lib/plugin/clear.rb +14 -0
- data/lib/plugin/confirm.rb +1 -1
- data/lib/plugin/cool.rb +1 -1
- data/lib/plugin/devel.rb +13 -0
- data/lib/plugin/erb.rb +1 -1
- data/lib/plugin/filter.rb +4 -4
- data/lib/plugin/follow.rb +5 -5
- data/lib/plugin/grass.rb +27 -0
- data/lib/plugin/group.rb +8 -4
- data/lib/plugin/growl.rb +1 -1
- data/lib/plugin/hatebu.rb +2 -2
- data/lib/plugin/history.rb +9 -0
- data/lib/plugin/log.rb +14 -6
- data/lib/plugin/modify_arg_hook_sample.rb +1 -1
- data/lib/plugin/otsune.rb +2 -2
- data/lib/plugin/plugin.rb +3 -3
- data/lib/plugin/post_exec_hook_sample.rb +1 -1
- data/lib/plugin/pre_exec_hook_sample.rb +1 -1
- data/lib/plugin/reblog.rb +2 -2
- data/lib/plugin/scrape.rb +2 -2
- data/lib/plugin/shell.rb +1 -1
- data/lib/plugin/sl.rb +6 -6
- data/lib/plugin/standard_plugins.rb +62 -44
- data/lib/plugin/system_status.rb +2 -2
- data/lib/plugin/update_editor.rb +1 -1
- data/lib/plugin/wassr_post.rb +1 -1
- data/lib/plugin/yhara.rb +2 -2
- data/lib/plugin/yonda.rb +9 -9
- data/lib/termtter/client.rb +24 -7
- data/lib/termtter/command.rb +2 -2
- data/lib/termtter/hook.rb +1 -1
- data/lib/termtter/task.rb +1 -1
- data/lib/termtter/twitter.rb +51 -27
- data/lib/termtter/version.rb +1 -1
- data/spec/plugin/cool_spec.rb +10 -0
- data/spec/plugin/fib_spec.rb +16 -0
- data/spec/plugin/filter_spec.rb +18 -0
- data/spec/plugin/plugin_spec.rb +25 -0
- data/spec/plugin/shell_spec.rb +10 -0
- data/spec/plugin/spam_spec.rb +17 -0
- data/spec/plugin/standard_plugins_spec.rb +31 -0
- data/spec/spec_helper.rb +4 -0
- data/spec/termtter/client_spec.rb +175 -0
- data/spec/termtter/command_spec.rb +161 -0
- data/spec/termtter/task_manager_spec.rb +78 -0
- data/spec/termtter/task_spec.rb +22 -0
- data/spec/termtter/user_spec.rb +27 -0
- data/spec/termtter_spec.rb +43 -0
- metadata +40 -42
- data/Manifest.txt +0 -77
- data/PostInstall.txt +0 -1
- data/run_termtter.rb +0 -17
data/README.rdoc
CHANGED
@@ -62,6 +62,15 @@ http://www.lingr.com/room/termtter
|
|
62
62
|
|
63
63
|
http://wiki.github.com/jugyo/termtter/home (in Japanese)
|
64
64
|
|
65
|
+
== TODO:
|
66
|
+
|
67
|
+
- newgem を使わないようにする
|
68
|
+
- rubytter を使うようにする
|
69
|
+
- filter と plugin を統一する
|
70
|
+
- plugin => plugins (ディレクトリ名変更)
|
71
|
+
- $HOME 以下に plugin 用のディレクトリを置けるようにする
|
72
|
+
- コマンドラインオプションでいろいろ指定できるようにする
|
73
|
+
|
65
74
|
== LICENSE:
|
66
75
|
|
67
76
|
(The MIT License)
|
data/Rakefile
CHANGED
@@ -1,64 +1,46 @@
|
|
1
|
-
|
2
|
-
require
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
if line =~ pattern
|
48
|
-
res << [fn, count.to_s, line.gsub(/\A\s+/, '')]
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
fmax = res.map {|i| i[0] }.map(&:size).max
|
54
|
-
cmax = res.map {|i| i[1] }.map(&:size).max
|
55
|
-
res.each do |fn, count, line|
|
56
|
-
puts "%s :%s:%s" % [fn.ljust(fmax), count.rjust(cmax), line]
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
desc "Look for TODO and FIXME tags in the code"
|
61
|
-
task :todo do
|
62
|
-
egrep /(FIXME|TODO)/
|
63
|
-
end
|
64
|
-
|
1
|
+
$:.unshift File.dirname(__FILE__) + '/lib'
|
2
|
+
require 'termtter'
|
3
|
+
|
4
|
+
require 'spec/rake/spectask'
|
5
|
+
desc 'run all specs'
|
6
|
+
Spec::Rake::SpecTask.new do |t|
|
7
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
8
|
+
t.spec_opts = ['-c']
|
9
|
+
end
|
10
|
+
|
11
|
+
desc 'Generate gemspec'
|
12
|
+
task :gemspec do |t|
|
13
|
+
open('termtter.gemspec', "wb" ) do |file|
|
14
|
+
file << <<-EOS
|
15
|
+
Gem::Specification.new do |s|
|
16
|
+
s.name = 'termtter'
|
17
|
+
s.version = '#{Termtter::VERSION}'
|
18
|
+
s.summary = "Terminal based Twitter client"
|
19
|
+
s.description = "Termtter is a terminal based Twitter client"
|
20
|
+
s.files = %w( #{Dir['lib/**/*.rb'].join(' ')}
|
21
|
+
#{Dir['spec/**/*.rb'].join(' ')}
|
22
|
+
#{Dir['test/**/*.rb', 'test/**/*.json'].join(' ')}
|
23
|
+
README.rdoc
|
24
|
+
History.txt
|
25
|
+
Rakefile )
|
26
|
+
s.executables = ["kill_termtter", "termtter"]
|
27
|
+
s.add_dependency("json_pure", ">= 1.1.3")
|
28
|
+
s.add_dependency("configatron", ">= 2.2.2")
|
29
|
+
s.add_dependency("highline", ">= 1.5.0")
|
30
|
+
s.authors = %w(jugyo ujihisa)
|
31
|
+
s.email = 'jugyo.org@gmail.com'
|
32
|
+
s.homepage = 'http://wiki.github.com/jugyo/termtter'
|
33
|
+
s.rubyforge_project = 'termtter'
|
34
|
+
s.has_rdoc = true
|
35
|
+
s.rdoc_options = ["--main", "README.rdoc", "--exclude", "spec"]
|
36
|
+
s.extra_rdoc_files = ["README.rdoc", "History.txt"]
|
37
|
+
end
|
38
|
+
EOS
|
39
|
+
end
|
40
|
+
puts "Generate gemspec"
|
41
|
+
end
|
42
|
+
|
43
|
+
desc 'Generate gem'
|
44
|
+
task :gem => :gemspec do |t|
|
45
|
+
system 'gem', 'build', 'termtter.gemspec'
|
46
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
module Termtter::Client
|
4
|
+
add_filter do |statuses|
|
5
|
+
statuses.each do |s|
|
6
|
+
s.text.gsub!(/(\S)(https?:\/\/)/, '\1 \2')
|
7
|
+
end
|
8
|
+
statuses
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
# url_addspace
|
13
|
+
# add space before URL without space
|
14
|
+
# example:
|
15
|
+
# before: ABCDEhttp://~~~
|
16
|
+
# after: ABCDE http://~~~
|
data/lib/plugin/april_fool.rb
CHANGED
@@ -5,7 +5,7 @@ def april_fool;april_fool? ? "今日はエイプリルフールではありま
|
|
5
5
|
|
6
6
|
Termtter::Client.register_command(
|
7
7
|
:name => :april_fool, :aliases => [:af],
|
8
|
-
:exec_proc =>
|
8
|
+
:exec_proc => lambda {|arg|
|
9
9
|
if arg =~ /^\?you\s(\w+)/
|
10
10
|
puts "=> #{Termtter::Client.update_status("@#{$1} #{april_fool}")}"
|
11
11
|
else
|
data/lib/plugin/bomb.rb
CHANGED
data/lib/plugin/clear.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
module Termtter::Client
|
4
|
+
register_command :name => :clear, :aliases => [:cls],
|
5
|
+
:help => ['clear,cls', "Clear termtter's buffer"],
|
6
|
+
:exec_proc => lambda {|args|
|
7
|
+
system 'clear'
|
8
|
+
}
|
9
|
+
end
|
10
|
+
|
11
|
+
# todo:
|
12
|
+
# support windows.
|
13
|
+
# i don't have windows machine and cannot test:P
|
14
|
+
# cls command?
|
data/lib/plugin/confirm.rb
CHANGED
data/lib/plugin/cool.rb
CHANGED
data/lib/plugin/devel.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
module Termtter::Client
|
4
|
+
register_command(
|
5
|
+
:name => :eval,
|
6
|
+
:aliases => [],
|
7
|
+
:exec_proc => lambda {|arg|
|
8
|
+
result = eval(arg) unless arg.empty?
|
9
|
+
puts "=> #{result.inspect}"
|
10
|
+
},
|
11
|
+
:help => ['eval EXPR', 'evaluate expression']
|
12
|
+
)
|
13
|
+
end
|
data/lib/plugin/erb.rb
CHANGED
data/lib/plugin/filter.rb
CHANGED
@@ -9,7 +9,7 @@ module Termtter::Client
|
|
9
9
|
|
10
10
|
register_command(
|
11
11
|
:name => :filter, :aliases => [],
|
12
|
-
:exec_proc =>
|
12
|
+
:exec_proc => lambda {|arg|
|
13
13
|
begin
|
14
14
|
result = filter arg.strip
|
15
15
|
rescue LoadError
|
@@ -18,7 +18,7 @@ module Termtter::Client
|
|
18
18
|
puts "=> #{result.inspect}"
|
19
19
|
end
|
20
20
|
},
|
21
|
-
:completion_proc =>
|
21
|
+
:completion_proc => lambda {|cmd, args|
|
22
22
|
find_filter_candidates args, "#{cmd} %s", filters
|
23
23
|
},
|
24
24
|
:help => ['filter FILE', 'Apply a filter']
|
@@ -26,7 +26,7 @@ module Termtter::Client
|
|
26
26
|
|
27
27
|
register_command(
|
28
28
|
:name => :unfilter, :aliases => [],
|
29
|
-
:exec_proc =>
|
29
|
+
:exec_proc => lambda {|arg|
|
30
30
|
clear_filters
|
31
31
|
public_storage[:filters].clear
|
32
32
|
puts '=> filter cleared'
|
@@ -36,7 +36,7 @@ module Termtter::Client
|
|
36
36
|
|
37
37
|
register_command(
|
38
38
|
:name => :filters, :aliases => [],
|
39
|
-
:exec_proc =>
|
39
|
+
:exec_proc => lambda {|arg|
|
40
40
|
unless public_storage[:filters].empty?
|
41
41
|
puts public_storage[:filters].join(', ')
|
42
42
|
else
|
data/lib/plugin/follow.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
module Termtter::Client
|
4
4
|
register_command(
|
5
5
|
:name => :follow, :aliases => [],
|
6
|
-
:exec_proc =>
|
6
|
+
:exec_proc => lambda {|arg|
|
7
7
|
if arg =~ /^(\w+)/
|
8
8
|
res = Termtter::API::twitter.social($1.strip, :follow)
|
9
9
|
if res.code == '200'
|
@@ -13,7 +13,7 @@ module Termtter::Client
|
|
13
13
|
end
|
14
14
|
end
|
15
15
|
},
|
16
|
-
:completion_proc =>
|
16
|
+
:completion_proc => lambda {|cmd, args|
|
17
17
|
find_user_candidates args, "#{cmd} %s"
|
18
18
|
},
|
19
19
|
:help => ['follow USER', 'Follow user']
|
@@ -21,9 +21,9 @@ module Termtter::Client
|
|
21
21
|
|
22
22
|
register_command(
|
23
23
|
:name => :leave, :aliases => [],
|
24
|
-
:exec_proc =>
|
24
|
+
:exec_proc => lambda {|arg|
|
25
25
|
if arg =~ /^(\w+)/
|
26
|
-
res =
|
26
|
+
res = Termtter::API::twitter.social($1.strip, :leave)
|
27
27
|
if res.code == '200'
|
28
28
|
puts "Leaved user @#{$1}"
|
29
29
|
else
|
@@ -31,7 +31,7 @@ module Termtter::Client
|
|
31
31
|
end
|
32
32
|
end
|
33
33
|
},
|
34
|
-
:completion_proc =>
|
34
|
+
:completion_proc => lambda {|cmd, args|
|
35
35
|
find_user_candidates args, "#{cmd} %s"
|
36
36
|
},
|
37
37
|
:help => ['leave USER', 'Leave user']
|
data/lib/plugin/grass.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
module Termtter
|
3
|
+
module Client
|
4
|
+
|
5
|
+
configatron.plugins.grass.set_default(:rate, 0)
|
6
|
+
|
7
|
+
register_command(
|
8
|
+
:name => :w, :aliases => [:grass],
|
9
|
+
:exec_proc => lambda {|arg|
|
10
|
+
arg, rate = arg.split(/ /)
|
11
|
+
count = arg =~ /^[0-9]+$/ ? arg.to_i : 3
|
12
|
+
rate ||= configatron.plugins.grass.rate
|
13
|
+
grow = (count * rate.to_i).quo(100).round
|
14
|
+
grasses = ('w' * (count-grow) + 'W' * grow).split(//).shuffle.join
|
15
|
+
call_commands("update #{grasses}")
|
16
|
+
},
|
17
|
+
:help => ['grass, w', 'Grass it!']
|
18
|
+
)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
# usage
|
23
|
+
# > w 10
|
24
|
+
# => wwwwwwwwww
|
25
|
+
#
|
26
|
+
# see also
|
27
|
+
# http://d.hatena.ne.jp/tomisima/20090204/1233762301
|
data/lib/plugin/group.rb
CHANGED
@@ -4,7 +4,7 @@ module Termtter
|
|
4
4
|
class Status
|
5
5
|
def is_member?(group = nil)
|
6
6
|
if group
|
7
|
-
configatron.plugins.group.groups[
|
7
|
+
configatron.plugins.group.groups[group].include? self.user_screen_name
|
8
8
|
else
|
9
9
|
configatron.plugins.group.groups.values.flatten.include? self.user_screen_name
|
10
10
|
end
|
@@ -25,10 +25,14 @@ module Termtter::Client
|
|
25
25
|
register_command(
|
26
26
|
:name => :group,
|
27
27
|
:aliases => [:g],
|
28
|
-
:exec_proc =>
|
28
|
+
:exec_proc => lambda {|arg|
|
29
29
|
unless arg.empty?
|
30
30
|
group_name = arg.to_sym
|
31
|
-
|
31
|
+
if group_name == :all
|
32
|
+
group = configatron.plugins.group.groups.values.flatten.uniq
|
33
|
+
else
|
34
|
+
group = configatron.plugins.group.groups[group_name]
|
35
|
+
end
|
32
36
|
statuses = group ? public_storage[:log].select { |s|
|
33
37
|
group.include?(s.user_screen_name)
|
34
38
|
} : []
|
@@ -39,7 +43,7 @@ module Termtter::Client
|
|
39
43
|
end
|
40
44
|
end
|
41
45
|
},
|
42
|
-
:completion_proc =>
|
46
|
+
:completion_proc => lambda {|cmd, arg|
|
43
47
|
find_group_candidates arg, "#{cmd} %s"
|
44
48
|
},
|
45
49
|
:help => ['group,g GROUPNAME', 'Filter by group members']
|
data/lib/plugin/growl.rb
CHANGED
@@ -37,7 +37,7 @@ Thread.new do
|
|
37
37
|
begin
|
38
38
|
if s = queue.pop
|
39
39
|
unless growl
|
40
|
-
arg = ['growlnotify', s.user_screen_name, '-m', s.text.gsub("\n",''), '-n', 'termtter'
|
40
|
+
arg = ['growlnotify', s.user_screen_name, '-m', s.text.gsub("\n",''), '-n', 'termtter']
|
41
41
|
#icon_path = get_icon_path(s)
|
42
42
|
#arg += ['--image', icon_path] if icon_path
|
43
43
|
system *arg
|
data/lib/plugin/hatebu.rb
CHANGED
@@ -6,7 +6,7 @@ require 'atomutil'
|
|
6
6
|
module Termtter::Client
|
7
7
|
register_command(
|
8
8
|
:name => :hatebu, :aliases => [],
|
9
|
-
:exec_proc =>
|
9
|
+
:exec_proc => lambda {|arg|
|
10
10
|
if arg =~ /^(\d+)(.*)$/
|
11
11
|
id = $1.strip
|
12
12
|
comment = $2.strip
|
@@ -41,7 +41,7 @@ module Termtter::Client
|
|
41
41
|
end
|
42
42
|
end
|
43
43
|
},
|
44
|
-
:completion_proc =>
|
44
|
+
:completion_proc => lambda {|cmd, args|
|
45
45
|
if args =~ /^(\d*)$/
|
46
46
|
find_status_id_candidates $1, "#{cmd} %s"
|
47
47
|
end
|
data/lib/plugin/history.rb
CHANGED
data/lib/plugin/log.rb
CHANGED
@@ -19,7 +19,7 @@ module Termtter::Client
|
|
19
19
|
|
20
20
|
register_command(
|
21
21
|
:name => :log,
|
22
|
-
:exec_proc =>
|
22
|
+
:exec_proc => lambda{|arg|
|
23
23
|
if arg.empty?
|
24
24
|
# log
|
25
25
|
statuses = public_storage[:log]
|
@@ -36,18 +36,26 @@ module Termtter::Client
|
|
36
36
|
call_hooks(statuses[-print_max..-1], :search)
|
37
37
|
end
|
38
38
|
},
|
39
|
-
:completion_proc =>
|
39
|
+
:completion_proc => lambda {|cmd, arg|
|
40
40
|
find_user_candidates arg, "#{cmd} %s"
|
41
41
|
},
|
42
42
|
:help => [ 'log (USER(S)) (MAX)', 'Show local log of the user(s)']
|
43
43
|
)
|
44
44
|
|
45
|
-
|
46
|
-
|
47
|
-
|
45
|
+
register_command(
|
46
|
+
:name => :search_log, :aliases => [:sl],
|
47
|
+
:exec_proc => lambda{|arg|
|
48
|
+
unless arg.strip.empty?
|
49
|
+
pat = Regexp.new arg
|
50
|
+
statuses = public_storage[:log].select { |s| s.text =~ pat }
|
51
|
+
call_hooks(statuses, :search)
|
52
|
+
end
|
53
|
+
},
|
54
|
+
:help => [ 'search_log WORD', 'Search log for WORD' ]
|
55
|
+
)
|
48
56
|
|
49
|
-
add_help '/WORD', 'Search log for WORD'
|
50
57
|
add_command %r'^/(.+)' do |m, t|
|
58
|
+
warn '/WORD command will be removed. Use search_log command instead.'
|
51
59
|
pat = Regexp.new(m[1])
|
52
60
|
statuses = public_storage[:log].select { |s| s.text =~ pat }
|
53
61
|
call_hooks(statuses, :search, t)
|