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.
Files changed (57) hide show
  1. data/README.rdoc +9 -0
  2. data/Rakefile +46 -64
  3. data/lib/filter/url_addspace.rb +16 -0
  4. data/lib/plugin/april_fool.rb +1 -1
  5. data/lib/plugin/bomb.rb +1 -1
  6. data/lib/plugin/clear.rb +14 -0
  7. data/lib/plugin/confirm.rb +1 -1
  8. data/lib/plugin/cool.rb +1 -1
  9. data/lib/plugin/devel.rb +13 -0
  10. data/lib/plugin/erb.rb +1 -1
  11. data/lib/plugin/filter.rb +4 -4
  12. data/lib/plugin/follow.rb +5 -5
  13. data/lib/plugin/grass.rb +27 -0
  14. data/lib/plugin/group.rb +8 -4
  15. data/lib/plugin/growl.rb +1 -1
  16. data/lib/plugin/hatebu.rb +2 -2
  17. data/lib/plugin/history.rb +9 -0
  18. data/lib/plugin/log.rb +14 -6
  19. data/lib/plugin/modify_arg_hook_sample.rb +1 -1
  20. data/lib/plugin/otsune.rb +2 -2
  21. data/lib/plugin/plugin.rb +3 -3
  22. data/lib/plugin/post_exec_hook_sample.rb +1 -1
  23. data/lib/plugin/pre_exec_hook_sample.rb +1 -1
  24. data/lib/plugin/reblog.rb +2 -2
  25. data/lib/plugin/scrape.rb +2 -2
  26. data/lib/plugin/shell.rb +1 -1
  27. data/lib/plugin/sl.rb +6 -6
  28. data/lib/plugin/standard_plugins.rb +62 -44
  29. data/lib/plugin/system_status.rb +2 -2
  30. data/lib/plugin/update_editor.rb +1 -1
  31. data/lib/plugin/wassr_post.rb +1 -1
  32. data/lib/plugin/yhara.rb +2 -2
  33. data/lib/plugin/yonda.rb +9 -9
  34. data/lib/termtter/client.rb +24 -7
  35. data/lib/termtter/command.rb +2 -2
  36. data/lib/termtter/hook.rb +1 -1
  37. data/lib/termtter/task.rb +1 -1
  38. data/lib/termtter/twitter.rb +51 -27
  39. data/lib/termtter/version.rb +1 -1
  40. data/spec/plugin/cool_spec.rb +10 -0
  41. data/spec/plugin/fib_spec.rb +16 -0
  42. data/spec/plugin/filter_spec.rb +18 -0
  43. data/spec/plugin/plugin_spec.rb +25 -0
  44. data/spec/plugin/shell_spec.rb +10 -0
  45. data/spec/plugin/spam_spec.rb +17 -0
  46. data/spec/plugin/standard_plugins_spec.rb +31 -0
  47. data/spec/spec_helper.rb +4 -0
  48. data/spec/termtter/client_spec.rb +175 -0
  49. data/spec/termtter/command_spec.rb +161 -0
  50. data/spec/termtter/task_manager_spec.rb +78 -0
  51. data/spec/termtter/task_spec.rb +22 -0
  52. data/spec/termtter/user_spec.rb +27 -0
  53. data/spec/termtter_spec.rb +43 -0
  54. metadata +40 -42
  55. data/Manifest.txt +0 -77
  56. data/PostInstall.txt +0 -1
  57. data/run_termtter.rb +0 -17
@@ -0,0 +1,161 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ require File.dirname(__FILE__) + '/../spec_helper'
4
+
5
+ module Termtter
6
+
7
+ describe Command do
8
+
9
+ before do
10
+ params = {
11
+ :name => 'update',
12
+ :aliases => ['u', 'up'],
13
+ :exec_proc => lambda {|arg| arg },
14
+ :completion_proc => lambda {|command, arg| ['complete1', 'complete2'] },
15
+ :help => ['update,u TEXT', 'test command']
16
+ }
17
+ @command = Command.new(params)
18
+ end
19
+
20
+ it 'should execute' do
21
+ [
22
+ ['update test test', 'test test'],
23
+ ['update test test', 'test test'],
24
+ ['update test test', 'test test'],
25
+ ].each do |input, args|
26
+ result = @command.exec_if_match(input)
27
+ result.should == args
28
+ end
29
+ end
30
+
31
+ it 'should failed on execute' do
32
+ result = @command.exec_if_match('upda test test')
33
+ result.should == nil
34
+ end
35
+
36
+ it 'should return command regex' do
37
+ @command.pattern.should == /^((update|u|up)|(update|u|up)\s+(.*?))\s*$/
38
+ end
39
+
40
+ it 'should be given name as String or Symbol' do
41
+ Command.new(:name => 'foo').name.should == :foo
42
+ Command.new(:name => :foo).name.should == :foo
43
+ end
44
+
45
+ it 'should return name' do
46
+ @command.name.should == :update
47
+ end
48
+
49
+ it 'should return aliases' do
50
+ @command.aliases.should == [:u, :up]
51
+ end
52
+
53
+ it 'should return commands' do
54
+ @command.commands.should == [:update, :u, :up]
55
+ end
56
+
57
+ it 'should return help' do
58
+ @command.help.should == ['update,u TEXT', 'test command']
59
+ end
60
+
61
+ it 'should return candidates for completion' do
62
+ # complement
63
+ [
64
+ ['upd', ['update']],
65
+ [' upd', []],
66
+ [' upd ', []],
67
+ ['update', ['complete1', 'complete2']],
68
+ ['update ', ['complete1', 'complete2']],
69
+ [' update ', []],
70
+ ['u foo', ['complete1', 'complete2']],
71
+ ['u', ['complete1', 'complete2']],
72
+ ['up', ['complete1', 'complete2']],
73
+ ].each do |input, comp|
74
+ @command.complement(input).should == comp
75
+ end
76
+ end
77
+
78
+ it 'should can redefine exec_proc' do
79
+ # redefine exec_proc
80
+ command_arg = nil
81
+ @command.exec_proc = lambda {|arg|
82
+ command_arg = arg
83
+ 'result'
84
+ }
85
+ command_arg.should == nil
86
+
87
+ # exec command
88
+ result = @command.exec_if_match('update test test')
89
+ command_arg.should == 'test test'
90
+ result.should == 'result'
91
+ end
92
+
93
+ it 'should return command_info when call method "match?"' do
94
+ [
95
+ ['update', ['update', nil]],
96
+ ['up', ['up', nil]],
97
+ ['u', ['u', nil]],
98
+ ['update ', ['update', nil]],
99
+ [' update ', nil],
100
+ ['update foo', ['update', 'foo']],
101
+ [' update foo', nil],
102
+ [' update foo ', nil],
103
+ ['u foo', ['u', 'foo']],
104
+ ['up foo', ['up', 'foo']],
105
+ ['upd foo', nil],
106
+ ['upd foo', nil],
107
+ ].each do |input, result|
108
+ @command.match?(input).should == result
109
+ end
110
+ end
111
+
112
+ it 'should raise ArgumentError when constructor arguments are deficient' do
113
+ lambda { Command.new }.should raise_error(ArgumentError)
114
+ lambda { Command.new(:exec_proc => lambda {|args|}) }.should raise_error(ArgumentError)
115
+ lambda { Command.new(:aliases => ['u']) }.should raise_error(ArgumentError)
116
+ end
117
+
118
+ it 'should return true with the exec_proc return nil' do
119
+ command = Command.new(:name => :test, :exec_proc => lambda {|args|})
120
+ command.exec_if_match('test').should == true
121
+ end
122
+
123
+ it 'should call exec_proc when call method "execute"' do
124
+ @command.execute('test').should == 'test'
125
+ @command.execute(' test').should == ' test'
126
+ @command.execute(' test ').should == ' test '
127
+ @command.execute('test test').should == 'test test'
128
+ end
129
+
130
+ it 'should redefine method "exec_if_match"' do
131
+ # add method
132
+ class << @command
133
+ def exec_if_match(input)
134
+ case input
135
+ when /^update\s+foo\s*(.*)/
136
+ foo($1)
137
+ when /^update\s+bar\s*(.*)/
138
+ bar($1)
139
+ end
140
+ end
141
+ def foo(arg)
142
+ "foo(#{arg})"
143
+ end
144
+ def bar(arg)
145
+ "bar(#{arg})"
146
+ end
147
+ end
148
+
149
+ @command.exec_if_match('update foo xxx').should == 'foo(xxx)'
150
+ @command.exec_if_match('update bar xxx').should == 'bar(xxx)'
151
+ end
152
+
153
+ it 'should raise ArgumentError at execute' do
154
+ lambda { @command.execute(nil) }.should_not raise_error(ArgumentError)
155
+ lambda { @command.execute('foo') }.should_not raise_error(ArgumentError)
156
+ lambda { @command.execute(false) }.should raise_error(ArgumentError)
157
+ lambda { @command.execute(Array.new) }.should raise_error(ArgumentError)
158
+ end
159
+ end
160
+ end
161
+
@@ -0,0 +1,78 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ require File.dirname(__FILE__) + '/../spec_helper'
4
+ require 'termtter/task'
5
+ require 'termtter/task_manager'
6
+
7
+ module Termtter
8
+ describe TaskManager do
9
+ before do
10
+ @task_manager = TaskManager.new
11
+ end
12
+
13
+ it 'should able to add tasks' do
14
+ @task_manager.add_task() {}
15
+ @task_manager.add_task(:after => 10) {}
16
+ @task_manager.instance_eval('@tasks').size.should == 2
17
+ end
18
+
19
+ it 'should return due_tasks' do
20
+ time_now = Time.now
21
+ Time.stub!(:now).and_return(time_now)
22
+
23
+ @task_manager.add_task() {}
24
+ @task_manager.add_task(:after => 10) {}
25
+
26
+ due_tasks = @task_manager.instance_eval('pull_due_tasks')
27
+ due_tasks.size.should == 1
28
+ end
29
+
30
+ it 'should run tasks' do
31
+ time_now = Time.now
32
+ Time.stub!(:now).and_return(time_now)
33
+
34
+ task1_called = false
35
+ task2_called = false
36
+ @task_manager.add_task() {task1_called = true}
37
+ @task_manager.add_task(:after => 10) {task2_called = true}
38
+
39
+ task1_called.should == false
40
+ task2_called.should == false
41
+ @task_manager.instance_eval('@tasks').size.should == 2
42
+
43
+ @task_manager.step
44
+ task1_called.should == true
45
+ task2_called.should == false
46
+ @task_manager.instance_eval('@tasks').size.should == 1
47
+
48
+ Time.stub!(:now).and_return(time_now + 10)
49
+ @task_manager.step
50
+ task2_called.should == true
51
+ @task_manager.instance_eval('@tasks').size.should == 0
52
+ end
53
+
54
+ it 'should run repeat tasks' do
55
+ time_now = Time.now
56
+ Time.stub!(:now).and_return(time_now)
57
+
58
+ called_count = 0
59
+ @task_manager.add_task(:interval => 10) {called_count += 1}
60
+ @task_manager.step
61
+
62
+ called_count.should == 1
63
+ @task_manager.instance_eval('@tasks').size.should == 1
64
+
65
+ Time.stub!(:now).and_return(time_now + 10)
66
+ @task_manager.step
67
+ called_count.should == 2
68
+ @task_manager.instance_eval('@tasks').size.should == 1
69
+ end
70
+
71
+ it 'should add task with :name' do
72
+ @task_manager.add_task(:name => 'foo')
73
+ @task_manager.get_task('foo').name.should == 'foo'
74
+ @task_manager.delete_task('foo')
75
+ @task_manager.get_task('foo').should == nil
76
+ end
77
+ end
78
+ end
@@ -0,0 +1,22 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ require File.dirname(__FILE__) + '/../spec_helper'
4
+ require 'termtter/task'
5
+
6
+ module Termtter
7
+ describe Task do
8
+
9
+ it 'should be instantiate' do
10
+ time_now = Time.now
11
+ Time.stub!(:now).and_return(time_now)
12
+
13
+ task = Task.new() do
14
+ end
15
+ task.exec_at.should == time_now
16
+
17
+ task = Task.new(:after => 10) do
18
+ end
19
+ task.exec_at.should == (time_now + 10)
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,27 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ require File.dirname(__FILE__) + '/../spec_helper'
4
+
5
+ module Termtter
6
+ describe User do
7
+ before do
8
+ @user = User.new
9
+ @params = %w[ name favourites_count url id description protected utc_offset time_zone
10
+ screen_name notifications statuses_count followers_count friends_count
11
+ profile_image_url location following created_at
12
+ ]
13
+ end
14
+
15
+ it 'should access to properties' do
16
+ @params.each do |attr|
17
+ @user.__send__(attr.to_sym).should == nil
18
+ end
19
+
20
+ @params.each do |attr|
21
+ @user.__send__("#{attr}=".to_sym, 'foo')
22
+ @user.__send__(attr.to_sym).should == 'foo'
23
+ end
24
+ end
25
+ end
26
+ end
27
+
@@ -0,0 +1,43 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ require File.dirname(__FILE__) + '/spec_helper'
4
+
5
+ module Termtter
6
+ describe Twitter, 'when get_timeline called' do
7
+ before do
8
+ connection = mock('connection', :null_object => true)
9
+ @twitter = Termtter::Twitter.new('test', 'test', connection)
10
+
11
+ Termtter::Client.add_hook do |statuses, event|
12
+ @statuses = statuses
13
+ @event = event
14
+ end
15
+ end
16
+
17
+ it 'should get timeline' do
18
+ @twitter.should_receive(:open).
19
+ and_return(
20
+ File.open(
21
+ File.dirname(__FILE__) + "/../test/friends_timeline.json"))
22
+ statuses = @twitter.get_timeline('')
23
+ statuses.size.should == 3
24
+ statuses[0].user_id.should == 102
25
+ statuses[0].user_screen_name.should == 'test2'
26
+ statuses[0].user_name.should == 'Test User 2'
27
+ statuses[0].text.should == 'texttext 2'
28
+ statuses[0].user_url.should == 'http://twitter.com/test2'
29
+ statuses[0].user_profile_image_url.should ==
30
+ 'http://s3.amazonaws.com/twitter_production/profile_images/000/102.png'
31
+ statuses[0].created_at.to_s.should == 'Sat Jan 03 21:13:45 +0900 2009'
32
+
33
+ statuses[2].user_id.should == 100
34
+ statuses[2].user_screen_name.should == 'test0'
35
+ statuses[2].user_name.should == 'Test User 0'
36
+ statuses[2].text.should == 'texttext 0'
37
+ statuses[2].user_url.should == 'http://twitter.com/test0'
38
+ statuses[2].user_profile_image_url.should ==
39
+ 'http://s3.amazonaws.com/twitter_production/profile_images/000/100.png'
40
+ statuses[2].created_at.to_s.should == 'Sat Jan 03 21:13:45 +0900 2009'
41
+ end
42
+ end
43
+ end
metadata CHANGED
@@ -1,83 +1,59 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jugyo-termtter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.2
4
+ version: 0.8.3
5
5
  platform: ruby
6
6
  authors:
7
- - bubblegum
8
- - hakobe
9
- - hitode909
10
7
  - jugyo
11
- - koichiro
12
- - mattn
13
- - motemen
14
- - Sixeight
15
8
  - ujihisa
16
- - yanbe
17
9
  autorequire:
18
10
  bindir: bin
19
11
  cert_chain: []
20
12
 
21
- date: 2009-02-01 00:00:00 -08:00
13
+ date: 2009-02-13 00:00:00 -08:00
22
14
  default_executable:
23
15
  dependencies:
24
16
  - !ruby/object:Gem::Dependency
25
17
  name: json_pure
18
+ type: :runtime
26
19
  version_requirement:
27
20
  version_requirements: !ruby/object:Gem::Requirement
28
21
  requirements:
29
22
  - - ">="
30
23
  - !ruby/object:Gem::Version
31
- version: "0"
24
+ version: 1.1.3
32
25
  version:
33
26
  - !ruby/object:Gem::Dependency
34
27
  name: configatron
28
+ type: :runtime
35
29
  version_requirement:
36
30
  version_requirements: !ruby/object:Gem::Requirement
37
31
  requirements:
38
32
  - - ">="
39
33
  - !ruby/object:Gem::Version
40
- version: "0"
34
+ version: 2.2.2
41
35
  version:
42
36
  - !ruby/object:Gem::Dependency
43
37
  name: highline
38
+ type: :runtime
44
39
  version_requirement:
45
40
  version_requirements: !ruby/object:Gem::Requirement
46
41
  requirements:
47
42
  - - ">="
48
43
  - !ruby/object:Gem::Version
49
- version: "0"
50
- version:
51
- - !ruby/object:Gem::Dependency
52
- name: hoe
53
- version_requirement:
54
- version_requirements: !ruby/object:Gem::Requirement
55
- requirements:
56
- - - ">="
57
- - !ruby/object:Gem::Version
58
- version: 1.8.0
44
+ version: 1.5.0
59
45
  version:
60
46
  description: Termtter is a terminal based Twitter client
61
- email:
62
- - jugyo.org@gmail.com
47
+ email: jugyo.org@gmail.com
63
48
  executables:
64
49
  - kill_termtter
65
50
  - termtter
66
51
  extensions: []
67
52
 
68
53
  extra_rdoc_files:
69
- - History.txt
70
- - Manifest.txt
71
- - PostInstall.txt
72
54
  - README.rdoc
73
- files:
74
55
  - History.txt
75
- - Manifest.txt
76
- - PostInstall.txt
77
- - README.rdoc
78
- - Rakefile
79
- - bin/kill_termtter
80
- - bin/termtter
56
+ files:
81
57
  - lib/filter/en2ja.rb
82
58
  - lib/filter/english.rb
83
59
  - lib/filter/expand-tinyurl.rb
@@ -85,11 +61,14 @@ files:
85
61
  - lib/filter/ignore.rb
86
62
  - lib/filter/reply.rb
87
63
  - lib/filter/reverse.rb
64
+ - lib/filter/url_addspace.rb
88
65
  - lib/filter/yhara.rb
89
66
  - lib/plugin/april_fool.rb
90
67
  - lib/plugin/bomb.rb
68
+ - lib/plugin/clear.rb
91
69
  - lib/plugin/confirm.rb
92
70
  - lib/plugin/cool.rb
71
+ - lib/plugin/devel.rb
93
72
  - lib/plugin/english.rb
94
73
  - lib/plugin/erb.rb
95
74
  - lib/plugin/favorite.rb
@@ -97,6 +76,7 @@ files:
97
76
  - lib/plugin/filter.rb
98
77
  - lib/plugin/follow.rb
99
78
  - lib/plugin/graduatter.rb
79
+ - lib/plugin/grass.rb
100
80
  - lib/plugin/group.rb
101
81
  - lib/plugin/growl.rb
102
82
  - lib/plugin/hatebu.rb
@@ -132,7 +112,6 @@ files:
132
112
  - lib/plugin/wassr_post.rb
133
113
  - lib/plugin/yhara.rb
134
114
  - lib/plugin/yonda.rb
135
- - lib/termtter.rb
136
115
  - lib/termtter/api.rb
137
116
  - lib/termtter/client.rb
138
117
  - lib/termtter/command.rb
@@ -144,16 +123,35 @@ files:
144
123
  - lib/termtter/twitter.rb
145
124
  - lib/termtter/user.rb
146
125
  - lib/termtter/version.rb
147
- - run_termtter.rb
126
+ - lib/termtter.rb
127
+ - spec/plugin/cool_spec.rb
128
+ - spec/plugin/fib_spec.rb
129
+ - spec/plugin/filter_spec.rb
130
+ - spec/plugin/plugin_spec.rb
131
+ - spec/plugin/shell_spec.rb
132
+ - spec/plugin/spam_spec.rb
133
+ - spec/plugin/standard_plugins_spec.rb
134
+ - spec/spec_helper.rb
135
+ - spec/termtter/client_spec.rb
136
+ - spec/termtter/command_spec.rb
137
+ - spec/termtter/task_manager_spec.rb
138
+ - spec/termtter/task_spec.rb
139
+ - spec/termtter/user_spec.rb
140
+ - spec/termtter_spec.rb
141
+ - test/test_termtter.rb
148
142
  - test/friends_timeline.json
149
143
  - test/search.json
150
- - test/test_termtter.rb
144
+ - README.rdoc
145
+ - History.txt
146
+ - Rakefile
151
147
  has_rdoc: true
152
- homepage: http://github.com/jugyo/termtter
153
- post_install_message: PostInstall.txt
148
+ homepage: http://wiki.github.com/jugyo/termtter
149
+ post_install_message:
154
150
  rdoc_options:
155
151
  - --main
156
152
  - README.rdoc
153
+ - --exclude
154
+ - spec
157
155
  require_paths:
158
156
  - lib
159
157
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -174,6 +172,6 @@ rubyforge_project: termtter
174
172
  rubygems_version: 1.2.0
175
173
  signing_key:
176
174
  specification_version: 2
177
- summary: Termtter is a terminal based Twitter client
178
- test_files:
179
- - test/test_termtter.rb
175
+ summary: Terminal based Twitter client
176
+ test_files: []
177
+