atig 0.4.5 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -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/retweet'
|
5
4
|
require 'atig/twitter_struct'
|
6
5
|
|
@@ -14,15 +13,15 @@ describe Atig::IFilter::Retweet do
|
|
14
13
|
end
|
15
14
|
|
16
15
|
it "should throw normal status" do
|
17
|
-
filtered("hello").
|
16
|
+
expect(filtered("hello")).to be_text("hello")
|
18
17
|
end
|
19
18
|
|
20
19
|
it "should prefix RT for Retweet" do
|
21
|
-
filtered("RT: hello...",
|
20
|
+
expect(filtered("RT: hello...",
|
22
21
|
'retweeted_status'=>{ 'text' => 'hello',
|
23
22
|
'user' => {
|
24
23
|
'screen_name' => 'mzp'
|
25
|
-
} }).
|
26
|
-
|
24
|
+
} })).
|
25
|
+
to be_text("#{@rt}RT @mzp: hello")
|
27
26
|
end
|
28
27
|
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/retweet_time'
|
5
4
|
require 'atig/twitter_struct'
|
6
5
|
|
@@ -10,16 +9,16 @@ describe Atig::IFilter::RetweetTime do
|
|
10
9
|
end
|
11
10
|
|
12
11
|
it "should throw normal status" do
|
13
|
-
filtered("hello").
|
12
|
+
expect(filtered("hello")).to be_text("hello")
|
14
13
|
end
|
15
14
|
|
16
15
|
it "should prefix RT for Retweet" do
|
17
|
-
filtered("RT @mzp: hello",
|
16
|
+
expect(filtered("RT @mzp: hello",
|
18
17
|
'retweeted_status'=>{ 'text' => 'hello',
|
19
18
|
'created_at' => 'Sat Sep 25 14:33:19 +0000 2010',
|
20
19
|
'user' => {
|
21
20
|
'screen_name' => 'mzp'
|
22
|
-
} }).
|
23
|
-
|
21
|
+
} })).
|
22
|
+
to be_text("#{@rt}RT @mzp: hello \x0310[2010-09-25 14:33]\x0F")
|
24
23
|
end
|
25
24
|
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/sanitize'
|
5
4
|
require 'atig/twitter_struct'
|
6
5
|
|
@@ -10,16 +9,16 @@ describe Atig::IFilter::Sanitize do
|
|
10
9
|
end
|
11
10
|
|
12
11
|
it "should convert escape html" do
|
13
|
-
filtered("< > "").
|
12
|
+
expect(filtered("< > "")).to be_text("< > \"")
|
14
13
|
end
|
15
14
|
|
16
15
|
it "should convert whitespace" do
|
17
|
-
filtered("\r\n").
|
18
|
-
filtered("\r").
|
19
|
-
filtered("\n").
|
16
|
+
expect(filtered("\r\n")).to be_text(" ")
|
17
|
+
expect(filtered("\r")).to be_text(" ")
|
18
|
+
expect(filtered("\n")).to be_text(" ")
|
20
19
|
end
|
21
20
|
|
22
21
|
it "should delete \\000\\001 sequence" do
|
23
|
-
filtered("\000\001").
|
22
|
+
expect(filtered("\000\001")).to be_text("")
|
24
23
|
end
|
25
24
|
end
|
data/spec/ifilter/sid_spec.rb
CHANGED
@@ -1,29 +1,28 @@
|
|
1
1
|
# -*- mode:ruby; coding:utf-8 -*-
|
2
2
|
|
3
|
-
require File.expand_path( '../../spec_helper', __FILE__ )
|
4
3
|
require 'atig/ifilter/xid'
|
5
4
|
require 'atig/twitter_struct'
|
6
5
|
|
7
6
|
describe Atig::IFilter::Sid, "when disable tid" do
|
8
7
|
def filtered(text)
|
9
|
-
ifilter = Atig::IFilter::Sid.new(OpenStruct.new(:
|
10
|
-
:
|
8
|
+
ifilter = Atig::IFilter::Sid.new(OpenStruct.new(log:double('log'),
|
9
|
+
opts:OpenStruct.new))
|
11
10
|
ifilter.call status(text,'sid'=>1)
|
12
11
|
end
|
13
12
|
|
14
13
|
it "should through text" do
|
15
|
-
filtered("hello").
|
14
|
+
expect(filtered("hello")).to be_text("hello")
|
16
15
|
end
|
17
16
|
end
|
18
17
|
|
19
18
|
describe Atig::IFilter::Sid, "when enable tid" do
|
20
19
|
def filtered(text)
|
21
|
-
ifilter = Atig::IFilter::Sid.new(OpenStruct.new(:
|
22
|
-
:
|
20
|
+
ifilter = Atig::IFilter::Sid.new(OpenStruct.new(log:double('log'),
|
21
|
+
opts:OpenStruct.new(sid:true)))
|
23
22
|
ifilter.call status(text,'sid'=>1)
|
24
23
|
end
|
25
24
|
|
26
25
|
it "should append sid" do
|
27
|
-
filtered("hello").
|
26
|
+
expect(filtered("hello")).to be_text("hello \x0310[1]\x0F")
|
28
27
|
end
|
29
28
|
end
|
data/spec/ifilter/strip_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/ifilter/strip'
|
5
4
|
require 'atig/twitter_struct'
|
6
5
|
|
@@ -10,14 +9,14 @@ describe Atig::IFilter::Strip do
|
|
10
9
|
end
|
11
10
|
|
12
11
|
it "should strip *tw*" do
|
13
|
-
@ifilter.call(status("hoge *tw*")).
|
12
|
+
expect(@ifilter.call(status("hoge *tw*"))).to be_text("hoge")
|
14
13
|
end
|
15
14
|
|
16
15
|
it "should strip _" do
|
17
|
-
@ifilter.call(status("hoge _")).
|
16
|
+
expect(@ifilter.call(status("hoge _"))).to be_text("hoge")
|
18
17
|
end
|
19
18
|
|
20
19
|
it "should strip white-space" do
|
21
|
-
@ifilter.call(status(" hoge ")).
|
20
|
+
expect(@ifilter.call(status(" hoge "))).to be_text("hoge")
|
22
21
|
end
|
23
22
|
end
|
data/spec/ifilter/tid_spec.rb
CHANGED
@@ -1,29 +1,28 @@
|
|
1
1
|
# -*- mode:ruby; coding:utf-8 -*-
|
2
2
|
|
3
|
-
require File.expand_path( '../../spec_helper', __FILE__ )
|
4
3
|
require 'atig/ifilter/xid'
|
5
4
|
require 'atig/twitter_struct'
|
6
5
|
|
7
6
|
describe Atig::IFilter::Tid, "when disable tid" do
|
8
7
|
def filtered(text)
|
9
|
-
ifilter = Atig::IFilter::Tid.new(OpenStruct.new(:
|
10
|
-
:
|
8
|
+
ifilter = Atig::IFilter::Tid.new(OpenStruct.new(log:double('log'),
|
9
|
+
opts:OpenStruct.new))
|
11
10
|
ifilter.call status(text,'tid'=>1)
|
12
11
|
end
|
13
12
|
|
14
13
|
it "should through text" do
|
15
|
-
filtered("hello").
|
14
|
+
expect(filtered("hello")).to be_text("hello")
|
16
15
|
end
|
17
16
|
end
|
18
17
|
|
19
18
|
describe Atig::IFilter::Tid, "when enable tid" do
|
20
19
|
def filtered(text)
|
21
|
-
ifilter = Atig::IFilter::Tid.new(OpenStruct.new(:
|
22
|
-
:
|
20
|
+
ifilter = Atig::IFilter::Tid.new(OpenStruct.new(log:double('log'),
|
21
|
+
opts:OpenStruct.new(tid:true)))
|
23
22
|
ifilter.call status(text,'tid'=>1)
|
24
23
|
end
|
25
24
|
|
26
25
|
it "should append tid" do
|
27
|
-
filtered("hello").
|
26
|
+
expect(filtered("hello")).to be_text("hello \x0310[1]\x0F")
|
28
27
|
end
|
29
28
|
end
|
data/spec/levenshtein_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/levenshtein'
|
5
4
|
|
6
5
|
target = [Atig::Levenshtein, Atig::Levenshtein::PureRuby]
|
@@ -16,8 +15,8 @@ target.each do |m|
|
|
16
15
|
["", "foo", 3],
|
17
16
|
["あああ", "ああい", 1],
|
18
17
|
].each do |a, b, expected|
|
19
|
-
m.levenshtein(a.split(//), b.split(//)).
|
20
|
-
m.levenshtein(b.split(//), a.split(//)).
|
18
|
+
expect(m.levenshtein(a.split(//), b.split(//))).to eq(expected)
|
19
|
+
expect(m.levenshtein(b.split(//), a.split(//))).to eq(expected)
|
21
20
|
end
|
22
21
|
end
|
23
22
|
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/ofilter/escape_url'
|
5
4
|
|
6
5
|
class Atig::OFilter::EscapeUrl
|
@@ -10,22 +9,22 @@ end
|
|
10
9
|
describe Atig::OFilter::EscapeUrl do
|
11
10
|
before do
|
12
11
|
@logger = double('Logger')
|
13
|
-
@logger.
|
14
|
-
@logger.
|
15
|
-
@logger.
|
12
|
+
expect(@logger).to receive(:info).at_most(:once)
|
13
|
+
expect(@logger).to receive(:error).at_most(:once)
|
14
|
+
expect(@logger).to receive(:debug).at_most(:once)
|
16
15
|
end
|
17
16
|
|
18
17
|
def filtered(text,opt={})
|
19
|
-
esc = Atig::OFilter::EscapeUrl.new(OpenStruct.new(
|
20
|
-
esc.call :
|
18
|
+
esc = Atig::OFilter::EscapeUrl.new(OpenStruct.new(log:@logger,:opts=>nil))
|
19
|
+
esc.call status: text
|
21
20
|
end
|
22
21
|
|
23
22
|
it "through normal url" do
|
24
|
-
filtered("http://example.com").
|
23
|
+
expect(filtered("http://example.com")).to eq({ status: "http://example.com"})
|
25
24
|
end
|
26
25
|
|
27
26
|
it "escape only url" do
|
28
|
-
filtered("あああ http://example.com/あああ").
|
27
|
+
expect(filtered("あああ http://example.com/あああ")).to eq({ status: "あああ http://example.com/%E3%81%82%E3%81%82%E3%81%82" })
|
29
28
|
end
|
30
29
|
end
|
31
30
|
|
@@ -33,18 +32,18 @@ if defined? ::Punycode then
|
|
33
32
|
describe Atig::OFilter::EscapeUrl,"when punycode is enabled" do
|
34
33
|
before do
|
35
34
|
@logger = double('Logger')
|
36
|
-
@logger.
|
37
|
-
@logger.
|
38
|
-
@logger.
|
35
|
+
expect(@logger).to receive(:info).at_most(:once)
|
36
|
+
expect(@logger).to receive(:error).at_most(:once)
|
37
|
+
expect(@logger).to receive(:debug).at_most(:once)
|
39
38
|
end
|
40
39
|
|
41
40
|
def filtered(text,opt={})
|
42
|
-
esc = Atig::OFilter::EscapeUrl.new(OpenStruct.new(
|
43
|
-
esc.call :
|
41
|
+
esc = Atig::OFilter::EscapeUrl.new(OpenStruct.new(log:@logger,:opts=>nil))
|
42
|
+
esc.call status: text
|
44
43
|
end
|
45
44
|
|
46
45
|
it "escape international URL" do
|
47
|
-
filtered("http://あああ.com").
|
46
|
+
expect(filtered("http://あああ.com")).to eq({status: "http://xn--l8jaa.com" })
|
48
47
|
end
|
49
48
|
end
|
50
49
|
end
|
data/spec/ofilter/footer_spec.rb
CHANGED
@@ -1,32 +1,31 @@
|
|
1
1
|
# -*- mode:ruby; coding:utf-8 -*-
|
2
2
|
|
3
|
-
require File.expand_path( '../../spec_helper', __FILE__ )
|
4
3
|
require 'atig/ofilter/footer'
|
5
4
|
require 'ostruct'
|
6
5
|
|
7
6
|
describe Atig::OFilter::Footer do
|
8
7
|
before do
|
9
8
|
@opts = OpenStruct.new
|
10
|
-
@filter = Atig::OFilter::Footer.new(OpenStruct.new(
|
9
|
+
@filter = Atig::OFilter::Footer.new(OpenStruct.new(opts:@opts))
|
11
10
|
end
|
12
11
|
|
13
12
|
it "should pass through" do
|
14
|
-
@filter.call(:
|
15
|
-
:
|
16
|
-
}
|
13
|
+
expect(@filter.call(status: 'hi')).to eq({
|
14
|
+
status: "hi"
|
15
|
+
})
|
17
16
|
end
|
18
17
|
|
19
18
|
it "should append footer" do
|
20
19
|
@opts.footer = '*tw*'
|
21
|
-
@filter.call(:
|
22
|
-
:
|
23
|
-
}
|
20
|
+
expect(@filter.call(status: 'hi')).to eq({
|
21
|
+
status: "hi *tw*"
|
22
|
+
})
|
24
23
|
end
|
25
24
|
|
26
25
|
it "should not append footer" do
|
27
26
|
@opts.footer = false
|
28
|
-
@filter.call(:
|
29
|
-
:
|
30
|
-
}
|
27
|
+
expect(@filter.call(status: 'hi')).to eq({
|
28
|
+
status: "hi"
|
29
|
+
})
|
31
30
|
end
|
32
31
|
end
|
data/spec/ofilter/geo_spec.rb
CHANGED
@@ -1,33 +1,32 @@
|
|
1
1
|
# -*- mode:ruby; coding:utf-8 -*-
|
2
2
|
|
3
|
-
require File.expand_path( '../../spec_helper', __FILE__ )
|
4
3
|
require 'atig/ofilter/geo'
|
5
4
|
require 'ostruct'
|
6
5
|
|
7
6
|
describe Atig::OFilter::Geo,"when disabled" do
|
8
7
|
def filtered(text,opt={})
|
9
|
-
geo = Atig::OFilter::Geo.new(OpenStruct.new(:
|
10
|
-
geo.call :
|
8
|
+
geo = Atig::OFilter::Geo.new(OpenStruct.new(opts:OpenStruct.new(opt)))
|
9
|
+
geo.call status: text
|
11
10
|
end
|
12
11
|
|
13
12
|
it "should through" do
|
14
|
-
filtered("hi").
|
15
|
-
:
|
16
|
-
}
|
13
|
+
expect(filtered("hi")).to eq({
|
14
|
+
status: "hi"
|
15
|
+
})
|
17
16
|
end
|
18
17
|
end
|
19
18
|
|
20
19
|
describe Atig::OFilter::Geo,"when enabled" do
|
21
20
|
def filtered(text,opt={})
|
22
|
-
geo = Atig::OFilter::Geo.new(OpenStruct.new(:
|
23
|
-
geo.call :
|
21
|
+
geo = Atig::OFilter::Geo.new(OpenStruct.new(opts:OpenStruct.new(opt)))
|
22
|
+
geo.call status: text
|
24
23
|
end
|
25
24
|
|
26
25
|
it "add lat & long" do
|
27
|
-
filtered("hi",:ll=>"42.1,43.1").
|
28
|
-
:
|
29
|
-
:
|
30
|
-
:
|
31
|
-
}
|
26
|
+
expect(filtered("hi",:ll=>"42.1,43.1")).to eq({
|
27
|
+
status: "hi",
|
28
|
+
lat: 42.1,
|
29
|
+
long: 43.1
|
30
|
+
})
|
32
31
|
end
|
33
32
|
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/ofilter/short_url'
|
5
4
|
require 'ostruct'
|
6
5
|
|
@@ -8,17 +7,17 @@ describe Atig::OFilter::ShortUrl,"when no-login bitly" do
|
|
8
7
|
before do
|
9
8
|
logger = double('Logger')
|
10
9
|
bitly = double("Bitly")
|
11
|
-
bitly.
|
10
|
+
allow(bitly).to receive(:shorten){|s|
|
12
11
|
"[#{s}]"
|
13
12
|
}
|
14
|
-
Atig::Bitly.
|
15
|
-
@ofilter = Atig::OFilter::ShortUrl.new(OpenStruct.new(:
|
13
|
+
expect(Atig::Bitly).to receive(:no_login).with(logger).and_return(bitly)
|
14
|
+
@ofilter = Atig::OFilter::ShortUrl.new(OpenStruct.new(log:logger, opts:OpenStruct.new('bitlify'=>true)))
|
16
15
|
end
|
17
16
|
|
18
17
|
it "should shorten url by bitly" do
|
19
|
-
@ofilter.call({:
|
20
|
-
:
|
21
|
-
}
|
18
|
+
expect(@ofilter.call({status: "this is http://example.com/a http://example.com/b"})).to eq({
|
19
|
+
status: "this is [http://example.com/a] [http://example.com/b]"
|
20
|
+
})
|
22
21
|
end
|
23
22
|
end
|
24
23
|
|
@@ -26,17 +25,17 @@ describe Atig::OFilter::ShortUrl,"when no-login bitly with size" do
|
|
26
25
|
before do
|
27
26
|
logger = double('Logger')
|
28
27
|
bitly = double("Bitly")
|
29
|
-
bitly.
|
28
|
+
allow(bitly).to receive(:shorten){|s|
|
30
29
|
"[#{s}]"
|
31
30
|
}
|
32
|
-
Atig::Bitly.
|
33
|
-
@ofilter = Atig::OFilter::ShortUrl.new(OpenStruct.new(:
|
31
|
+
expect(Atig::Bitly).to receive(:no_login).with(logger).and_return(bitly)
|
32
|
+
@ofilter = Atig::OFilter::ShortUrl.new(OpenStruct.new(log:logger, opts:OpenStruct.new('bitlify'=>13)))
|
34
33
|
end
|
35
34
|
|
36
35
|
it "should only shorten large url" do
|
37
|
-
@ofilter.call({:
|
38
|
-
:
|
39
|
-
}
|
36
|
+
expect(@ofilter.call({status: "this is http://example.com/a http://a.com"})).to eq({
|
37
|
+
status: "this is [http://example.com/a] http://a.com"
|
38
|
+
})
|
40
39
|
end
|
41
40
|
end
|
42
41
|
|
@@ -44,17 +43,17 @@ describe Atig::OFilter::ShortUrl,"when login bitly" do
|
|
44
43
|
before do
|
45
44
|
logger = double('Logger')
|
46
45
|
bitly = double("Bitly")
|
47
|
-
bitly.
|
46
|
+
allow(bitly).to receive(:shorten){|s|
|
48
47
|
"[#{s}]"
|
49
48
|
}
|
50
|
-
Atig::Bitly.
|
51
|
-
@ofilter = Atig::OFilter::ShortUrl.new(OpenStruct.new(:
|
49
|
+
expect(Atig::Bitly).to receive(:login).with(logger,"username","api_key").and_return(bitly)
|
50
|
+
@ofilter = Atig::OFilter::ShortUrl.new(OpenStruct.new(log:logger, opts:OpenStruct.new('bitlify'=>'username:api_key')))
|
52
51
|
end
|
53
52
|
|
54
53
|
it "should only shorten large url" do
|
55
|
-
@ofilter.call({:
|
56
|
-
:
|
57
|
-
}
|
54
|
+
expect(@ofilter.call({status: "this is http://example.com/a http://example.com/b"})).to eq({
|
55
|
+
status: "this is [http://example.com/a] [http://example.com/b]"
|
56
|
+
})
|
58
57
|
end
|
59
58
|
end
|
60
59
|
|
@@ -62,17 +61,17 @@ describe Atig::OFilter::ShortUrl,"when login bitly with size" do
|
|
62
61
|
before do
|
63
62
|
logger = double('Logger')
|
64
63
|
bitly = double("Bitly")
|
65
|
-
bitly.
|
64
|
+
allow(bitly).to receive(:shorten){|s|
|
66
65
|
"[#{s}]"
|
67
66
|
}
|
68
|
-
Atig::Bitly.
|
69
|
-
@ofilter = Atig::OFilter::ShortUrl.new(OpenStruct.new(:
|
67
|
+
expect(Atig::Bitly).to receive(:login).with(logger,"username","api_key").and_return(bitly)
|
68
|
+
@ofilter = Atig::OFilter::ShortUrl.new(OpenStruct.new(log:logger, opts:OpenStruct.new('bitlify'=>'username:api_key:13')))
|
70
69
|
end
|
71
70
|
|
72
71
|
it "should only shorten large url" do
|
73
|
-
@ofilter.call({:
|
74
|
-
:
|
75
|
-
}
|
72
|
+
expect(@ofilter.call({status: "this is http://example.com/a http://a.com"})).to eq({
|
73
|
+
status: "this is [http://example.com/a] http://a.com"
|
74
|
+
})
|
76
75
|
end
|
77
76
|
end
|
78
77
|
|
@@ -80,12 +79,12 @@ describe Atig::OFilter::ShortUrl,"when nop" do
|
|
80
79
|
before do
|
81
80
|
logger = double('Logger')
|
82
81
|
|
83
|
-
@ofilter = Atig::OFilter::ShortUrl.new(OpenStruct.new(:
|
82
|
+
@ofilter = Atig::OFilter::ShortUrl.new(OpenStruct.new(log:logger, opts:OpenStruct.new()))
|
84
83
|
end
|
85
84
|
|
86
85
|
it "should only not do anything" do
|
87
|
-
@ofilter.call({:
|
88
|
-
:
|
89
|
-
}
|
86
|
+
expect(@ofilter.call({status: "this is http://example.com/a http://a.com"})).to eq({
|
87
|
+
status: "this is http://example.com/a http://a.com"
|
88
|
+
})
|
90
89
|
end
|
91
90
|
end
|