atig 0.4.5 → 0.5.0
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.
- checksums.yaml +4 -4
- data/.rspec +1 -0
- data/.travis.yml +3 -2
- data/Gemfile +2 -0
- data/README.mkdn +2 -0
- data/Rakefile +0 -6
- data/atig.gemspec +21 -20
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/{bin → exe}/atig +0 -0
- data/lib/atig/agent/agent.rb +4 -4
- data/lib/atig/agent/dm.rb +4 -4
- data/lib/atig/agent/following.rb +3 -3
- data/lib/atig/agent/list.rb +2 -2
- data/lib/atig/agent/list_status.rb +6 -6
- data/lib/atig/agent/stream_follow.rb +2 -2
- data/lib/atig/agent/user_stream.rb +3 -3
- data/lib/atig/basic_twitter.rb +1 -3
- data/lib/atig/bitly.rb +1 -1
- data/lib/atig/channel/channel.rb +1 -1
- data/lib/atig/channel/list.rb +3 -3
- data/lib/atig/channel/retweet.rb +1 -1
- data/lib/atig/channel/timeline.rb +1 -1
- data/lib/atig/command/autofix.rb +4 -4
- data/lib/atig/command/destroy.rb +1 -1
- data/lib/atig/command/dm.rb +2 -2
- data/lib/atig/command/favorite.rb +1 -1
- data/lib/atig/command/info.rb +2 -2
- data/lib/atig/command/reply.rb +2 -2
- data/lib/atig/command/retweet.rb +2 -2
- data/lib/atig/command/search.rb +2 -2
- data/lib/atig/command/status.rb +3 -3
- data/lib/atig/command/user.rb +3 -3
- data/lib/atig/command/version.rb +3 -3
- data/lib/atig/db/followings.rb +5 -6
- data/lib/atig/db/statuses.rb +12 -10
- data/lib/atig/db/transaction.rb +1 -1
- data/lib/atig/gateway/channel.rb +1 -2
- data/lib/atig/gateway/session.rb +13 -13
- data/lib/atig/http.rb +4 -4
- data/lib/atig/ifilter/expand_url.rb +1 -1
- data/lib/atig/ifilter/retweet.rb +1 -1
- data/lib/atig/ifilter/retweet_time.rb +1 -1
- data/lib/atig/ifilter/sanitize.rb +1 -1
- data/lib/atig/ifilter/strip.rb +1 -1
- data/lib/atig/ifilter/xid.rb +1 -1
- data/lib/atig/oauth.rb +3 -3
- data/lib/atig/ofilter/escape_url.rb +1 -1
- data/lib/atig/ofilter/footer.rb +1 -1
- data/lib/atig/ofilter/geo.rb +1 -1
- data/lib/atig/ofilter/short_url.rb +1 -1
- data/lib/atig/option.rb +1 -1
- data/lib/atig/optparse.rb +22 -11
- data/lib/atig/search.rb +4 -2
- data/lib/atig/stream.rb +1 -1
- data/lib/atig/twitter.rb +5 -4
- data/lib/atig/update_checker.rb +2 -2
- data/lib/atig/url_escape.rb +1 -1
- data/lib/atig/version.rb +1 -1
- data/lib/memory_profiler.rb +1 -1
- data/spec/command/autofix_spec.rb +7 -8
- data/spec/command/destroy_spec.rb +12 -13
- data/spec/command/dm_spec.rb +5 -6
- data/spec/command/favorite_spec.rb +11 -12
- data/spec/command/limit_spec.rb +6 -7
- data/spec/command/location_spec.rb +4 -5
- data/spec/command/name_spec.rb +2 -3
- data/spec/command/option_spec.rb +28 -29
- data/spec/command/refresh_spec.rb +3 -4
- data/spec/command/reply_spec.rb +22 -23
- data/spec/command/retweet_spec.rb +17 -18
- data/spec/command/spam_spec.rb +4 -5
- data/spec/command/status_spec.rb +19 -20
- data/spec/command/thread_spec.rb +20 -21
- data/spec/command/time_spec.rb +18 -21
- data/spec/command/uptime_spec.rb +17 -18
- data/spec/command/user_info_spec.rb +13 -16
- data/spec/command/user_spec.rb +13 -14
- data/spec/command/version_spec.rb +25 -29
- data/spec/command/whois_spec.rb +25 -26
- data/spec/command_helper.rb +2 -2
- data/spec/db/followings_spec.rb +22 -23
- data/spec/db/listenable_spec.rb +2 -3
- data/spec/db/lists_spec.rb +16 -17
- data/spec/db/roman_spec.rb +3 -5
- data/spec/db/sized_uniq_array_spec.rb +13 -14
- data/spec/db/statuses_spec.rb +69 -70
- data/spec/ifilter/expand_url_spec.rb +18 -20
- data/spec/ifilter/retweet_spec.rb +4 -5
- data/spec/ifilter/retweet_time_spec.rb +4 -5
- data/spec/ifilter/sanitize_spec.rb +5 -6
- data/spec/ifilter/sid_spec.rb +6 -7
- data/spec/ifilter/strip_spec.rb +3 -4
- data/spec/ifilter/tid_spec.rb +6 -7
- data/spec/levenshtein_spec.rb +2 -3
- data/spec/ofilter/escape_url_spec.rb +13 -14
- data/spec/ofilter/footer_spec.rb +10 -11
- data/spec/ofilter/geo_spec.rb +12 -13
- data/spec/ofilter/short_url_spec.rb +28 -29
- data/spec/option_spec.rb +23 -24
- data/spec/sized_hash_spec.rb +5 -6
- data/spec/spec_helper.rb +8 -6
- data/spec/update_checker_spec.rb +14 -15
- metadata +9 -32
- 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 +0 -233
- data/docs/commandline_options.rst +0 -21
- data/docs/commands.rst +0 -84
- data/docs/conf.py +0 -194
- data/docs/config.rst +0 -159
- data/docs/feature.rst +0 -41
- data/docs/hacking_guide.rst +0 -43
- data/docs/index.rst +0 -102
- data/docs/irc.rst +0 -31
- data/docs/options.rst +0 -76
- data/docs/quickstart.rst +0 -96
- data/docs/resize.sh +0 -7
- data/docs/tiarra.rst +0 -2
- data/docs/tig.rst +0 -21
- data/requirements.txt +0 -5
data/spec/db/listenable_spec.rb
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
# -*- mode:ruby; coding:utf-8 -*-
|
|
2
2
|
|
|
3
|
-
require File.expand_path( '../../spec_helper', __FILE__ )
|
|
4
3
|
require 'atig/db/listenable'
|
|
5
4
|
|
|
6
5
|
class SampleListener
|
|
@@ -24,9 +23,9 @@ describe Atig::Db::Listenable, "when it is called" do
|
|
|
24
23
|
it "should call all listener" do
|
|
25
24
|
@listeners.hi 1,2,3
|
|
26
25
|
|
|
27
|
-
@args.length.
|
|
26
|
+
expect(@args.length).to eq(3)
|
|
28
27
|
1.upto(2) {|i|
|
|
29
|
-
@args[i].
|
|
28
|
+
expect(@args[i]).to eq([1,2,3])
|
|
30
29
|
}
|
|
31
30
|
end
|
|
32
31
|
end
|
data/spec/db/lists_spec.rb
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
# -*- mode:ruby; coding:utf-8 -*-
|
|
2
2
|
|
|
3
|
-
require File.expand_path( '../../spec_helper', __FILE__ )
|
|
4
3
|
require 'atig/db/lists'
|
|
5
4
|
|
|
6
5
|
describe Atig::Db::Lists do
|
|
7
6
|
def user(id, name, protect, only)
|
|
8
|
-
OpenStruct.new(:
|
|
7
|
+
OpenStruct.new(id: id, screen_name:name, protected:protect, only:only)
|
|
9
8
|
end
|
|
10
9
|
|
|
11
10
|
before do
|
|
@@ -29,15 +28,15 @@ describe Atig::Db::Lists do
|
|
|
29
28
|
@lists.update("a" => [ @alice, @bob ],
|
|
30
29
|
"b" => [ @alice, @bob , @charriey ])
|
|
31
30
|
|
|
32
|
-
@lists.find_by_screen_name('alice').sort.
|
|
33
|
-
@lists.find_by_screen_name('charriey').
|
|
31
|
+
expect(@lists.find_by_screen_name('alice').sort).to eq(["a", "b"])
|
|
32
|
+
expect(@lists.find_by_screen_name('charriey')).to eq(["b"])
|
|
34
33
|
end
|
|
35
34
|
|
|
36
35
|
it "should have lists" do
|
|
37
36
|
@lists.update("a" => [ @alice, @bob ],
|
|
38
37
|
"b" => [ @alice, @bob , @charriey ])
|
|
39
38
|
|
|
40
|
-
@lists.find_by_list_name('a').
|
|
39
|
+
expect(@lists.find_by_list_name('a')).to eq([ @alice, @bob ])
|
|
41
40
|
end
|
|
42
41
|
|
|
43
42
|
it "should have each" do
|
|
@@ -51,52 +50,52 @@ describe Atig::Db::Lists do
|
|
|
51
50
|
@lists.each do|name,users|
|
|
52
51
|
hash[name] = users
|
|
53
52
|
end
|
|
54
|
-
hash.
|
|
53
|
+
expect(hash).to eq(data)
|
|
55
54
|
end
|
|
56
55
|
|
|
57
56
|
it "should call listener when new list" do
|
|
58
57
|
@lists.update("a" => [ @alice, @bob ])
|
|
59
58
|
|
|
60
|
-
@args.keys.
|
|
61
|
-
@args[:new].
|
|
62
|
-
@args[:join].
|
|
59
|
+
expect(@args.keys).to include(:new, :join)
|
|
60
|
+
expect(@args[:new]).to eq([ "a" ])
|
|
61
|
+
expect(@args[:join]).to eq([ "a", [ @alice, @bob ] ])
|
|
63
62
|
end
|
|
64
63
|
|
|
65
64
|
it "should call listener when partcial update" do
|
|
66
65
|
@lists.update("a" => [ @alice ])
|
|
67
66
|
@lists["a"].update([ @alice, @bob, @charriey ])
|
|
68
|
-
@args[:join].
|
|
67
|
+
expect(@args[:join]).to eq(["a", [ @bob, @charriey ]])
|
|
69
68
|
end
|
|
70
69
|
|
|
71
70
|
it "should call on_invalidated" do
|
|
72
71
|
called = false
|
|
73
72
|
@lists.on_invalidated do|name|
|
|
74
|
-
name.
|
|
73
|
+
expect(name).to eq("a")
|
|
75
74
|
called = true
|
|
76
75
|
end
|
|
77
76
|
@lists.invalidate("a")
|
|
78
77
|
|
|
79
|
-
called.
|
|
78
|
+
expect(called).to be_truthy
|
|
80
79
|
end
|
|
81
80
|
|
|
82
81
|
it "should call listener when delete list" do
|
|
83
82
|
@lists.update("a" => [ @alice, @bob ])
|
|
84
83
|
@lists.update({})
|
|
85
|
-
@args.keys.
|
|
86
|
-
@args[:del].
|
|
84
|
+
expect(@args.keys).to include(:new, :join, :del)
|
|
85
|
+
expect(@args[:del]).to eq(["a"])
|
|
87
86
|
end
|
|
88
87
|
|
|
89
88
|
it "should call listener when join user" do
|
|
90
89
|
@lists.update("a" => [ @alice ])
|
|
91
90
|
@lists.update("a" => [ @alice, @bob, @charriey ])
|
|
92
91
|
|
|
93
|
-
@args[:join].
|
|
92
|
+
expect(@args[:join]).to eq(["a", [ @bob, @charriey ]])
|
|
94
93
|
end
|
|
95
94
|
|
|
96
95
|
it "should call listener when exit user" do
|
|
97
96
|
@lists.update("a" => [ @alice, @bob, @charriey ])
|
|
98
97
|
@lists.update("a" => [ @alice ])
|
|
99
|
-
@args[:part].
|
|
98
|
+
expect(@args[:part]).to eq(["a", [ @bob, @charriey ]])
|
|
100
99
|
end
|
|
101
100
|
|
|
102
101
|
it "should call listener when change user mode" do
|
|
@@ -104,6 +103,6 @@ describe Atig::Db::Lists do
|
|
|
104
103
|
bob = user @bob.id, 'bob', false, false
|
|
105
104
|
@lists.update("a" => [ @alice, bob ])
|
|
106
105
|
|
|
107
|
-
@args[:mode].
|
|
106
|
+
expect(@args[:mode]).to eq([ "a", [ bob ]])
|
|
108
107
|
end
|
|
109
108
|
end
|
data/spec/db/roman_spec.rb
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
# -*- mode:ruby; coding:utf-8 -*-
|
|
2
2
|
|
|
3
|
-
require File.expand_path( '../../spec_helper', __FILE__ )
|
|
4
3
|
require 'atig/db/roman'
|
|
5
4
|
|
|
6
5
|
describe Atig::Db::Roman do
|
|
@@ -9,9 +8,8 @@ describe Atig::Db::Roman do
|
|
|
9
8
|
end
|
|
10
9
|
|
|
11
10
|
it "should make readble tid" do
|
|
12
|
-
@roman.make(0).
|
|
13
|
-
@roman.make(1).
|
|
14
|
-
@roman.make(2).
|
|
11
|
+
expect(@roman.make(0)).to eq('a')
|
|
12
|
+
expect(@roman.make(1)).to eq('i')
|
|
13
|
+
expect(@roman.make(2)).to eq('u')
|
|
15
14
|
end
|
|
16
15
|
end
|
|
17
|
-
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
# -*- mode:ruby; coding:utf-8 -*-
|
|
2
2
|
|
|
3
|
-
require File.expand_path( '../../spec_helper', __FILE__ )
|
|
4
3
|
require 'atig/db/sized_uniq_array'
|
|
5
4
|
require 'ostruct'
|
|
6
5
|
|
|
7
6
|
describe Atig::Db::SizedUniqArray do
|
|
8
7
|
def item(id)
|
|
9
8
|
item = double "Item-#{id}"
|
|
10
|
-
item.
|
|
9
|
+
allow(item).to receive(:id).and_return id
|
|
11
10
|
item
|
|
12
11
|
end
|
|
13
12
|
|
|
@@ -24,40 +23,40 @@ describe Atig::Db::SizedUniqArray do
|
|
|
24
23
|
end
|
|
25
24
|
|
|
26
25
|
it "should include items" do
|
|
27
|
-
@array.to_a.
|
|
26
|
+
expect(@array.to_a).to eq([ @item1, @item2, @item3 ])
|
|
28
27
|
end
|
|
29
28
|
|
|
30
29
|
it "should rorate array" do
|
|
31
30
|
@array << @item4
|
|
32
|
-
@array.to_a.
|
|
31
|
+
expect(@array.to_a).to eq([ @item2, @item3, @item4 ])
|
|
33
32
|
end
|
|
34
33
|
|
|
35
34
|
it "should have reverse_each" do
|
|
36
35
|
xs = []
|
|
37
36
|
@array.reverse_each {|x| xs << x }
|
|
38
|
-
xs.
|
|
37
|
+
expect(xs).to eq([ @item3, @item2, @item1 ])
|
|
39
38
|
end
|
|
40
39
|
|
|
41
40
|
it "should not have duplicate element" do
|
|
42
41
|
@array << item(1)
|
|
43
|
-
@array.to_a.
|
|
42
|
+
expect(@array.to_a).to eq([ @item1, @item2, @item3 ])
|
|
44
43
|
end
|
|
45
44
|
|
|
46
45
|
it "should be accesible by index" do
|
|
47
|
-
@array[0].
|
|
48
|
-
@array[1].
|
|
49
|
-
@array[2].
|
|
46
|
+
expect(@array[0]).to eq(@item1)
|
|
47
|
+
expect(@array[1]).to eq(@item2)
|
|
48
|
+
expect(@array[2]).to eq(@item3)
|
|
50
49
|
end
|
|
51
50
|
|
|
52
51
|
it "should not change index" do
|
|
53
52
|
@array << @item4
|
|
54
|
-
@array[0].
|
|
55
|
-
@array[1].
|
|
56
|
-
@array[2].
|
|
53
|
+
expect(@array[0]).to eq(@item4)
|
|
54
|
+
expect(@array[1]).to eq(@item2)
|
|
55
|
+
expect(@array[2]).to eq(@item3)
|
|
57
56
|
end
|
|
58
57
|
|
|
59
58
|
it "should return index when add element" do
|
|
60
|
-
(@array << @item4).
|
|
61
|
-
(@array << @item3).
|
|
59
|
+
expect(@array << @item4).to eq(0)
|
|
60
|
+
expect(@array << @item3).to eq(nil)
|
|
62
61
|
end
|
|
63
62
|
end
|
data/spec/db/statuses_spec.rb
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
# -*- mode:ruby; coding:utf-8 -*-
|
|
2
2
|
|
|
3
|
-
require File.expand_path( '../../spec_helper', __FILE__ )
|
|
4
3
|
require 'fileutils'
|
|
5
4
|
require 'atig/db/statuses'
|
|
6
5
|
|
|
7
6
|
describe Atig::Db::Statuses do
|
|
8
7
|
def status(id, text, time)
|
|
9
|
-
OpenStruct.new(:
|
|
8
|
+
OpenStruct.new(id: id, text: text, created_at: time.strftime("%a %b %d %H:%M:%S +0000 %Y"))
|
|
10
9
|
end
|
|
11
10
|
|
|
12
11
|
def user(name)
|
|
13
|
-
OpenStruct.new(:
|
|
12
|
+
OpenStruct.new(screen_name: name, id: name)
|
|
14
13
|
end
|
|
15
14
|
|
|
16
15
|
before do
|
|
@@ -26,9 +25,9 @@ describe Atig::Db::Statuses do
|
|
|
26
25
|
@alice = user 'alice'
|
|
27
26
|
@bob = user 'bob'
|
|
28
27
|
|
|
29
|
-
@db.add :
|
|
30
|
-
@db.add :
|
|
31
|
-
@db.add :
|
|
28
|
+
@db.add status: @a , user: @alice, source: :srcA
|
|
29
|
+
@db.add status: @b , user: @bob , source: :srcB
|
|
30
|
+
@db.add status: @c , user: @alice, source: :srcC
|
|
32
31
|
end
|
|
33
32
|
|
|
34
33
|
after(:all) do
|
|
@@ -43,142 +42,142 @@ describe Atig::Db::Statuses do
|
|
|
43
42
|
entry = nil
|
|
44
43
|
@db.listen{|x| entry = x }
|
|
45
44
|
|
|
46
|
-
@db.add :
|
|
45
|
+
@db.add status: @d, user: @alice, source: :timeline, fuga: :hoge
|
|
47
46
|
|
|
48
|
-
entry.source.
|
|
49
|
-
entry.status.
|
|
50
|
-
entry.tid.
|
|
51
|
-
entry.sid.
|
|
52
|
-
entry.user.
|
|
53
|
-
entry.source.
|
|
54
|
-
entry.fuga.
|
|
47
|
+
expect(entry.source).to eq(:timeline)
|
|
48
|
+
expect(entry.status).to eq(@d)
|
|
49
|
+
expect(entry.tid).to match(/\w+/)
|
|
50
|
+
expect(entry.sid).to match(/\w+/)
|
|
51
|
+
expect(entry.user).to eq(@alice)
|
|
52
|
+
expect(entry.source).to eq(:timeline)
|
|
53
|
+
expect(entry.fuga).to eq(:hoge)
|
|
55
54
|
end
|
|
56
55
|
|
|
57
56
|
it "should not contain duplicate" do
|
|
58
57
|
called = false
|
|
59
58
|
@db.listen{|*_| called = true }
|
|
60
59
|
|
|
61
|
-
@db.add :
|
|
62
|
-
called.
|
|
60
|
+
@db.add status: @c, user: @bob, source: :timeline
|
|
61
|
+
expect(called).to be_falsey
|
|
63
62
|
end
|
|
64
63
|
|
|
65
64
|
it "should be found by id" do
|
|
66
65
|
entry = @db.find_by_id 1
|
|
67
|
-
entry.id.
|
|
68
|
-
entry.status.
|
|
69
|
-
entry.user .
|
|
70
|
-
entry.tid .
|
|
71
|
-
entry.sid.
|
|
66
|
+
expect(entry.id).to eq(1)
|
|
67
|
+
expect(entry.status).to eq(@a)
|
|
68
|
+
expect(entry.user) .to eq(@alice)
|
|
69
|
+
expect(entry.tid) .to match(/\w+/)
|
|
70
|
+
expect(entry.sid).to match(/\w+/)
|
|
72
71
|
end
|
|
73
72
|
|
|
74
73
|
it "should have unique tid" do
|
|
75
74
|
db = Atig::Db::Statuses.new 'test.db'
|
|
76
|
-
db.add :
|
|
75
|
+
db.add status: @d , user: @alice, source: :srcA
|
|
77
76
|
|
|
78
77
|
a = @db.find_by_id(1)
|
|
79
78
|
d = @db.find_by_id(4)
|
|
80
|
-
a.tid.
|
|
81
|
-
a.sid.
|
|
79
|
+
expect(a.tid).not_to eq(d.tid)
|
|
80
|
+
expect(a.sid).not_to eq(d.cid)
|
|
82
81
|
end
|
|
83
82
|
|
|
84
83
|
it "should be found all" do
|
|
85
84
|
db = @db.find_all
|
|
86
|
-
db.size.
|
|
85
|
+
expect(db.size).to eq(3)
|
|
87
86
|
a,b,c = db
|
|
88
87
|
|
|
89
|
-
a.status.
|
|
90
|
-
a.user .
|
|
91
|
-
a.tid .
|
|
92
|
-
a.sid .
|
|
88
|
+
expect(a.status).to eq(@c)
|
|
89
|
+
expect(a.user) .to eq(@alice)
|
|
90
|
+
expect(a.tid) .to match(/\w+/)
|
|
91
|
+
expect(a.sid) .to match(/\w+/)
|
|
93
92
|
|
|
94
|
-
b.status.
|
|
95
|
-
b.user .
|
|
96
|
-
b.tid .
|
|
97
|
-
b.sid .
|
|
93
|
+
expect(b.status).to eq(@b)
|
|
94
|
+
expect(b.user) .to eq(@bob)
|
|
95
|
+
expect(b.tid) .to match(/\w+/)
|
|
96
|
+
expect(b.sid) .to match(/\w+/)
|
|
98
97
|
|
|
99
|
-
c.status.
|
|
100
|
-
c.user.
|
|
101
|
-
c.tid.
|
|
102
|
-
c.sid.
|
|
98
|
+
expect(c.status).to eq(@a)
|
|
99
|
+
expect(c.user).to eq(@alice)
|
|
100
|
+
expect(c.tid).to match(/\w+/)
|
|
101
|
+
expect(c.sid).to match(/\w+/)
|
|
103
102
|
end
|
|
104
103
|
|
|
105
104
|
it "should be found by tid" do
|
|
106
105
|
entry = @db.find_by_id(1)
|
|
107
|
-
@db.find_by_tid(entry.tid).
|
|
106
|
+
expect(@db.find_by_tid(entry.tid)).to eq(entry)
|
|
108
107
|
end
|
|
109
108
|
|
|
110
109
|
it "should be found by sid" do
|
|
111
110
|
entry = @db.find_by_id(1)
|
|
112
|
-
@db.find_by_sid(entry.sid).
|
|
111
|
+
expect(@db.find_by_sid(entry.sid)).to eq(entry)
|
|
113
112
|
end
|
|
114
113
|
|
|
115
114
|
it "should be found by tid" do
|
|
116
|
-
@db.find_by_tid('__').
|
|
115
|
+
expect(@db.find_by_tid('__')).to be_nil
|
|
117
116
|
end
|
|
118
117
|
|
|
119
118
|
it "should be found by user" do
|
|
120
119
|
a,b = *@db.find_by_user(@alice)
|
|
121
120
|
|
|
122
|
-
a.status.
|
|
123
|
-
a.user .
|
|
124
|
-
a.tid .
|
|
125
|
-
a.sid .
|
|
121
|
+
expect(a.status).to eq(@c)
|
|
122
|
+
expect(a.user) .to eq(@alice)
|
|
123
|
+
expect(a.tid) .to match(/\w+/)
|
|
124
|
+
expect(a.sid) .to match(/\w+/)
|
|
126
125
|
|
|
127
|
-
b.status.
|
|
128
|
-
b.user.
|
|
129
|
-
b.tid.
|
|
130
|
-
b.sid.
|
|
126
|
+
expect(b.status).to eq(@a)
|
|
127
|
+
expect(b.user).to eq(@alice)
|
|
128
|
+
expect(b.tid).to match(/\w+/)
|
|
129
|
+
expect(b.sid).to match(/\w+/)
|
|
131
130
|
end
|
|
132
131
|
|
|
133
132
|
it "should be found by screen_name" do
|
|
134
133
|
db = @db.find_by_screen_name('alice')
|
|
135
|
-
db.size.
|
|
134
|
+
expect(db.size).to eq(2)
|
|
136
135
|
a,b = db
|
|
137
136
|
|
|
138
|
-
a.status.
|
|
139
|
-
a.user .
|
|
140
|
-
a.tid .
|
|
141
|
-
a.sid .
|
|
137
|
+
expect(a.status).to eq(@c)
|
|
138
|
+
expect(a.user) .to eq(@alice)
|
|
139
|
+
expect(a.tid) .to match(/\w+/)
|
|
140
|
+
expect(a.sid) .to match(/\w+/)
|
|
142
141
|
|
|
143
|
-
b.status.
|
|
144
|
-
b.user.
|
|
145
|
-
b.tid.
|
|
146
|
-
b.sid.
|
|
142
|
+
expect(b.status).to eq(@a)
|
|
143
|
+
expect(b.user).to eq(@alice)
|
|
144
|
+
expect(b.tid).to match(/\w+/)
|
|
145
|
+
expect(b.sid).to match(/\w+/)
|
|
147
146
|
end
|
|
148
147
|
|
|
149
148
|
it "should be found by screen_name with limit" do
|
|
150
|
-
xs = @db.find_by_screen_name('alice', :
|
|
151
|
-
xs.size.
|
|
149
|
+
xs = @db.find_by_screen_name('alice', limit: 1)
|
|
150
|
+
expect(xs.size).to eq(1)
|
|
152
151
|
|
|
153
152
|
a,_ = xs
|
|
154
|
-
a.status.
|
|
155
|
-
a.user .
|
|
156
|
-
a.tid .
|
|
157
|
-
a.sid .
|
|
153
|
+
expect(a.status).to eq(@c)
|
|
154
|
+
expect(a.user) .to eq(@alice)
|
|
155
|
+
expect(a.tid) .to match(/\w+/)
|
|
156
|
+
expect(a.sid) .to match(/\w+/)
|
|
158
157
|
end
|
|
159
158
|
|
|
160
159
|
it "should remove by id" do
|
|
161
160
|
@db.remove_by_id 1
|
|
162
|
-
@db.find_by_id(1).
|
|
161
|
+
expect(@db.find_by_id(1)).to be_nil
|
|
163
162
|
end
|
|
164
163
|
|
|
165
164
|
it "should have uniq tid/sid when removed" do
|
|
166
165
|
old = @db.find_by_id 3
|
|
167
166
|
@db.remove_by_id 3
|
|
168
|
-
@db.add :
|
|
167
|
+
@db.add status: @c , user: @alice, source: :src
|
|
169
168
|
new = @db.find_by_id 3
|
|
170
169
|
|
|
171
|
-
old.tid.
|
|
172
|
-
old.sid.
|
|
170
|
+
expect(old.tid).not_to eq(new.tid)
|
|
171
|
+
expect(old.sid).not_to eq(new.sid)
|
|
173
172
|
end
|
|
174
173
|
|
|
175
174
|
it "should cleanup" do
|
|
176
|
-
Atig::Db::Statuses::Size = 10 unless defined? Atig::Db::Statuses::Size # hack
|
|
175
|
+
Atig::Db::Statuses::Size = 10 unless defined? Atig::Db::Statuses::Size # hack
|
|
177
176
|
Atig::Db::Statuses::Size.times do|i|
|
|
178
177
|
s = status i+100, 'a', Time.utc(2010,1,5)+i+1
|
|
179
|
-
@db.add :
|
|
178
|
+
@db.add status: s , user: @alice , source: :srcB
|
|
180
179
|
end
|
|
181
180
|
@db.cleanup
|
|
182
|
-
@db.find_by_status_id(@a.id).
|
|
181
|
+
expect(@db.find_by_status_id(@a.id)).to eq(nil)
|
|
183
182
|
end
|
|
184
183
|
end
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
# -*- mode:ruby; coding:utf-8 -*-
|
|
2
2
|
|
|
3
|
-
require File.expand_path( '../../spec_helper', __FILE__ )
|
|
4
3
|
require 'atig/ifilter/expand_url'
|
|
5
4
|
require 'atig/twitter_struct'
|
|
6
5
|
|
|
@@ -10,57 +9,57 @@ end
|
|
|
10
9
|
|
|
11
10
|
describe Atig::IFilter::ExpandUrl, "when disable whole url" do
|
|
12
11
|
def filtered(text)
|
|
13
|
-
ifilter = Atig::IFilter::ExpandUrl.new OpenStruct.new(:
|
|
12
|
+
ifilter = Atig::IFilter::ExpandUrl.new OpenStruct.new(log:double('log'),:opts=>OpenStruct.new)
|
|
14
13
|
ifilter.call status(text)
|
|
15
14
|
end
|
|
16
15
|
|
|
17
16
|
it "should expand bit.ly" do
|
|
18
|
-
filtered("This is http://bit.ly/hoge").
|
|
19
|
-
filtered("This is http://bitly.com/hoge").
|
|
17
|
+
expect(filtered("This is http://bit.ly/hoge")).to be_text("This is [http://bit.ly/hoge]")
|
|
18
|
+
expect(filtered("This is http://bitly.com/hoge")).to be_text("This is [http://bitly.com/hoge]")
|
|
20
19
|
end
|
|
21
20
|
|
|
22
21
|
it "should expand htn.to" do
|
|
23
|
-
filtered("This is http://htn.to/TZdkXg").
|
|
24
|
-
filtered("This is http://htnnto/TZdkXg").
|
|
22
|
+
expect(filtered("This is http://htn.to/TZdkXg")).to be_text("This is [http://htn.to/TZdkXg]")
|
|
23
|
+
expect(filtered("This is http://htnnto/TZdkXg")).to be_text("This is http://htnnto/TZdkXg")
|
|
25
24
|
end
|
|
26
25
|
|
|
27
26
|
it "should expand tmblr.co" do
|
|
28
|
-
filtered("This is http://tmblr.co/Z0rNbyxhxUK5").
|
|
27
|
+
expect(filtered("This is http://tmblr.co/Z0rNbyxhxUK5")).to be_text("This is [http://tmblr.co/Z0rNbyxhxUK5]")
|
|
29
28
|
end
|
|
30
29
|
|
|
31
30
|
it "should expand nico.ms" do
|
|
32
|
-
filtered("This is http://nico.ms/sm11870888").
|
|
31
|
+
expect(filtered("This is http://nico.ms/sm11870888")).to be_text("This is [http://nico.ms/sm11870888]")
|
|
33
32
|
end
|
|
34
33
|
|
|
35
34
|
it "should through other url" do
|
|
36
|
-
filtered("http://example.com").
|
|
35
|
+
expect(filtered("http://example.com")).to be_text("http://example.com")
|
|
37
36
|
end
|
|
38
37
|
end
|
|
39
38
|
|
|
40
39
|
describe Atig::IFilter::ExpandUrl, "when enable whole url" do
|
|
41
40
|
def filtered(text)
|
|
42
41
|
context = OpenStruct.new(
|
|
43
|
-
:
|
|
44
|
-
:
|
|
42
|
+
log: double('log'),
|
|
43
|
+
opts: OpenStruct.new(untiny_whole_urls:true))
|
|
45
44
|
ifilter = Atig::IFilter::ExpandUrl.new(context)
|
|
46
45
|
ifilter.call status(text)
|
|
47
46
|
end
|
|
48
47
|
|
|
49
48
|
it "should expand bit.ly" do
|
|
50
|
-
filtered("This is http://bit.ly/hoge").
|
|
49
|
+
expect(filtered("This is http://bit.ly/hoge")).to be_text("This is [http://bit.ly/hoge]")
|
|
51
50
|
end
|
|
52
51
|
|
|
53
52
|
it "should expand other url" do
|
|
54
|
-
filtered("http://example.com").
|
|
55
|
-
filtered("https://example.com").
|
|
53
|
+
expect(filtered("http://example.com")).to be_text("[http://example.com]")
|
|
54
|
+
expect(filtered("https://example.com")).to be_text("[https://example.com]")
|
|
56
55
|
end
|
|
57
56
|
end
|
|
58
57
|
|
|
59
58
|
describe Atig::IFilter::ExpandUrl, "when has urls entities" do
|
|
60
59
|
def filtered(text, opts)
|
|
61
60
|
context = OpenStruct.new(
|
|
62
|
-
:
|
|
63
|
-
:
|
|
61
|
+
log: double('log'),
|
|
62
|
+
opts: OpenStruct.new)
|
|
64
63
|
ifilter = Atig::IFilter::ExpandUrl.new(context)
|
|
65
64
|
ifilter.call status(text, opts)
|
|
66
65
|
end
|
|
@@ -77,9 +76,8 @@ describe Atig::IFilter::ExpandUrl, "when has urls entities" do
|
|
|
77
76
|
}]
|
|
78
77
|
}
|
|
79
78
|
}
|
|
80
|
-
filtered("http://t.co/1Vyoux4kB8", opts).
|
|
81
|
-
filtered("http://t.co/1Vyoux4kB8 http://t.co/V1441ye6g2", opts).
|
|
82
|
-
be_text("http://example.com/ http://expmaple.org/")
|
|
79
|
+
expect(filtered("http://t.co/1Vyoux4kB8", opts)).to be_text("http://example.com/")
|
|
80
|
+
expect(filtered("http://t.co/1Vyoux4kB8 http://t.co/V1441ye6g2", opts)).to be_text("http://example.com/ http://example.org/")
|
|
83
81
|
end
|
|
84
82
|
|
|
85
83
|
it "should expand recursive shorten URL" do
|
|
@@ -91,6 +89,6 @@ describe Atig::IFilter::ExpandUrl, "when has urls entities" do
|
|
|
91
89
|
}]
|
|
92
90
|
}
|
|
93
91
|
}
|
|
94
|
-
filtered("http://t.co/h8sqL5ZMuz", opts).
|
|
92
|
+
expect(filtered("http://t.co/h8sqL5ZMuz", opts)).to be_text("[http://bit.ly/1LM4fW]")
|
|
95
93
|
end
|
|
96
94
|
end
|