atig 0.0.1
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/.gitignore +24 -0
- data/Gemfile +3 -0
- data/README.mkdn +52 -0
- data/Rakefile +15 -0
- data/atig.gemspec +25 -0
- data/bin/atig +74 -0
- data/docs/OMakefile +32 -0
- data/docs/OMakeroot +45 -0
- data/docs/_static/allow.png +0 -0
- data/docs/_static/emacs.png +0 -0
- data/docs/_static/irc_setting.png +0 -0
- data/docs/_static/irssi.png +0 -0
- data/docs/_static/limechat.png +0 -0
- data/docs/_static/limechat_s.png +0 -0
- data/docs/_static/oauth_channel.png +0 -0
- data/docs/_static/screenshot.png +0 -0
- data/docs/_static/structure.png +0 -0
- data/docs/_static/verify.png +0 -0
- data/docs/changelog.rst +96 -0
- data/docs/commandline_options.rst +21 -0
- data/docs/commands.rst +84 -0
- data/docs/conf.py +194 -0
- data/docs/config.rst +159 -0
- data/docs/feature.rst +41 -0
- data/docs/graphics.graffle +1995 -0
- data/docs/hacking_guide.rst +43 -0
- data/docs/index.rst +109 -0
- data/docs/irc.rst +31 -0
- data/docs/options.rst +75 -0
- data/docs/quickstart.rst +89 -0
- data/docs/resize.sh +7 -0
- data/docs/tiarra.rst +2 -0
- data/docs/tig.rst +21 -0
- data/lib/atig.rb +19 -0
- data/lib/atig/agent.rb +8 -0
- data/lib/atig/agent/agent.rb +38 -0
- data/lib/atig/agent/clenup.rb +23 -0
- data/lib/atig/agent/dm.rb +35 -0
- data/lib/atig/agent/following.rb +45 -0
- data/lib/atig/agent/full_list.rb +20 -0
- data/lib/atig/agent/list.rb +55 -0
- data/lib/atig/agent/list_status.rb +46 -0
- data/lib/atig/agent/mention.rb +13 -0
- data/lib/atig/agent/other_list.rb +18 -0
- data/lib/atig/agent/own_list.rb +18 -0
- data/lib/atig/agent/stream_follow.rb +38 -0
- data/lib/atig/agent/timeline.rb +13 -0
- data/lib/atig/agent/user_stream.rb +31 -0
- data/lib/atig/basic_twitter.rb +116 -0
- data/lib/atig/bitly.rb +52 -0
- data/lib/atig/channel.rb +5 -0
- data/lib/atig/channel/channel.rb +17 -0
- data/lib/atig/channel/dm.rb +14 -0
- data/lib/atig/channel/list.rb +76 -0
- data/lib/atig/channel/mention.rb +20 -0
- data/lib/atig/channel/retweet.rb +28 -0
- data/lib/atig/channel/timeline.rb +74 -0
- data/lib/atig/command.rb +21 -0
- data/lib/atig/command/autofix.rb +58 -0
- data/lib/atig/command/command.rb +24 -0
- data/lib/atig/command/command_helper.rb +95 -0
- data/lib/atig/command/destroy.rb +44 -0
- data/lib/atig/command/dm.rb +31 -0
- data/lib/atig/command/favorite.rb +27 -0
- data/lib/atig/command/info.rb +50 -0
- data/lib/atig/command/limit.rb +15 -0
- data/lib/atig/command/location.rb +23 -0
- data/lib/atig/command/name.rb +18 -0
- data/lib/atig/command/option.rb +37 -0
- data/lib/atig/command/refresh.rb +18 -0
- data/lib/atig/command/reply.rb +37 -0
- data/lib/atig/command/retweet.rb +63 -0
- data/lib/atig/command/search.rb +51 -0
- data/lib/atig/command/spam.rb +26 -0
- data/lib/atig/command/status.rb +41 -0
- data/lib/atig/command/thread.rb +44 -0
- data/lib/atig/command/time.rb +32 -0
- data/lib/atig/command/uptime.rb +32 -0
- data/lib/atig/command/user.rb +42 -0
- data/lib/atig/command/user_info.rb +27 -0
- data/lib/atig/command/version.rb +49 -0
- data/lib/atig/command/whois.rb +39 -0
- data/lib/atig/db/db.rb +60 -0
- data/lib/atig/db/followings.rb +131 -0
- data/lib/atig/db/listenable.rb +22 -0
- data/lib/atig/db/lists.rb +76 -0
- data/lib/atig/db/roman.rb +30 -0
- data/lib/atig/db/sized_uniq_array.rb +62 -0
- data/lib/atig/db/sql.rb +35 -0
- data/lib/atig/db/statuses.rb +147 -0
- data/lib/atig/db/transaction.rb +47 -0
- data/lib/atig/exception_util.rb +26 -0
- data/lib/atig/gateway.rb +62 -0
- data/lib/atig/gateway/channel.rb +99 -0
- data/lib/atig/gateway/session.rb +326 -0
- data/lib/atig/http.rb +95 -0
- data/lib/atig/ifilter.rb +7 -0
- data/lib/atig/ifilter/expand_url.rb +74 -0
- data/lib/atig/ifilter/retweet.rb +14 -0
- data/lib/atig/ifilter/retweet_time.rb +16 -0
- data/lib/atig/ifilter/sanitize.rb +18 -0
- data/lib/atig/ifilter/strip.rb +15 -0
- data/lib/atig/ifilter/utf7.rb +26 -0
- data/lib/atig/ifilter/xid.rb +36 -0
- data/lib/atig/levenshtein.rb +49 -0
- data/lib/atig/monkey.rb +4 -0
- data/lib/atig/oauth-patch.rb +40 -0
- data/lib/atig/oauth.rb +55 -0
- data/lib/atig/ofilter.rb +4 -0
- data/lib/atig/ofilter/escape_url.rb +102 -0
- data/lib/atig/ofilter/footer.rb +20 -0
- data/lib/atig/ofilter/geo.rb +17 -0
- data/lib/atig/ofilter/short_url.rb +47 -0
- data/lib/atig/option.rb +90 -0
- data/lib/atig/scheduler.rb +79 -0
- data/lib/atig/search.rb +22 -0
- data/lib/atig/search_twitter.rb +21 -0
- data/lib/atig/sized_hash.rb +33 -0
- data/lib/atig/stream.rb +66 -0
- data/lib/atig/twitter.rb +79 -0
- data/lib/atig/twitter_struct.rb +63 -0
- data/lib/atig/unu.rb +27 -0
- data/lib/atig/update_checker.rb +53 -0
- data/lib/atig/url_escape.rb +62 -0
- data/lib/atig/util.rb +16 -0
- data/lib/atig/version.rb +3 -0
- data/lib/memory_profiler.rb +77 -0
- data/spec/command/autofix_spec.rb +35 -0
- data/spec/command/destroy_spec.rb +98 -0
- data/spec/command/dm_spec.rb +28 -0
- data/spec/command/favorite_spec.rb +55 -0
- data/spec/command/limit_spec.rb +27 -0
- data/spec/command/location_spec.rb +25 -0
- data/spec/command/name_spec.rb +19 -0
- data/spec/command/option_spec.rb +133 -0
- data/spec/command/refresh_spec.rb +22 -0
- data/spec/command/reply_spec.rb +79 -0
- data/spec/command/retweet_spec.rb +66 -0
- data/spec/command/spam_spec.rb +27 -0
- data/spec/command/status_spec.rb +44 -0
- data/spec/command/thread_spec.rb +91 -0
- data/spec/command/time_spec.rb +52 -0
- data/spec/command/uptime_spec.rb +55 -0
- data/spec/command/user_info_spec.rb +42 -0
- data/spec/command/user_spec.rb +50 -0
- data/spec/command/version_spec.rb +67 -0
- data/spec/command/whois_spec.rb +78 -0
- data/spec/db/followings_spec.rb +100 -0
- data/spec/db/listenable_spec.rb +32 -0
- data/spec/db/lists_spec.rb +104 -0
- data/spec/db/roman_spec.rb +17 -0
- data/spec/db/sized_uniq_array_spec.rb +63 -0
- data/spec/db/statuses_spec.rb +180 -0
- data/spec/ifilter/expand_url_spec.rb +44 -0
- data/spec/ifilter/retweet_spec.rb +28 -0
- data/spec/ifilter/retweet_time_spec.rb +25 -0
- data/spec/ifilter/sanitize_spec.rb +25 -0
- data/spec/ifilter/sid_spec.rb +29 -0
- data/spec/ifilter/strip_spec.rb +23 -0
- data/spec/ifilter/tid_spec.rb +29 -0
- data/spec/ifilter/utf7_spec.rb +30 -0
- data/spec/levenshtein_spec.rb +24 -0
- data/spec/ofilter/escape_url_spec.rb +50 -0
- data/spec/ofilter/footer_spec.rb +32 -0
- data/spec/ofilter/geo_spec.rb +33 -0
- data/spec/ofilter/short_url_spec.rb +127 -0
- data/spec/option_spec.rb +91 -0
- data/spec/sized_hash_spec.rb +45 -0
- data/spec/spec_helper.rb +35 -0
- data/spec/update_checker_spec.rb +55 -0
- metadata +326 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# -*- mode:ruby; coding:utf-8 -*-
|
|
2
|
+
|
|
3
|
+
require File.expand_path( '../../spec_helper', __FILE__ )
|
|
4
|
+
require 'atig/ifilter/utf7'
|
|
5
|
+
require 'atig/twitter_struct'
|
|
6
|
+
|
|
7
|
+
describe Atig::IFilter::Utf7 do
|
|
8
|
+
def filtered(text)
|
|
9
|
+
logger = mock('logger').should_receive(:error).at_most(:once)
|
|
10
|
+
ifilter = Atig::IFilter::Utf7.new(OpenStruct.new(:log=>logger,
|
|
11
|
+
:opts=>OpenStruct.new))
|
|
12
|
+
ifilter.call status(text)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it "should be used in Iconv" do
|
|
16
|
+
defined?(::Iconv).should be_true
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it "should through ASCII" do
|
|
20
|
+
filtered("hello").should be_text("hello")
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it "should decode +sequence" do
|
|
24
|
+
filtered("1 +- 1 = 2").should be_text("1 + 1 = 2")
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
it "should decode pound sign" do
|
|
28
|
+
filtered("+AKM-1").should be_text("£1")
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# -*- mode:ruby; coding:utf-8 -*-
|
|
2
|
+
|
|
3
|
+
require File.expand_path( '../spec_helper', __FILE__ )
|
|
4
|
+
require 'atig/levenshtein'
|
|
5
|
+
|
|
6
|
+
target = [Atig::Levenshtein, Atig::Levenshtein::PureRuby]
|
|
7
|
+
|
|
8
|
+
target.each do |m|
|
|
9
|
+
describe m do
|
|
10
|
+
it "should return correct levenshtein distance" do
|
|
11
|
+
[
|
|
12
|
+
["kitten", "sitting", 3],
|
|
13
|
+
["foo", "foo", 0],
|
|
14
|
+
["", "", 0],
|
|
15
|
+
["foO", "foo", 1],
|
|
16
|
+
["", "foo", 3],
|
|
17
|
+
["あああ", "ああい", 1],
|
|
18
|
+
].each do |a, b, expected|
|
|
19
|
+
m.levenshtein(a.split(//), b.split(//)).should == expected
|
|
20
|
+
m.levenshtein(b.split(//), a.split(//)).should == expected
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# -*- mode:ruby; coding:utf-8 -*-
|
|
2
|
+
|
|
3
|
+
require File.expand_path( '../../spec_helper', __FILE__ )
|
|
4
|
+
require 'atig/ofilter/escape_url'
|
|
5
|
+
|
|
6
|
+
class Atig::OFilter::EscapeUrl
|
|
7
|
+
def exist_uri?(_); true end
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
describe Atig::OFilter::EscapeUrl do
|
|
11
|
+
before do
|
|
12
|
+
@logger = mock('Logger')
|
|
13
|
+
@logger.should_receive(:info).at_most(:once)
|
|
14
|
+
@logger.should_receive(:error).at_most(:once)
|
|
15
|
+
@logger.should_receive(:debug).at_most(:once)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def filtered(text,opt={})
|
|
19
|
+
esc = Atig::OFilter::EscapeUrl.new(OpenStruct.new(:log=>@logger,:opts=>nil))
|
|
20
|
+
esc.call :status => text
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it "through normal url" do
|
|
24
|
+
filtered("http://example.com").should == { :status => "http://example.com"}
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
it "escape only url" do
|
|
28
|
+
filtered("あああ http://example.com/あああ").should == { :status => "あああ http://example.com/%E3%81%82%E3%81%82%E3%81%82" }
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
if defined? ::Punycode then
|
|
33
|
+
describe Atig::OFilter::EscapeUrl,"when punycode is enabled" do
|
|
34
|
+
before do
|
|
35
|
+
@logger = mock('Logger')
|
|
36
|
+
@logger.should_receive(:info).at_most(:once)
|
|
37
|
+
@logger.should_receive(:error).at_most(:once)
|
|
38
|
+
@logger.should_receive(:debug).at_most(:once)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def filtered(text,opt={})
|
|
42
|
+
esc = Atig::OFilter::EscapeUrl.new(OpenStruct.new(:log=>@logger,:opts=>nil))
|
|
43
|
+
esc.call :status => text
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
it "escape international URL" do
|
|
47
|
+
filtered("http://あああ.com").should == {:status => "http://xn--l8jaa.com" }
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# -*- mode:ruby; coding:utf-8 -*-
|
|
2
|
+
|
|
3
|
+
require File.expand_path( '../../spec_helper', __FILE__ )
|
|
4
|
+
require 'atig/ofilter/footer'
|
|
5
|
+
require 'ostruct'
|
|
6
|
+
|
|
7
|
+
describe Atig::OFilter::Footer do
|
|
8
|
+
before do
|
|
9
|
+
@opts = OpenStruct.new
|
|
10
|
+
@filter = Atig::OFilter::Footer.new(OpenStruct.new(:opts=>@opts))
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it "should pass through" do
|
|
14
|
+
@filter.call(:status => 'hi').should == {
|
|
15
|
+
:status => "hi"
|
|
16
|
+
}
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it "should append footer" do
|
|
20
|
+
@opts.footer = '*tw*'
|
|
21
|
+
@filter.call(:status => 'hi').should == {
|
|
22
|
+
:status => "hi *tw*"
|
|
23
|
+
}
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it "should not append footer" do
|
|
27
|
+
@opts.footer = false
|
|
28
|
+
@filter.call(:status => 'hi').should == {
|
|
29
|
+
:status => "hi"
|
|
30
|
+
}
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# -*- mode:ruby; coding:utf-8 -*-
|
|
2
|
+
|
|
3
|
+
require File.expand_path( '../../spec_helper', __FILE__ )
|
|
4
|
+
require 'atig/ofilter/geo'
|
|
5
|
+
require 'ostruct'
|
|
6
|
+
|
|
7
|
+
describe Atig::OFilter::Geo,"when disabled" do
|
|
8
|
+
def filtered(text,opt={})
|
|
9
|
+
geo = Atig::OFilter::Geo.new(OpenStruct.new(:opts=>OpenStruct.new(opt)))
|
|
10
|
+
geo.call :status => text
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it "should through" do
|
|
14
|
+
filtered("hi").should == {
|
|
15
|
+
:status => "hi"
|
|
16
|
+
}
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
describe Atig::OFilter::Geo,"when enabled" do
|
|
21
|
+
def filtered(text,opt={})
|
|
22
|
+
geo = Atig::OFilter::Geo.new(OpenStruct.new(:opts=>OpenStruct.new(opt)))
|
|
23
|
+
geo.call :status => text
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it "add lat & long" do
|
|
27
|
+
filtered("hi",:ll=>"42.1,43.1").should == {
|
|
28
|
+
:status => "hi",
|
|
29
|
+
:lat => 42.1,
|
|
30
|
+
:long => 43.1
|
|
31
|
+
}
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
# -*- mode:ruby; coding:utf-8 -*-
|
|
2
|
+
|
|
3
|
+
require File.expand_path( '../../spec_helper', __FILE__ )
|
|
4
|
+
require 'atig/ofilter/short_url'
|
|
5
|
+
require 'ostruct'
|
|
6
|
+
|
|
7
|
+
describe Atig::OFilter::ShortUrl,"when no-login bitly" do
|
|
8
|
+
before do
|
|
9
|
+
logger = mock('Logger')
|
|
10
|
+
bitly = mock("Bitly")
|
|
11
|
+
bitly.stub!(:shorten).and_return{|s|
|
|
12
|
+
"[#{s}]"
|
|
13
|
+
}
|
|
14
|
+
Atig::Bitly.should_receive(:no_login).with(logger).and_return(bitly)
|
|
15
|
+
@ofilter = Atig::OFilter::ShortUrl.new(OpenStruct.new(:log=>logger, :opts=>OpenStruct.new('bitlify'=>true)))
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it "should shorten url by bitly" do
|
|
19
|
+
@ofilter.call({:status => "this is http://example.com/a http://example.com/b"}).should == {
|
|
20
|
+
:status => "this is [http://example.com/a] [http://example.com/b]"
|
|
21
|
+
}
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
describe Atig::OFilter::ShortUrl,"when no-login bitly with size" do
|
|
26
|
+
before do
|
|
27
|
+
logger = mock('Logger')
|
|
28
|
+
bitly = mock("Bitly")
|
|
29
|
+
bitly.stub!(:shorten).and_return{|s|
|
|
30
|
+
"[#{s}]"
|
|
31
|
+
}
|
|
32
|
+
Atig::Bitly.should_receive(:no_login).with(logger).and_return(bitly)
|
|
33
|
+
@ofilter = Atig::OFilter::ShortUrl.new(OpenStruct.new(:log=>logger, :opts=>OpenStruct.new('bitlify'=>13)))
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it "should only shorten large url" do
|
|
37
|
+
@ofilter.call({:status => "this is http://example.com/a http://a.com"}).should == {
|
|
38
|
+
:status => "this is [http://example.com/a] http://a.com"
|
|
39
|
+
}
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
describe Atig::OFilter::ShortUrl,"when login bitly" do
|
|
44
|
+
before do
|
|
45
|
+
logger = mock('Logger')
|
|
46
|
+
bitly = mock("Bitly")
|
|
47
|
+
bitly.stub!(:shorten).and_return{|s|
|
|
48
|
+
"[#{s}]"
|
|
49
|
+
}
|
|
50
|
+
Atig::Bitly.should_receive(:login).with(logger,"username","api_key").and_return(bitly)
|
|
51
|
+
@ofilter = Atig::OFilter::ShortUrl.new(OpenStruct.new(:log=>logger, :opts=>OpenStruct.new('bitlify'=>'username:api_key')))
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
it "should only shorten large url" do
|
|
55
|
+
@ofilter.call({:status => "this is http://example.com/a http://example.com/b"}).should == {
|
|
56
|
+
:status => "this is [http://example.com/a] [http://example.com/b]"
|
|
57
|
+
}
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
describe Atig::OFilter::ShortUrl,"when login bitly with size" do
|
|
62
|
+
before do
|
|
63
|
+
logger = mock('Logger')
|
|
64
|
+
bitly = mock("Bitly")
|
|
65
|
+
bitly.stub!(:shorten).and_return{|s|
|
|
66
|
+
"[#{s}]"
|
|
67
|
+
}
|
|
68
|
+
Atig::Bitly.should_receive(:login).with(logger,"username","api_key").and_return(bitly)
|
|
69
|
+
@ofilter = Atig::OFilter::ShortUrl.new(OpenStruct.new(:log=>logger, :opts=>OpenStruct.new('bitlify'=>'username:api_key:13')))
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
it "should only shorten large url" do
|
|
73
|
+
@ofilter.call({:status => "this is http://example.com/a http://a.com"}).should == {
|
|
74
|
+
:status => "this is [http://example.com/a] http://a.com"
|
|
75
|
+
}
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
describe Atig::OFilter::ShortUrl,"when unu bitly" do
|
|
80
|
+
before do
|
|
81
|
+
logger = mock('Logger')
|
|
82
|
+
unu = mock("Unu")
|
|
83
|
+
unu.stub!(:shorten).and_return{|s|
|
|
84
|
+
"[#{s}]"
|
|
85
|
+
}
|
|
86
|
+
Atig::Unu.should_receive(:new).with(logger).and_return(unu)
|
|
87
|
+
@ofilter = Atig::OFilter::ShortUrl.new(OpenStruct.new(:log=>logger, :opts=>OpenStruct.new('unuify'=>true)))
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
it "should shorten url by unu" do
|
|
91
|
+
@ofilter.call({:status => "this is http://example.com/a http://example.com/b"}).should == {
|
|
92
|
+
:status => "this is [http://example.com/a] [http://example.com/b]"
|
|
93
|
+
}
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
describe Atig::OFilter::ShortUrl,"when no-login unu with size" do
|
|
98
|
+
before do
|
|
99
|
+
logger = mock('Logger')
|
|
100
|
+
unu = mock("Unu")
|
|
101
|
+
unu.stub!(:shorten).and_return{|s|
|
|
102
|
+
"[#{s}]"
|
|
103
|
+
}
|
|
104
|
+
Atig::Unu.should_receive(:new).with(logger).and_return(unu)
|
|
105
|
+
@ofilter = Atig::OFilter::ShortUrl.new(OpenStruct.new(:log=>logger, :opts=>OpenStruct.new('unuify'=>13)))
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
it "should only shorten large url" do
|
|
109
|
+
@ofilter.call({:status => "this is http://example.com/a http://a.com"}).should == {
|
|
110
|
+
:status => "this is [http://example.com/a] http://a.com"
|
|
111
|
+
}
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
describe Atig::OFilter::ShortUrl,"when nop" do
|
|
116
|
+
before do
|
|
117
|
+
logger = mock('Logger')
|
|
118
|
+
|
|
119
|
+
@ofilter = Atig::OFilter::ShortUrl.new(OpenStruct.new(:log=>logger, :opts=>OpenStruct.new()))
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
it "should only not do anything" do
|
|
123
|
+
@ofilter.call({:status => "this is http://example.com/a http://a.com"}).should == {
|
|
124
|
+
:status => "this is http://example.com/a http://a.com"
|
|
125
|
+
}
|
|
126
|
+
end
|
|
127
|
+
end
|
data/spec/option_spec.rb
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# -*- mode:ruby; coding:utf-8 -*-
|
|
2
|
+
|
|
3
|
+
require File.expand_path( '../spec_helper', __FILE__ )
|
|
4
|
+
require 'atig/option'
|
|
5
|
+
|
|
6
|
+
describe Atig::Option do
|
|
7
|
+
before do
|
|
8
|
+
@opt = Atig::Option.parse 'a b=1 c=1.2 d=foo'
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
it "should have bool property" do
|
|
12
|
+
@opt.a.should be_true
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it "should have int property" do
|
|
16
|
+
@opt.b.should == 1
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it "should have float property" do
|
|
20
|
+
@opt.c.should == 1.2
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it "should have string property" do
|
|
24
|
+
@opt.d.should == 'foo'
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
it "should not have other property" do
|
|
28
|
+
@opt.e.should == nil
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it "should update the value" do
|
|
32
|
+
@opt.a = false
|
|
33
|
+
@opt.a.should be_false
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it "should be accessed by [name]" do
|
|
37
|
+
@opt[:a].should be_true
|
|
38
|
+
@opt['a'].should be_true
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
it "should be updated by [name]=" do
|
|
42
|
+
@opt[:a] = false
|
|
43
|
+
|
|
44
|
+
@opt.a.should be_false
|
|
45
|
+
@opt[:a].should be_false
|
|
46
|
+
@opt['a'].should be_false
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
it "should be updated by [name]=" do
|
|
50
|
+
@opt['a'] = false
|
|
51
|
+
|
|
52
|
+
@opt.a.should be_false
|
|
53
|
+
@opt[:a].should be_false
|
|
54
|
+
@opt['a'].should be_false
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
it "should be created by [name]=" do
|
|
58
|
+
@opt['e'] = false
|
|
59
|
+
|
|
60
|
+
@opt.e.should be_false
|
|
61
|
+
@opt[:e].should be_false
|
|
62
|
+
@opt['e'].should be_false
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
it "should be access to id" do
|
|
66
|
+
@opt.id.should be_nil
|
|
67
|
+
@opt.id = 1
|
|
68
|
+
@opt.id.should == 1
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
it "should have default value" do
|
|
72
|
+
@opt.api_base.should == 'https://api.twitter.com/1/'
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
it "should list up all fields" do
|
|
76
|
+
@opt.fields.map{|x| x.to_s }.sort.should == %w(api_base stream_api_base search_api_base a b c d).sort
|
|
77
|
+
|
|
78
|
+
@opt.e = 1
|
|
79
|
+
@opt.fields.map{|x| x.to_s }.sort.should == %w(api_base search_api_base stream_api_base a b c d e).sort
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
describe Atig::Option,'with not default value' do
|
|
84
|
+
before do
|
|
85
|
+
@opt = Atig::Option.parse 'hoge api_base=twitter.com'
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
it "should be specified value" do
|
|
89
|
+
@opt.api_base.should == 'twitter.com'
|
|
90
|
+
end
|
|
91
|
+
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# -*- mode:ruby; coding:utf-8 -*-
|
|
2
|
+
|
|
3
|
+
require File.expand_path( '../spec_helper', __FILE__ )
|
|
4
|
+
require 'atig/sized_hash'
|
|
5
|
+
|
|
6
|
+
describe Atig::SizedHash do
|
|
7
|
+
before do
|
|
8
|
+
@hash = Atig::SizedHash.new 3
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
it "はkeyとvalueでアクセスできる" do
|
|
12
|
+
@hash[:foo] = :bar
|
|
13
|
+
@hash[:foo].should == :bar
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it "はサイズが取得できる" do
|
|
17
|
+
@hash.size == 0
|
|
18
|
+
|
|
19
|
+
@hash[:foo] = :bar
|
|
20
|
+
@hash.size == 1
|
|
21
|
+
|
|
22
|
+
@hash[:foo] = :baz
|
|
23
|
+
@hash.size == 1
|
|
24
|
+
|
|
25
|
+
@hash[:xyzzy] = :hoge
|
|
26
|
+
@hash.size == 2
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
it "は古いのが消える" do
|
|
30
|
+
('a'..'c').each{|c| @hash[c] = 42 }
|
|
31
|
+
|
|
32
|
+
@hash.key?('a').should be_true
|
|
33
|
+
|
|
34
|
+
@hash['d'] = 42
|
|
35
|
+
@hash.key?('a').should be_false
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
it "は使うたびに寿命が伸びる" do
|
|
39
|
+
('a'..'c').each{|c| @hash[c] = 42 }
|
|
40
|
+
@hash['a']
|
|
41
|
+
@hash['d'] = 42
|
|
42
|
+
@hash.key?('a').should be_true
|
|
43
|
+
@hash.key?('b').should be_false
|
|
44
|
+
end
|
|
45
|
+
end
|
data/spec/spec_helper.rb
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# -*- mode:ruby; coding:utf-8 -*-
|
|
2
|
+
require 'rubygems'
|
|
3
|
+
require 'bundler'
|
|
4
|
+
|
|
5
|
+
Bundler.setup
|
|
6
|
+
Bundler.require :default, :test
|
|
7
|
+
|
|
8
|
+
$:.unshift(File.expand_path( '../lib', File.dirname(__FILE__) ) )
|
|
9
|
+
|
|
10
|
+
require 'atig/monkey'
|
|
11
|
+
|
|
12
|
+
RSpec::Matchers.define :be_text do |text|
|
|
13
|
+
match do |status|
|
|
14
|
+
status.text.should == text
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def status(text,opt={})
|
|
19
|
+
Atig::TwitterStruct.make(opt.merge('text' => text))
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def user(id, name)
|
|
23
|
+
user = stub("User-#{name}")
|
|
24
|
+
user.stub!(:id).and_return(id)
|
|
25
|
+
user.stub!(:screen_name).and_return(name)
|
|
26
|
+
user
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def entry(user,status,name='entry',id=0)
|
|
30
|
+
entry = stub name
|
|
31
|
+
entry.stub!('id').and_return(id)
|
|
32
|
+
entry.stub!('user').and_return(user)
|
|
33
|
+
entry.stub!('status').and_return(status)
|
|
34
|
+
entry
|
|
35
|
+
end
|