draftcode-termtter 1.0.8
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/History.txt +4 -0
- data/README.rdoc +100 -0
- data/Rakefile +55 -0
- data/bin/kill_termtter +22 -0
- data/bin/termtter +6 -0
- data/lib/plugins/addspace.rb +27 -0
- data/lib/plugins/april_fool.rb +15 -0
- data/lib/plugins/bomb.rb +39 -0
- data/lib/plugins/clear.rb +14 -0
- data/lib/plugins/command_plus.rb +47 -0
- data/lib/plugins/confirm.rb +33 -0
- data/lib/plugins/cool.rb +10 -0
- data/lib/plugins/countter.rb +23 -0
- data/lib/plugins/devel.rb +18 -0
- data/lib/plugins/direct_messages.rb +36 -0
- data/lib/plugins/en2ja.rb +11 -0
- data/lib/plugins/english.rb +25 -0
- data/lib/plugins/erb.rb +17 -0
- data/lib/plugins/exec.rb +17 -0
- data/lib/plugins/exec_and_update.rb +14 -0
- data/lib/plugins/expand-tinyurl.rb +34 -0
- data/lib/plugins/fib.rb +28 -0
- data/lib/plugins/fib_filter.rb +14 -0
- data/lib/plugins/filter.rb +69 -0
- data/lib/plugins/graduatter.rb +8 -0
- data/lib/plugins/grass.rb +27 -0
- data/lib/plugins/group.rb +64 -0
- data/lib/plugins/growl.rb +52 -0
- data/lib/plugins/growl2.rb +143 -0
- data/lib/plugins/hatebu.rb +59 -0
- data/lib/plugins/hatebu_and_update.rb +58 -0
- data/lib/plugins/history.rb +93 -0
- data/lib/plugins/ignore.rb +19 -0
- data/lib/plugins/keyword.rb +18 -0
- data/lib/plugins/l2.rb +25 -0
- data/lib/plugins/log.rb +73 -0
- data/lib/plugins/me.rb +10 -0
- data/lib/plugins/modify_arg_hook_sample.rb +7 -0
- data/lib/plugins/msagent.rb +38 -0
- data/lib/plugins/multi_reply.rb +27 -0
- data/lib/plugins/notify-send.rb +22 -0
- data/lib/plugins/notify-send2.rb +52 -0
- data/lib/plugins/notify-send3.rb +45 -0
- data/lib/plugins/open_url.rb +59 -0
- data/lib/plugins/otsune.rb +21 -0
- data/lib/plugins/outputz.rb +33 -0
- data/lib/plugins/pause.rb +3 -0
- data/lib/plugins/post_exec_hook_sample.rb +9 -0
- data/lib/plugins/pre_exec_hook_sample.rb +9 -0
- data/lib/plugins/primes.rb +30 -0
- data/lib/plugins/quicklook.rb +41 -0
- data/lib/plugins/random.rb +23 -0
- data/lib/plugins/reblog.rb +40 -0
- data/lib/plugins/reload.rb +3 -0
- data/lib/plugins/reply.rb +8 -0
- data/lib/plugins/retweet.rb +46 -0
- data/lib/plugins/reverse.rb +13 -0
- data/lib/plugins/say.rb +26 -0
- data/lib/plugins/scrape.rb +41 -0
- data/lib/plugins/screen-notify.rb +20 -0
- data/lib/plugins/screen.rb +24 -0
- data/lib/plugins/shell.rb +14 -0
- data/lib/plugins/sl.rb +48 -0
- data/lib/plugins/spam.rb +16 -0
- data/lib/plugins/standard_plugins.rb +525 -0
- data/lib/plugins/stdout.rb +220 -0
- data/lib/plugins/storage.rb +55 -0
- data/lib/plugins/storage/DB.rb +37 -0
- data/lib/plugins/storage/status.rb +83 -0
- data/lib/plugins/storage/status_mook.rb +30 -0
- data/lib/plugins/switch_user.rb +22 -0
- data/lib/plugins/system_status.rb +33 -0
- data/lib/plugins/timer.rb +18 -0
- data/lib/plugins/tinyurl.rb +20 -0
- data/lib/plugins/translation.rb +38 -0
- data/lib/plugins/typable_id.rb +94 -0
- data/lib/plugins/update_editor.rb +53 -0
- data/lib/plugins/uri-open.rb +66 -0
- data/lib/plugins/wassr_post.rb +22 -0
- data/lib/plugins/yhara.rb +148 -0
- data/lib/plugins/yhara_filter.rb +8 -0
- data/lib/plugins/yonda.rb +21 -0
- data/lib/termtter.rb +38 -0
- data/lib/termtter/api.rb +57 -0
- data/lib/termtter/client.rb +324 -0
- data/lib/termtter/command.rb +80 -0
- data/lib/termtter/config.rb +68 -0
- data/lib/termtter/config_setup.rb +38 -0
- data/lib/termtter/connection.rb +41 -0
- data/lib/termtter/hook.rb +31 -0
- data/lib/termtter/optparse.rb +14 -0
- data/lib/termtter/system_extensions.rb +115 -0
- data/lib/termtter/task.rb +17 -0
- data/lib/termtter/task_manager.rb +116 -0
- data/lib/termtter/version.rb +4 -0
- data/spec/plugins/cool_spec.rb +10 -0
- data/spec/plugins/english_spec.rb +19 -0
- data/spec/plugins/fib_spec.rb +15 -0
- data/spec/plugins/filter_spec.rb +18 -0
- data/spec/plugins/pause_spec.rb +8 -0
- data/spec/plugins/primes_spec.rb +15 -0
- data/spec/plugins/shell_spec.rb +10 -0
- data/spec/plugins/sl_spec.rb +8 -0
- data/spec/plugins/spam_spec.rb +4 -0
- data/spec/plugins/standard_plugins_spec.rb +23 -0
- data/spec/plugins/storage/DB_spec.rb +12 -0
- data/spec/plugins/storage/status_spec.rb +24 -0
- data/spec/spec_helper.rb +7 -0
- data/spec/termtter/client_spec.rb +255 -0
- data/spec/termtter/command_spec.rb +107 -0
- data/spec/termtter/config_spec.rb +111 -0
- data/spec/termtter/hook_spec.rb +78 -0
- data/spec/termtter/task_manager_spec.rb +78 -0
- data/spec/termtter/task_spec.rb +22 -0
- data/spec/termtter_spec.rb +29 -0
- data/test/friends_timeline.json +5 -0
- data/test/search.json +8 -0
- metadata +211 -0
|
@@ -0,0 +1,107 @@
|
|
|
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 return command regex' do
|
|
21
|
+
@command.pattern.should == /^((update|u|up)|(update|u|up)\s+(.*?))\s*$/
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it 'should be given name as String or Symbol' do
|
|
25
|
+
Command.new(:name => 'foo').name.should == :foo
|
|
26
|
+
Command.new(:name => :foo).name.should == :foo
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
it 'should return name' do
|
|
30
|
+
@command.name.should == :update
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
it 'should return aliases' do
|
|
34
|
+
@command.aliases.should == [:u, :up]
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
it 'should return commands' do
|
|
38
|
+
@command.commands.should == [:update, :u, :up]
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
it 'should return help' do
|
|
42
|
+
@command.help.should == ['update,u TEXT', 'test command']
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
it 'should return candidates for completion' do
|
|
46
|
+
# complement
|
|
47
|
+
[
|
|
48
|
+
['upd', ['update']],
|
|
49
|
+
[' upd', []],
|
|
50
|
+
[' upd ', []],
|
|
51
|
+
['update a', ['complete1', 'complete2']],
|
|
52
|
+
[' update ', []],
|
|
53
|
+
['u foo', ['complete1', 'complete2']],
|
|
54
|
+
].each do |input, comp|
|
|
55
|
+
@command.complement(input).should == comp
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
it 'should return command_info when call method "match?"' do
|
|
60
|
+
[
|
|
61
|
+
['update', true],
|
|
62
|
+
['up', true],
|
|
63
|
+
['u', true],
|
|
64
|
+
['update ', true],
|
|
65
|
+
[' update ', false],
|
|
66
|
+
['update foo', true],
|
|
67
|
+
[' update foo', false],
|
|
68
|
+
[' update foo ', false],
|
|
69
|
+
['u foo', true],
|
|
70
|
+
['up foo', true],
|
|
71
|
+
['upd foo', false],
|
|
72
|
+
['upd foo', false],
|
|
73
|
+
].each do |input, result|
|
|
74
|
+
@command.match?(input).should == result
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
it 'should raise ArgumentError when constructor arguments are deficient' do
|
|
79
|
+
lambda { Command.new }.should raise_error(ArgumentError)
|
|
80
|
+
lambda { Command.new(:exec_proc => lambda {|args|}) }.should raise_error(ArgumentError)
|
|
81
|
+
lambda { Command.new(:aliases => ['u']) }.should raise_error(ArgumentError)
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
it 'should call exec_proc when call method "call"' do
|
|
85
|
+
@command.call('foo', 'test', 'foo test').should == 'test'
|
|
86
|
+
@command.call('foo', ' test', 'foo test').should == ' test'
|
|
87
|
+
@command.call('foo', ' test ', 'foo test ').should == ' test '
|
|
88
|
+
@command.call('foo', 'test test', 'foo test test').should == 'test test'
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
it 'should raise ArgumentError at call' do
|
|
92
|
+
lambda { @command.call('foo', nil, 'foo') }.should_not raise_error(ArgumentError)
|
|
93
|
+
lambda { @command.call('foo', 'foo', 'foo') }.should_not raise_error(ArgumentError)
|
|
94
|
+
lambda { @command.call('foo', false, 'foo') }.should raise_error(ArgumentError)
|
|
95
|
+
lambda { @command.call('foo', Array.new, 'foo') }.should raise_error(ArgumentError)
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
it 'split command line' do
|
|
99
|
+
Command.split_command_line('test foo bar').should == ['test', 'foo bar']
|
|
100
|
+
Command.split_command_line('test foo bar').should == ['test', 'foo bar']
|
|
101
|
+
Command.split_command_line('test foo bar').should == ['test', 'foo bar']
|
|
102
|
+
Command.split_command_line(' test foo bar').should == ['test', 'foo bar']
|
|
103
|
+
Command.split_command_line(' test foo bar ').should == ['test', 'foo bar']
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
|
4
|
+
|
|
5
|
+
module Termtter
|
|
6
|
+
describe Config do
|
|
7
|
+
before do
|
|
8
|
+
@config = Config.new
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
it 'should be able to store value to new storage' do
|
|
12
|
+
@config.new_storage = :value
|
|
13
|
+
@config.new_storage.should == :value
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it 'should be able to make subb.key and store value' do
|
|
17
|
+
@config.subb.key = :value
|
|
18
|
+
@config.subb.key.should == :value
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
it 'should be able to make multiple storage' do
|
|
22
|
+
@config.subb.more.for.test = 'value'
|
|
23
|
+
@config.subb.more.for.test.should == 'value'
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it 'should be able to change value in storage' do
|
|
27
|
+
@config.storage = :value1
|
|
28
|
+
@config.storage = :value2
|
|
29
|
+
@config.storage.should == :value2
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
it 'should be able to store any data' do
|
|
33
|
+
[
|
|
34
|
+
['string', 'value' ],
|
|
35
|
+
['symbol', :value ],
|
|
36
|
+
['arrry', [:a, :b] ],
|
|
37
|
+
['hashes', {:a => :b}],
|
|
38
|
+
['integer', 1 ],
|
|
39
|
+
['float', 1.5 ],
|
|
40
|
+
['regexp', /regexp/ ],
|
|
41
|
+
].each do |type, value|
|
|
42
|
+
@config.__send__("#{type}=", value)
|
|
43
|
+
@config.__send__(type).should == value
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
it 'should raise error when add by prohibited name' do
|
|
48
|
+
lambda {
|
|
49
|
+
@config.set_default('sub.aaa', :value)
|
|
50
|
+
@config.sub.aaa
|
|
51
|
+
}.should raise_error
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
it 'should raise error when add subb-storage to existed key' do
|
|
55
|
+
@config.subb = 'original value'
|
|
56
|
+
lambda {
|
|
57
|
+
@config.subb.key = 'invalid subbstitution'
|
|
58
|
+
}.should raise_error(
|
|
59
|
+
NoMethodError,
|
|
60
|
+
%r[undefined method `key=' for "original value":String]
|
|
61
|
+
)
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
it 'should set intermediate defult configs' do
|
|
65
|
+
@config.set_default 'subb.more', 'value'
|
|
66
|
+
@config.subb.class.should == Config
|
|
67
|
+
@config.subb.more.should == 'value'
|
|
68
|
+
|
|
69
|
+
@config.proxy.set_default(:port, 'value')
|
|
70
|
+
@config.proxy.port.should == 'value'
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
# FIXME: not work
|
|
74
|
+
# it 'should have :undefined value in un-assigned key' do
|
|
75
|
+
# @config.aaaa.should == :undefined
|
|
76
|
+
# end
|
|
77
|
+
|
|
78
|
+
it 'should be empty when something is assigned' do
|
|
79
|
+
@config.empty?.should be_true
|
|
80
|
+
|
|
81
|
+
@config.aaa = 1
|
|
82
|
+
@config.empty?.should be_false
|
|
83
|
+
|
|
84
|
+
@config.bbb.empty?.should be_true
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
it 'should be empty when assigned nil' do
|
|
88
|
+
@config.bbb = nil
|
|
89
|
+
@config.empty?.should be_false
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
it 'should be empty when set_defaulted' do
|
|
93
|
+
@config.set_default('aaa', 1)
|
|
94
|
+
@config.empty?.should be_false
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
it 'should use in expression' do
|
|
98
|
+
@config.set_default(:ssb, 'hoge')
|
|
99
|
+
lambda {
|
|
100
|
+
res = @config.ssb + ' piyo'
|
|
101
|
+
res.should == 'hoge piyo'
|
|
102
|
+
}.should_not raise_error
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
it 'should not change value when call set_default twice' do
|
|
106
|
+
@config.plugins.set_default :only, 'before_value'
|
|
107
|
+
@config.plugins.set_default :only, 'after_value'
|
|
108
|
+
@config.plugins.only.should == 'before_value'
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
end
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
|
4
|
+
|
|
5
|
+
module Termtter
|
|
6
|
+
describe Hook do
|
|
7
|
+
before do
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
it 'should match' do
|
|
11
|
+
hook = Hook.new(
|
|
12
|
+
:name => :spam,
|
|
13
|
+
:points => ['foo'],
|
|
14
|
+
:exec_proc => lambda{|cmd, arg|
|
|
15
|
+
}
|
|
16
|
+
)
|
|
17
|
+
hook.match?('foo').should == true
|
|
18
|
+
hook.match?('bar').should == false
|
|
19
|
+
hook.match?(:foo).should == true
|
|
20
|
+
hook.match?(:bar).should == false
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it 'should match when multi points' do
|
|
24
|
+
hook = Hook.new(
|
|
25
|
+
:name => :spam,
|
|
26
|
+
:points => ['foo', 'bar'],
|
|
27
|
+
:exec_proc => lambda{|cmd, arg|
|
|
28
|
+
}
|
|
29
|
+
)
|
|
30
|
+
hook.match?('foo').should == true
|
|
31
|
+
hook.match?('bar').should == true
|
|
32
|
+
hook.match?(:foo).should == true
|
|
33
|
+
hook.match?(:bar).should == true
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it 'should match when multi points' do
|
|
37
|
+
hook = Hook.new(
|
|
38
|
+
:name => :spam,
|
|
39
|
+
:points => ['foo', /bar/],
|
|
40
|
+
:exec_proc => lambda{|cmd, arg|
|
|
41
|
+
}
|
|
42
|
+
)
|
|
43
|
+
hook.match?('foo').should == true
|
|
44
|
+
hook.match?('bar').should == true
|
|
45
|
+
hook.match?('_bar_').should == true
|
|
46
|
+
hook.match?(:foo).should == true
|
|
47
|
+
hook.match?(:_bar_).should == true
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
it 'should match when multi points' do
|
|
51
|
+
hook = Hook.new(
|
|
52
|
+
:name => :spam,
|
|
53
|
+
:points => ['foo', /^bar/],
|
|
54
|
+
:exec_proc => lambda{|cmd, arg|
|
|
55
|
+
}
|
|
56
|
+
)
|
|
57
|
+
hook.match?('bar').should == true
|
|
58
|
+
hook.match?('bar_').should == true
|
|
59
|
+
hook.match?('_bar_').should == false
|
|
60
|
+
hook.match?(:'bar').should == true
|
|
61
|
+
hook.match?(:'bar_').should == true
|
|
62
|
+
hook.match?(:'_bar_').should == false
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
it 'call hook proc' do
|
|
66
|
+
proc_args = nil
|
|
67
|
+
hook = Hook.new(
|
|
68
|
+
:name => :spam,
|
|
69
|
+
:points => ['foo'],
|
|
70
|
+
:exec_proc => lambda{|*args|
|
|
71
|
+
proc_args = args
|
|
72
|
+
}
|
|
73
|
+
)
|
|
74
|
+
hook.call('foo', 'bar')
|
|
75
|
+
proc_args.should == ['foo', 'bar']
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
end
|
|
@@ -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,29 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
|
4
|
+
|
|
5
|
+
describe Termtter, 'when plugin is called (without init option)' do
|
|
6
|
+
it 'should require global plugin if exist' do
|
|
7
|
+
should_receive(:load).with('plugins/aaa.rb')
|
|
8
|
+
plugin 'aaa'
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
it 'should require user plugin if not exist' do
|
|
12
|
+
should_receive(:load).with('plugins/aaa.rb')
|
|
13
|
+
plugin 'aaa'
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it 'should handle_error if there are no plugins in global or user' do
|
|
17
|
+
Termtter::Client.should_receive(:handle_error)
|
|
18
|
+
plugin 'not-exist-plugin-hehehehehehe'
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
describe Termtter, 'when plugin is called (with init option)' do
|
|
23
|
+
it 'init option will become config' do
|
|
24
|
+
should_receive(:load)
|
|
25
|
+
|
|
26
|
+
plugin 'aaa', :bbb => :ccc
|
|
27
|
+
config.plugins.aaa.bbb.should == :ccc
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
[
|
|
2
|
+
{"in_reply_to_user_id":null,"truncated":false,"created_at":"Sat Jan 03 12:13:45 +0000 2009","user":{"description":"test2 xxxx","followers_count":102,"profile_image_url":"http:\/\/s3.amazonaws.com\/twitter_production\/profile_images\/000\/102.png","url":"http:\/\/twitter.com/test2","name":"Test User 2","protected":false,"screen_name":"test2","location":"Tokyo2","id":102},"favorited":false,"in_reply_to_screen_name":null,"text":"texttext 2","id":10002,"in_reply_to_status_id":null,"source":"<a href=\"http:\/\/ssss2\">ssss2<\/a>"},
|
|
3
|
+
{"in_reply_to_user_id":null,"truncated":false,"created_at":"Sat Jan 03 12:13:45 +0000 2009","user":{"description":"test1 xxxx","followers_count":101,"profile_image_url":"http:\/\/s3.amazonaws.com\/twitter_production\/profile_images\/000\/101.png","url":"http:\/\/twitter.com/test1","name":"Test User 1","protected":false,"screen_name":"test1","location":"Tokyo1","id":101},"favorited":false,"in_reply_to_screen_name":null,"text":"texttext 1","id":10001,"in_reply_to_status_id":null,"source":"<a href=\"http:\/\/ssss1\">ssss1<\/a>"},
|
|
4
|
+
{"in_reply_to_user_id":null,"truncated":false,"created_at":"Sat Jan 03 12:13:45 +0000 2009","user":{"description":"test0 xxxx","followers_count":100,"profile_image_url":"http:\/\/s3.amazonaws.com\/twitter_production\/profile_images\/000\/100.png","url":"http:\/\/twitter.com/test0","name":"Test User 0","protected":false,"screen_name":"test0","location":"Tokyo0","id":100},"favorited":false,"in_reply_to_screen_name":null,"text":"texttext 0","id":10000,"in_reply_to_status_id":null,"source":"<a href=\"http:\/\/ssss0\">ssss0<\/a>"}
|
|
5
|
+
]
|
data/test/search.json
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
{
|
|
2
|
+
"results":[
|
|
3
|
+
{"text":"texttext 2","to_user_id":202,"to_user":"to_user2","from_user":"test2","id":10002,"from_user_id":102,"iso_language_code":"en","profile_image_url":"http:\/\/s3.amazonaws.com\/twitter_production\/profile_images\/xxx\/102.jpg","created_at":"Sat, 03 Jan 2009 12:49:09 +0000"},
|
|
4
|
+
{"text":"texttext 1","to_user_id":101,"to_user":"to_user1","from_user":"test1","id":10001,"from_user_id":101,"iso_language_code":"en","profile_image_url":"http:\/\/s3.amazonaws.com\/twitter_production\/profile_images\/xxx\/101.jpg","created_at":"Sat, 03 Jan 2009 12:49:09 +0000"},
|
|
5
|
+
{"text":"texttext 0","to_user_id":100,"to_user":"to_user0","from_user":"test0","id":10000,"from_user_id":100,"iso_language_code":"en","profile_image_url":"http:\/\/s3.amazonaws.com\/twitter_production\/profile_images\/xxx\/100.jpg","created_at":"Sat, 03 Jan 2009 12:49:09 +0000"}
|
|
6
|
+
],
|
|
7
|
+
"since_id":0,"max_id":1093328763,"refresh_url":"?since_id=1093328763&q=ruby","results_per_page":15,"next_page":"?page=2&max_id=1093328763&q=ruby","completed_in":0.019603,"page":1,"query":"ruby"
|
|
8
|
+
}
|