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.
Files changed (171) hide show
  1. data/.gitignore +24 -0
  2. data/Gemfile +3 -0
  3. data/README.mkdn +52 -0
  4. data/Rakefile +15 -0
  5. data/atig.gemspec +25 -0
  6. data/bin/atig +74 -0
  7. data/docs/OMakefile +32 -0
  8. data/docs/OMakeroot +45 -0
  9. data/docs/_static/allow.png +0 -0
  10. data/docs/_static/emacs.png +0 -0
  11. data/docs/_static/irc_setting.png +0 -0
  12. data/docs/_static/irssi.png +0 -0
  13. data/docs/_static/limechat.png +0 -0
  14. data/docs/_static/limechat_s.png +0 -0
  15. data/docs/_static/oauth_channel.png +0 -0
  16. data/docs/_static/screenshot.png +0 -0
  17. data/docs/_static/structure.png +0 -0
  18. data/docs/_static/verify.png +0 -0
  19. data/docs/changelog.rst +96 -0
  20. data/docs/commandline_options.rst +21 -0
  21. data/docs/commands.rst +84 -0
  22. data/docs/conf.py +194 -0
  23. data/docs/config.rst +159 -0
  24. data/docs/feature.rst +41 -0
  25. data/docs/graphics.graffle +1995 -0
  26. data/docs/hacking_guide.rst +43 -0
  27. data/docs/index.rst +109 -0
  28. data/docs/irc.rst +31 -0
  29. data/docs/options.rst +75 -0
  30. data/docs/quickstart.rst +89 -0
  31. data/docs/resize.sh +7 -0
  32. data/docs/tiarra.rst +2 -0
  33. data/docs/tig.rst +21 -0
  34. data/lib/atig.rb +19 -0
  35. data/lib/atig/agent.rb +8 -0
  36. data/lib/atig/agent/agent.rb +38 -0
  37. data/lib/atig/agent/clenup.rb +23 -0
  38. data/lib/atig/agent/dm.rb +35 -0
  39. data/lib/atig/agent/following.rb +45 -0
  40. data/lib/atig/agent/full_list.rb +20 -0
  41. data/lib/atig/agent/list.rb +55 -0
  42. data/lib/atig/agent/list_status.rb +46 -0
  43. data/lib/atig/agent/mention.rb +13 -0
  44. data/lib/atig/agent/other_list.rb +18 -0
  45. data/lib/atig/agent/own_list.rb +18 -0
  46. data/lib/atig/agent/stream_follow.rb +38 -0
  47. data/lib/atig/agent/timeline.rb +13 -0
  48. data/lib/atig/agent/user_stream.rb +31 -0
  49. data/lib/atig/basic_twitter.rb +116 -0
  50. data/lib/atig/bitly.rb +52 -0
  51. data/lib/atig/channel.rb +5 -0
  52. data/lib/atig/channel/channel.rb +17 -0
  53. data/lib/atig/channel/dm.rb +14 -0
  54. data/lib/atig/channel/list.rb +76 -0
  55. data/lib/atig/channel/mention.rb +20 -0
  56. data/lib/atig/channel/retweet.rb +28 -0
  57. data/lib/atig/channel/timeline.rb +74 -0
  58. data/lib/atig/command.rb +21 -0
  59. data/lib/atig/command/autofix.rb +58 -0
  60. data/lib/atig/command/command.rb +24 -0
  61. data/lib/atig/command/command_helper.rb +95 -0
  62. data/lib/atig/command/destroy.rb +44 -0
  63. data/lib/atig/command/dm.rb +31 -0
  64. data/lib/atig/command/favorite.rb +27 -0
  65. data/lib/atig/command/info.rb +50 -0
  66. data/lib/atig/command/limit.rb +15 -0
  67. data/lib/atig/command/location.rb +23 -0
  68. data/lib/atig/command/name.rb +18 -0
  69. data/lib/atig/command/option.rb +37 -0
  70. data/lib/atig/command/refresh.rb +18 -0
  71. data/lib/atig/command/reply.rb +37 -0
  72. data/lib/atig/command/retweet.rb +63 -0
  73. data/lib/atig/command/search.rb +51 -0
  74. data/lib/atig/command/spam.rb +26 -0
  75. data/lib/atig/command/status.rb +41 -0
  76. data/lib/atig/command/thread.rb +44 -0
  77. data/lib/atig/command/time.rb +32 -0
  78. data/lib/atig/command/uptime.rb +32 -0
  79. data/lib/atig/command/user.rb +42 -0
  80. data/lib/atig/command/user_info.rb +27 -0
  81. data/lib/atig/command/version.rb +49 -0
  82. data/lib/atig/command/whois.rb +39 -0
  83. data/lib/atig/db/db.rb +60 -0
  84. data/lib/atig/db/followings.rb +131 -0
  85. data/lib/atig/db/listenable.rb +22 -0
  86. data/lib/atig/db/lists.rb +76 -0
  87. data/lib/atig/db/roman.rb +30 -0
  88. data/lib/atig/db/sized_uniq_array.rb +62 -0
  89. data/lib/atig/db/sql.rb +35 -0
  90. data/lib/atig/db/statuses.rb +147 -0
  91. data/lib/atig/db/transaction.rb +47 -0
  92. data/lib/atig/exception_util.rb +26 -0
  93. data/lib/atig/gateway.rb +62 -0
  94. data/lib/atig/gateway/channel.rb +99 -0
  95. data/lib/atig/gateway/session.rb +326 -0
  96. data/lib/atig/http.rb +95 -0
  97. data/lib/atig/ifilter.rb +7 -0
  98. data/lib/atig/ifilter/expand_url.rb +74 -0
  99. data/lib/atig/ifilter/retweet.rb +14 -0
  100. data/lib/atig/ifilter/retweet_time.rb +16 -0
  101. data/lib/atig/ifilter/sanitize.rb +18 -0
  102. data/lib/atig/ifilter/strip.rb +15 -0
  103. data/lib/atig/ifilter/utf7.rb +26 -0
  104. data/lib/atig/ifilter/xid.rb +36 -0
  105. data/lib/atig/levenshtein.rb +49 -0
  106. data/lib/atig/monkey.rb +4 -0
  107. data/lib/atig/oauth-patch.rb +40 -0
  108. data/lib/atig/oauth.rb +55 -0
  109. data/lib/atig/ofilter.rb +4 -0
  110. data/lib/atig/ofilter/escape_url.rb +102 -0
  111. data/lib/atig/ofilter/footer.rb +20 -0
  112. data/lib/atig/ofilter/geo.rb +17 -0
  113. data/lib/atig/ofilter/short_url.rb +47 -0
  114. data/lib/atig/option.rb +90 -0
  115. data/lib/atig/scheduler.rb +79 -0
  116. data/lib/atig/search.rb +22 -0
  117. data/lib/atig/search_twitter.rb +21 -0
  118. data/lib/atig/sized_hash.rb +33 -0
  119. data/lib/atig/stream.rb +66 -0
  120. data/lib/atig/twitter.rb +79 -0
  121. data/lib/atig/twitter_struct.rb +63 -0
  122. data/lib/atig/unu.rb +27 -0
  123. data/lib/atig/update_checker.rb +53 -0
  124. data/lib/atig/url_escape.rb +62 -0
  125. data/lib/atig/util.rb +16 -0
  126. data/lib/atig/version.rb +3 -0
  127. data/lib/memory_profiler.rb +77 -0
  128. data/spec/command/autofix_spec.rb +35 -0
  129. data/spec/command/destroy_spec.rb +98 -0
  130. data/spec/command/dm_spec.rb +28 -0
  131. data/spec/command/favorite_spec.rb +55 -0
  132. data/spec/command/limit_spec.rb +27 -0
  133. data/spec/command/location_spec.rb +25 -0
  134. data/spec/command/name_spec.rb +19 -0
  135. data/spec/command/option_spec.rb +133 -0
  136. data/spec/command/refresh_spec.rb +22 -0
  137. data/spec/command/reply_spec.rb +79 -0
  138. data/spec/command/retweet_spec.rb +66 -0
  139. data/spec/command/spam_spec.rb +27 -0
  140. data/spec/command/status_spec.rb +44 -0
  141. data/spec/command/thread_spec.rb +91 -0
  142. data/spec/command/time_spec.rb +52 -0
  143. data/spec/command/uptime_spec.rb +55 -0
  144. data/spec/command/user_info_spec.rb +42 -0
  145. data/spec/command/user_spec.rb +50 -0
  146. data/spec/command/version_spec.rb +67 -0
  147. data/spec/command/whois_spec.rb +78 -0
  148. data/spec/db/followings_spec.rb +100 -0
  149. data/spec/db/listenable_spec.rb +32 -0
  150. data/spec/db/lists_spec.rb +104 -0
  151. data/spec/db/roman_spec.rb +17 -0
  152. data/spec/db/sized_uniq_array_spec.rb +63 -0
  153. data/spec/db/statuses_spec.rb +180 -0
  154. data/spec/ifilter/expand_url_spec.rb +44 -0
  155. data/spec/ifilter/retweet_spec.rb +28 -0
  156. data/spec/ifilter/retweet_time_spec.rb +25 -0
  157. data/spec/ifilter/sanitize_spec.rb +25 -0
  158. data/spec/ifilter/sid_spec.rb +29 -0
  159. data/spec/ifilter/strip_spec.rb +23 -0
  160. data/spec/ifilter/tid_spec.rb +29 -0
  161. data/spec/ifilter/utf7_spec.rb +30 -0
  162. data/spec/levenshtein_spec.rb +24 -0
  163. data/spec/ofilter/escape_url_spec.rb +50 -0
  164. data/spec/ofilter/footer_spec.rb +32 -0
  165. data/spec/ofilter/geo_spec.rb +33 -0
  166. data/spec/ofilter/short_url_spec.rb +127 -0
  167. data/spec/option_spec.rb +91 -0
  168. data/spec/sized_hash_spec.rb +45 -0
  169. data/spec/spec_helper.rb +35 -0
  170. data/spec/update_checker_spec.rb +55 -0
  171. metadata +326 -0
@@ -0,0 +1,63 @@
1
+ # -*- mode:ruby; coding:utf-8 -*-
2
+
3
+ require File.expand_path( '../../spec_helper', __FILE__ )
4
+ require 'atig/db/sized_uniq_array'
5
+ require 'ostruct'
6
+
7
+ describe Atig::Db::SizedUniqArray do
8
+ def item(id)
9
+ item = stub "Item-#{id}"
10
+ item.stub!(:id).and_return id
11
+ item
12
+ end
13
+
14
+ before do
15
+ @array = Atig::Db::SizedUniqArray.new 3
16
+ @item1 = item 1
17
+ @item2 = item 2
18
+ @item3 = item 3
19
+ @item4 = item 4
20
+
21
+ @array << @item1
22
+ @array << @item2
23
+ @array << @item3
24
+ end
25
+
26
+ it "should include items" do
27
+ @array.to_a.should == [ @item1, @item2, @item3 ]
28
+ end
29
+
30
+ it "should rorate array" do
31
+ @array << @item4
32
+ @array.to_a.should == [ @item2, @item3, @item4 ]
33
+ end
34
+
35
+ it "should have reverse_each" do
36
+ xs = []
37
+ @array.reverse_each {|x| xs << x }
38
+ xs.should == [ @item3, @item2, @item1 ]
39
+ end
40
+
41
+ it "should not have duplicate element" do
42
+ @array << item(1)
43
+ @array.to_a.should == [ @item1, @item2, @item3 ]
44
+ end
45
+
46
+ it "should be accesible by index" do
47
+ @array[0].should == @item1
48
+ @array[1].should == @item2
49
+ @array[2].should == @item3
50
+ end
51
+
52
+ it "should not change index" do
53
+ @array << @item4
54
+ @array[0].should == @item4
55
+ @array[1].should == @item2
56
+ @array[2].should == @item3
57
+ end
58
+
59
+ it "should return index when add element" do
60
+ (@array << @item4).should == 0
61
+ (@array << @item3).should == nil
62
+ end
63
+ end
@@ -0,0 +1,180 @@
1
+ # -*- mode:ruby; coding:utf-8 -*-
2
+
3
+ require File.expand_path( '../../spec_helper', __FILE__ )
4
+ require 'fileutils'
5
+ require 'atig/db/statuses'
6
+
7
+ describe Atig::Db::Statuses do
8
+ def status(id, text, time)
9
+ OpenStruct.new(:id => id, :text => text, :created_at => time.strftime("%a %b %d %H:%M:%S +0000 %Y"))
10
+ end
11
+
12
+ def user(name)
13
+ OpenStruct.new(:screen_name => name, :id => name)
14
+ end
15
+
16
+ before do
17
+ @listened = []
18
+ FileUtils.rm_f 'test.db'
19
+ @db = Atig::Db::Statuses.new 'test.db'
20
+
21
+ @a = status 10, 'a', Time.utc(2010,1,5)
22
+ @b = status 20, 'b', Time.utc(2010,1,6)
23
+ @c = status 30, 'c', Time.utc(2010,1,7)
24
+ @d = status 40, 'd', Time.utc(2010,1,8)
25
+
26
+ @alice = user 'alice'
27
+ @bob = user 'bob'
28
+
29
+ @db.add :status => @a , :user => @alice, :source => :srcA
30
+ @db.add :status => @b , :user => @bob , :source => :srcB
31
+ @db.add :status => @c , :user => @alice, :source => :srcC
32
+ end
33
+
34
+ it "should be re-openable" do
35
+ Atig::Db::Statuses.new 'test.db'
36
+ end
37
+
38
+ it "should call listeners" do
39
+ entry = nil
40
+ @db.listen{|x| entry = x }
41
+
42
+ @db.add :status => @d, :user => @alice, :source => :timeline, :fuga => :hoge
43
+
44
+ entry.source.should == :timeline
45
+ entry.status.should == @d
46
+ entry.tid.should match(/\w+/)
47
+ entry.sid.should match(/\w+/)
48
+ entry.user.should == @alice
49
+ entry.source.should == :timeline
50
+ entry.fuga.should == :hoge
51
+ end
52
+
53
+ it "should not contain duplicate" do
54
+ called = false
55
+ @db.listen{|*_| called = true }
56
+
57
+ @db.add :status => @c, :user => @bob, :source => :timeline
58
+ called.should be_false
59
+ end
60
+
61
+ it "should be found by id" do
62
+ entry = @db.find_by_id 1
63
+ entry.id.should == 1
64
+ entry.status.should == @a
65
+ entry.user .should == @alice
66
+ entry.tid .should match(/\w+/)
67
+ entry.sid.should match(/\w+/)
68
+ end
69
+
70
+ it "should have unique tid" do
71
+ db = Atig::Db::Statuses.new 'test.db'
72
+ db.add :status => @d , :user => @alice, :source => :srcA
73
+
74
+ a = @db.find_by_id(1)
75
+ d = @db.find_by_id(4)
76
+ a.tid.should_not == d.tid
77
+ a.sid.should_not == d.cid
78
+ end
79
+
80
+ it "should be found all" do
81
+ db = @db.find_all
82
+ db.size.should == 3
83
+ a,b,c = db
84
+
85
+ a.status.should == @c
86
+ a.user .should == @alice
87
+ a.tid .should match(/\w+/)
88
+ a.sid .should match(/\w+/)
89
+
90
+ b.status.should == @b
91
+ b.user .should == @bob
92
+ b.tid .should match(/\w+/)
93
+ b.sid .should match(/\w+/)
94
+
95
+ c.status.should == @a
96
+ c.user.should == @alice
97
+ c.tid.should match(/\w+/)
98
+ c.sid.should match(/\w+/)
99
+ end
100
+
101
+ it "should be found by tid" do
102
+ entry = @db.find_by_id(1)
103
+ @db.find_by_tid(entry.tid).should == entry
104
+ end
105
+
106
+ it "should be found by sid" do
107
+ entry = @db.find_by_id(1)
108
+ @db.find_by_sid(entry.sid).should == entry
109
+ end
110
+
111
+ it "should be found by tid" do
112
+ @db.find_by_tid('__').should be_nil
113
+ end
114
+
115
+ it "should be found by user" do
116
+ a,b = *@db.find_by_user(@alice)
117
+
118
+ a.status.should == @c
119
+ a.user .should == @alice
120
+ a.tid .should match(/\w+/)
121
+ a.sid .should match(/\w+/)
122
+
123
+ b.status.should == @a
124
+ b.user.should == @alice
125
+ b.tid.should match(/\w+/)
126
+ b.sid.should match(/\w+/)
127
+ end
128
+
129
+ it "should be found by screen_name" do
130
+ db = @db.find_by_screen_name('alice')
131
+ db.size.should == 2
132
+ a,b = db
133
+
134
+ a.status.should == @c
135
+ a.user .should == @alice
136
+ a.tid .should match(/\w+/)
137
+ a.sid .should match(/\w+/)
138
+
139
+ b.status.should == @a
140
+ b.user.should == @alice
141
+ b.tid.should match(/\w+/)
142
+ b.sid.should match(/\w+/)
143
+ end
144
+
145
+ it "should be found by screen_name with limit" do
146
+ xs = @db.find_by_screen_name('alice', :limit => 1)
147
+ xs.size.should == 1
148
+
149
+ a,_ = xs
150
+ a.status.should == @c
151
+ a.user .should == @alice
152
+ a.tid .should match(/\w+/)
153
+ a.sid .should match(/\w+/)
154
+ end
155
+
156
+ it "should remove by id" do
157
+ @db.remove_by_id 1
158
+ @db.find_by_id(1).should be_nil
159
+ end
160
+
161
+ it "should have uniq tid/sid when removed" do
162
+ old = @db.find_by_id 3
163
+ @db.remove_by_id 3
164
+ @db.add :status => @c , :user => @alice, :source => :src
165
+ new = @db.find_by_id 3
166
+
167
+ old.tid.should_not == new.tid
168
+ old.sid.should_not == new.sid
169
+ end
170
+
171
+ it "should cleanup" do
172
+ Atig::Db::Statuses::Size = 10 unless defined? Atig::Db::Statuses::Size # hack
173
+ Atig::Db::Statuses::Size.times do|i|
174
+ s = status i+100, 'a', Time.utc(2010,1,5)+i+1
175
+ @db.add :status => s , :user => @alice , :source => :srcB
176
+ end
177
+ @db.cleanup
178
+ @db.find_by_status_id(@a.id).should == nil
179
+ end
180
+ end
@@ -0,0 +1,44 @@
1
+ # -*- mode:ruby; coding:utf-8 -*-
2
+
3
+ require File.expand_path( '../../spec_helper', __FILE__ )
4
+ require 'atig/ifilter/expand_url'
5
+ require 'atig/twitter_struct'
6
+
7
+ class Atig::IFilter::ExpandUrl
8
+ def resolve_http_redirect(uri); "[#{uri}]" end
9
+ end
10
+
11
+ describe Atig::IFilter::ExpandUrl, "when disable whole url" do
12
+ def filtered(text)
13
+ ifilter = Atig::IFilter::ExpandUrl.new OpenStruct.new(:log=>mock('log'),:opts=>OpenStruct.new)
14
+ ifilter.call status(text)
15
+ end
16
+
17
+ it "should expand bit.ly" do
18
+ filtered("This is http://bit.ly/hoge").should be_text("This is [http://bit.ly/hoge]")
19
+ end
20
+
21
+ it "should through other url" do
22
+ filtered("http://example.com").should be_text("http://example.com")
23
+ end
24
+ end
25
+
26
+ describe Atig::IFilter::ExpandUrl, "when enable whole url" do
27
+ def filtered(text)
28
+ context = OpenStruct.new(
29
+ :log => mock('log'),
30
+ :opts => OpenStruct.new(:untiny_whole_urls=>true))
31
+ ifilter = Atig::IFilter::ExpandUrl.new(context)
32
+ ifilter.call status(text)
33
+ end
34
+
35
+ it "should expand bit.ly" do
36
+ filtered("This is http://bit.ly/hoge").should be_text("This is [http://bit.ly/hoge]")
37
+ end
38
+
39
+ it "should expand other url" do
40
+ filtered("http://example.com").should be_text("[http://example.com]")
41
+ filtered("https://example.com").should be_text("[https://example.com]")
42
+ end
43
+ end
44
+
@@ -0,0 +1,28 @@
1
+ # -*- mode:ruby; coding:utf-8 -*-
2
+
3
+ require File.expand_path( '../../spec_helper', __FILE__ )
4
+ require 'atig/ifilter/retweet'
5
+ require 'atig/twitter_struct'
6
+
7
+ describe Atig::IFilter::Retweet do
8
+ def filtered(text, opt={})
9
+ Atig::IFilter::Retweet.call status(text, opt)
10
+ end
11
+
12
+ before do
13
+ @rt = Atig::IFilter::Retweet::Prefix
14
+ end
15
+
16
+ it "should throw normal status" do
17
+ filtered("hello").should be_text("hello")
18
+ end
19
+
20
+ it "should prefix RT for Retweet" do
21
+ filtered("RT: hello...",
22
+ 'retweeted_status'=>{ 'text' => 'hello',
23
+ 'user' => {
24
+ 'screen_name' => 'mzp'
25
+ } }).
26
+ should be_text("#{@rt}RT @mzp: hello")
27
+ end
28
+ end
@@ -0,0 +1,25 @@
1
+ # -*- mode:ruby; coding:utf-8 -*-
2
+
3
+ require File.expand_path( '../../spec_helper', __FILE__ )
4
+ require 'atig/ifilter/retweet_time'
5
+ require 'atig/twitter_struct'
6
+
7
+ describe Atig::IFilter::RetweetTime do
8
+ def filtered(text, opt={})
9
+ Atig::IFilter::RetweetTime.call status(text, opt)
10
+ end
11
+
12
+ it "should throw normal status" do
13
+ filtered("hello").should be_text("hello")
14
+ end
15
+
16
+ it "should prefix RT for Retweet" do
17
+ filtered("RT @mzp: hello",
18
+ 'retweeted_status'=>{ 'text' => 'hello',
19
+ 'created_at' => 'Sat Sep 25 14:33:19 +0000 2010',
20
+ 'user' => {
21
+ 'screen_name' => 'mzp'
22
+ } }).
23
+ should be_text("#{@rt}RT @mzp: hello \x0310[2010-09-25 23:33]\x0F")
24
+ end
25
+ end
@@ -0,0 +1,25 @@
1
+ # -*- mode:ruby; coding:utf-8 -*-
2
+
3
+ require File.expand_path( '../../spec_helper', __FILE__ )
4
+ require 'atig/ifilter/sanitize'
5
+ require 'atig/twitter_struct'
6
+
7
+ describe Atig::IFilter::Sanitize do
8
+ def filtered(text)
9
+ Atig::IFilter::Sanitize.call status(text)
10
+ end
11
+
12
+ it "should convert escape html" do
13
+ filtered("&lt; &gt; &quot;").should be_text("< > \"")
14
+ end
15
+
16
+ it "should convert whitespace" do
17
+ filtered("\r\n").should be_text(" ")
18
+ filtered("\r").should be_text(" ")
19
+ filtered("\n").should be_text(" ")
20
+ end
21
+
22
+ it "should delete \\000\\001 sequence" do
23
+ filtered("\000\001").should be_text("")
24
+ end
25
+ end
@@ -0,0 +1,29 @@
1
+ # -*- mode:ruby; coding:utf-8 -*-
2
+
3
+ require File.expand_path( '../../spec_helper', __FILE__ )
4
+ require 'atig/ifilter/xid'
5
+ require 'atig/twitter_struct'
6
+
7
+ describe Atig::IFilter::Sid, "when disable tid" do
8
+ def filtered(text)
9
+ ifilter = Atig::IFilter::Sid.new(OpenStruct.new(:log=>mock('log'),
10
+ :opts=>OpenStruct.new))
11
+ ifilter.call status(text,'sid'=>1)
12
+ end
13
+
14
+ it "should through text" do
15
+ filtered("hello").should be_text("hello")
16
+ end
17
+ end
18
+
19
+ describe Atig::IFilter::Sid, "when enable tid" do
20
+ def filtered(text)
21
+ ifilter = Atig::IFilter::Sid.new(OpenStruct.new(:log=>mock('log'),
22
+ :opts=>OpenStruct.new(:sid=>true)))
23
+ ifilter.call status(text,'sid'=>1)
24
+ end
25
+
26
+ it "should append sid" do
27
+ filtered("hello").should be_text("hello \x0310[1]\x0F")
28
+ end
29
+ end
@@ -0,0 +1,23 @@
1
+ # -*- mode:ruby; coding:utf-8 -*-
2
+
3
+ require File.expand_path( '../../spec_helper', __FILE__ )
4
+ require 'atig/ifilter/strip'
5
+ require 'atig/twitter_struct'
6
+
7
+ describe Atig::IFilter::Strip do
8
+ before do
9
+ @ifilter = Atig::IFilter::Strip.new %w(*tw* _)
10
+ end
11
+
12
+ it "should strip *tw*" do
13
+ @ifilter.call(status("hoge *tw*")).should be_text("hoge")
14
+ end
15
+
16
+ it "should strip _" do
17
+ @ifilter.call(status("hoge _")).should be_text("hoge")
18
+ end
19
+
20
+ it "should strip white-space" do
21
+ @ifilter.call(status(" hoge ")).should be_text("hoge")
22
+ end
23
+ end
@@ -0,0 +1,29 @@
1
+ # -*- mode:ruby; coding:utf-8 -*-
2
+
3
+ require File.expand_path( '../../spec_helper', __FILE__ )
4
+ require 'atig/ifilter/xid'
5
+ require 'atig/twitter_struct'
6
+
7
+ describe Atig::IFilter::Tid, "when disable tid" do
8
+ def filtered(text)
9
+ ifilter = Atig::IFilter::Tid.new(OpenStruct.new(:log=>mock('log'),
10
+ :opts=>OpenStruct.new))
11
+ ifilter.call status(text,'tid'=>1)
12
+ end
13
+
14
+ it "should through text" do
15
+ filtered("hello").should be_text("hello")
16
+ end
17
+ end
18
+
19
+ describe Atig::IFilter::Tid, "when enable tid" do
20
+ def filtered(text)
21
+ ifilter = Atig::IFilter::Tid.new(OpenStruct.new(:log=>mock('log'),
22
+ :opts=>OpenStruct.new(:tid=>true)))
23
+ ifilter.call status(text,'tid'=>1)
24
+ end
25
+
26
+ it "should append tid" do
27
+ filtered("hello").should be_text("hello \x0310[1]\x0F")
28
+ end
29
+ end