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/lib/atig/search.rb
CHANGED
|
@@ -5,14 +5,16 @@ require 'atig/url_escape'
|
|
|
5
5
|
module Atig
|
|
6
6
|
class Search
|
|
7
7
|
def search(query, options = {})
|
|
8
|
+
options[:q] = query
|
|
9
|
+
|
|
8
10
|
search = URI("https://search.twitter.com")
|
|
9
11
|
search.path = "/search.json"
|
|
10
|
-
params = options; options[:q] = query
|
|
11
12
|
search.query = options.to_query_str
|
|
13
|
+
|
|
12
14
|
http = Http.new nil
|
|
13
15
|
req = http.req(:get, search)
|
|
14
16
|
res = http.http(search, 5, 10).request(req)
|
|
15
|
-
|
|
17
|
+
JSON.parse(res.body)
|
|
16
18
|
rescue Errno::ETIMEDOUT, JSON::ParserError, IOError, Timeout::Error, Errno::ECONNRESET => e
|
|
17
19
|
@log.error e
|
|
18
20
|
text
|
data/lib/atig/stream.rb
CHANGED
|
@@ -33,7 +33,7 @@ module Atig
|
|
|
33
33
|
|
|
34
34
|
http = Net::HTTP.new(uri.host, uri.port)
|
|
35
35
|
http.use_ssl = true
|
|
36
|
-
request = Net::HTTP::Get.new(uri.request_uri)
|
|
36
|
+
request = Net::HTTP::Get.new(uri.request_uri, {"Accept-Encoding" => "identity"})
|
|
37
37
|
request.oauth!(http, @access.consumer, @access)
|
|
38
38
|
http.request(request) do |response|
|
|
39
39
|
unless response.code == '200' then
|
data/lib/atig/twitter.rb
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
2
|
|
|
3
|
+
require 'timeout'
|
|
3
4
|
require 'atig/basic_twitter'
|
|
4
5
|
require 'atig/http'
|
|
5
6
|
|
|
@@ -17,8 +18,8 @@ module Atig
|
|
|
17
18
|
r = []
|
|
18
19
|
cursor = -1
|
|
19
20
|
1.upto(limit) do |num|
|
|
20
|
-
options = {:
|
|
21
|
-
ret = api(path, options, { :
|
|
21
|
+
options = {cursor: cursor}.merge(opts)
|
|
22
|
+
ret = api(path, options, { authenticate: true })
|
|
22
23
|
r.concat ret[name]
|
|
23
24
|
cursor = ret[:next_cursor]
|
|
24
25
|
break if cursor.zero?
|
|
@@ -30,7 +31,7 @@ module Atig
|
|
|
30
31
|
methods.each do |m|
|
|
31
32
|
self.module_eval <<END
|
|
32
33
|
def #{m}(path, query = {}, opts = {})
|
|
33
|
-
opts.update( :
|
|
34
|
+
opts.update( method: :#{m})
|
|
34
35
|
api path, query, opts
|
|
35
36
|
end
|
|
36
37
|
END
|
|
@@ -56,7 +57,7 @@ END
|
|
|
56
57
|
end
|
|
57
58
|
|
|
58
59
|
def oauth(time, req)
|
|
59
|
-
timeout(time) do
|
|
60
|
+
Timeout.timeout(time) do
|
|
60
61
|
headers = {}
|
|
61
62
|
req.each{|k,v| headers[k] = v }
|
|
62
63
|
|
data/lib/atig/update_checker.rb
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
module Atig
|
|
4
4
|
module UpdateChecker
|
|
5
5
|
def commits
|
|
6
|
-
uri = URI("https://api.github.com/repos/
|
|
6
|
+
uri = URI("https://api.github.com/repos/atig/atig/commits")
|
|
7
7
|
http = Atig::Http.new
|
|
8
8
|
res = http.http(uri).request http.req(:get, uri)
|
|
9
9
|
JSON.parse(res.body)
|
|
@@ -47,7 +47,7 @@ module Atig
|
|
|
47
47
|
end.map {|i| i['commit']['message'] }
|
|
48
48
|
end
|
|
49
49
|
end
|
|
50
|
-
rescue Errno::ECONNREFUSED, Timeout::Error
|
|
50
|
+
rescue TypeError, Errno::ECONNREFUSED, Timeout::Error
|
|
51
51
|
[]
|
|
52
52
|
end
|
|
53
53
|
|
data/lib/atig/url_escape.rb
CHANGED
data/lib/atig/version.rb
CHANGED
data/lib/memory_profiler.rb
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
# each cycle. You can then use 'diff' to spot which strings were added
|
|
17
17
|
# between runs.
|
|
18
18
|
class MemoryProfiler
|
|
19
|
-
DEFAULTS = {:
|
|
19
|
+
DEFAULTS = {delay: 10, string_debug: false}
|
|
20
20
|
|
|
21
21
|
def self.start(opt={})
|
|
22
22
|
opt = DEFAULTS.dup.merge(opt)
|
|
@@ -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/command/autofix'
|
|
5
4
|
|
|
6
5
|
describe Atig::Command::Autofix do
|
|
@@ -10,24 +9,24 @@ describe Atig::Command::Autofix do
|
|
|
10
9
|
@opts.autofix = true
|
|
11
10
|
target = status 'hello', 'id'=>'42'
|
|
12
11
|
entry = entry user(1,'mzp'), target, "entry", 1
|
|
13
|
-
@statuses.
|
|
12
|
+
expect(@statuses).to receive(:find_by_user).with(@me,:limit=>1).and_return([ entry ])
|
|
14
13
|
end
|
|
15
14
|
|
|
16
15
|
it "should post normal tweet" do
|
|
17
16
|
res = status('blah blah')
|
|
18
|
-
@api.
|
|
17
|
+
expect(@api).to receive(:post).with('statuses/update', {status:'blah blah'}).and_return(res)
|
|
19
18
|
|
|
20
19
|
call '#twitter', "autofix", %w(blah blah)
|
|
21
20
|
end
|
|
22
21
|
|
|
23
22
|
it "should delete old similar tweet" do
|
|
24
23
|
res = status('hillo')
|
|
25
|
-
@api.
|
|
26
|
-
@api.
|
|
27
|
-
@statuses.
|
|
24
|
+
expect(@api).to receive(:post).with('statuses/update', {status:'hillo'}).and_return(res)
|
|
25
|
+
expect(@api).to receive(:post).with("statuses/destroy/42")
|
|
26
|
+
expect(@statuses).to receive(:remove_by_id).with(1)
|
|
28
27
|
|
|
29
|
-
@channel.
|
|
30
|
-
@channel.
|
|
28
|
+
expect(@channel).to receive(:notify).with("Similar update in previous. Conclude that it has error.")
|
|
29
|
+
expect(@channel).to receive(:notify).with("And overwrite previous as new status: hillo")
|
|
31
30
|
|
|
32
31
|
call '#twitter', "autofix", %w(hillo)
|
|
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/command/destroy'
|
|
5
4
|
|
|
6
5
|
describe Atig::Command::Destroy,"when status is not removed" do
|
|
@@ -12,9 +11,9 @@ describe Atig::Command::Destroy,"when status is not removed" do
|
|
|
12
11
|
|
|
13
12
|
it "should specified other's status" do
|
|
14
13
|
entry = entry user(2,'other'), status('blah blah', 'id'=>'1')
|
|
15
|
-
@statuses.
|
|
14
|
+
allow(@statuses).to receive(:find_by_tid).with('b').and_return(entry)
|
|
16
15
|
|
|
17
|
-
@channel.
|
|
16
|
+
expect(@channel).to receive(:notify).with("The status you specified by the ID tid is not yours.")
|
|
18
17
|
call "#twitter","destory",%w(b)
|
|
19
18
|
end
|
|
20
19
|
end
|
|
@@ -31,20 +30,20 @@ describe Atig::Command::Destroy,"when remove recently tweet" do
|
|
|
31
30
|
|
|
32
31
|
stub_status(:find_by_tid,'a' => entry)
|
|
33
32
|
stub_status(:find_by_sid,'mzp:a' => entry)
|
|
34
|
-
stub_status(:find_by_screen_name,'mzp' => [ entry ], :
|
|
33
|
+
stub_status(:find_by_screen_name,'mzp' => [ entry ], default:[])
|
|
35
34
|
|
|
36
35
|
# api
|
|
37
|
-
@api.
|
|
36
|
+
expect(@api).to receive(:post).with("statuses/destroy/1")
|
|
38
37
|
|
|
39
38
|
# notice
|
|
40
|
-
@channel.
|
|
39
|
+
expect(@channel).to receive(:notify).with("Destroyed: blah blah")
|
|
41
40
|
|
|
42
41
|
# update topics
|
|
43
42
|
new_entry = entry @me, status('foo', 'id'=>'2')
|
|
44
|
-
@gateway.
|
|
43
|
+
expect(@gateway).to receive(:topic).with(new_entry)
|
|
45
44
|
|
|
46
|
-
@statuses.
|
|
47
|
-
@statuses.
|
|
45
|
+
expect(@statuses).to receive(:remove_by_id).with(1){
|
|
46
|
+
expect(@statuses).to receive(:find_by_screen_name).with(@me.screen_name,:limit=>1){
|
|
48
47
|
[ new_entry ]
|
|
49
48
|
}
|
|
50
49
|
}
|
|
@@ -75,16 +74,16 @@ describe Atig::Command::Destroy,"when remove old tweet" do
|
|
|
75
74
|
|
|
76
75
|
stub_status(:find_by_tid,'a' => entry)
|
|
77
76
|
stub_status(:find_by_sid,'mzp:a' => entry)
|
|
78
|
-
stub_status(:find_by_screen_name, @db.me.screen_name => [ entry ], :
|
|
77
|
+
stub_status(:find_by_screen_name, @db.me.screen_name => [ entry ], default:[])
|
|
79
78
|
|
|
80
79
|
# api
|
|
81
|
-
@api.
|
|
80
|
+
expect(@api).to receive(:post).with("statuses/destroy/1")
|
|
82
81
|
|
|
83
82
|
# notice
|
|
84
|
-
@channel.
|
|
83
|
+
expect(@channel).to receive(:notify).with("Destroyed: blah blah")
|
|
85
84
|
|
|
86
85
|
# update topics
|
|
87
|
-
@statuses.
|
|
86
|
+
expect(@statuses).to receive(:remove_by_id).with(1)
|
|
88
87
|
end
|
|
89
88
|
|
|
90
89
|
it "should specified by tid" do
|
data/spec/command/dm_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/command/dm'
|
|
5
4
|
|
|
6
5
|
describe Atig::Command::Dm do
|
|
@@ -10,18 +9,18 @@ describe Atig::Command::Dm do
|
|
|
10
9
|
end
|
|
11
10
|
|
|
12
11
|
it "should have '/me dm' name" do
|
|
13
|
-
@gateway.names.
|
|
12
|
+
expect(@gateway.names).to eq(['d', 'dm','dms'])
|
|
14
13
|
end
|
|
15
14
|
|
|
16
15
|
it "should post the status by API" do
|
|
17
|
-
@api.
|
|
18
|
-
{:
|
|
19
|
-
@channel.
|
|
16
|
+
expect(@api).to receive(:post).with('direct_messages/new',
|
|
17
|
+
{screen_name: 'mzp', text: 'blah blah'})
|
|
18
|
+
expect(@channel).to receive(:notify).with("Sent message to mzp: blah blah")
|
|
20
19
|
call '#twitter', "dm", %w(mzp blah blah)
|
|
21
20
|
end
|
|
22
21
|
|
|
23
22
|
it "should post the status by API" do
|
|
24
|
-
@channel.
|
|
23
|
+
expect(@channel).to receive(:notify).with("/me dm <SCREEN_NAME> blah blah")
|
|
25
24
|
call '#twitter', "dm", %w()
|
|
26
25
|
end
|
|
27
26
|
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/command/favorite'
|
|
5
4
|
|
|
6
5
|
describe Atig::Command::Favorite do
|
|
@@ -14,40 +13,40 @@ describe Atig::Command::Favorite do
|
|
|
14
13
|
|
|
15
14
|
stub_status(:find_by_tid,'a' => entry)
|
|
16
15
|
stub_status(:find_by_sid,'mzp:a' => entry)
|
|
17
|
-
stub_status(:find_by_screen_name,'mzp' => [ entry ], :
|
|
16
|
+
stub_status(:find_by_screen_name,'mzp' => [ entry ], default:[])
|
|
18
17
|
end
|
|
19
18
|
|
|
20
19
|
it "should post fav by tid" do
|
|
21
|
-
@api.
|
|
22
|
-
@channel.
|
|
20
|
+
expect(@api).to receive(:post).with("favorites/create", {id: "1"})
|
|
21
|
+
expect(@channel).to receive(:notify).with("FAV: mzp: blah blah")
|
|
23
22
|
|
|
24
23
|
call "#twitter","fav",%w(a)
|
|
25
24
|
end
|
|
26
25
|
|
|
27
26
|
it "should post fav by sid" do
|
|
28
|
-
@api.
|
|
29
|
-
@channel.
|
|
27
|
+
expect(@api).to receive(:post).with("favorites/create", {id: "1"})
|
|
28
|
+
expect(@channel).to receive(:notify).with("FAV: mzp: blah blah")
|
|
30
29
|
|
|
31
30
|
call "#twitter","fav",%w(mzp:a)
|
|
32
31
|
end
|
|
33
32
|
|
|
34
33
|
it "should post fav by screen name" do
|
|
35
|
-
@api.
|
|
36
|
-
@channel.
|
|
34
|
+
expect(@api).to receive(:post).with("favorites/create", {id: "1"})
|
|
35
|
+
expect(@channel).to receive(:notify).with("FAV: mzp: blah blah")
|
|
37
36
|
|
|
38
37
|
call "#twitter","fav",%w(mzp)
|
|
39
38
|
end
|
|
40
39
|
|
|
41
40
|
it "should post fav by screen name with at" do
|
|
42
|
-
@api.
|
|
43
|
-
@channel.
|
|
41
|
+
expect(@api).to receive(:post).with("favorites/create", {id: "1"})
|
|
42
|
+
expect(@channel).to receive(:notify).with("FAV: mzp: blah blah")
|
|
44
43
|
|
|
45
44
|
call "#twitter","fav",%w(@mzp)
|
|
46
45
|
end
|
|
47
46
|
|
|
48
47
|
it "should post unfav" do
|
|
49
|
-
@api.
|
|
50
|
-
@channel.
|
|
48
|
+
expect(@api).to receive(:post).with("favorites/destroy", {id: "1"})
|
|
49
|
+
expect(@channel).to receive(:notify).with("UNFAV: mzp: blah blah")
|
|
51
50
|
|
|
52
51
|
call "#twitter","unfav",%w(a)
|
|
53
52
|
end
|
data/spec/command/limit_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/command/limit'
|
|
5
4
|
|
|
6
5
|
describe Atig::Command::Limit do
|
|
@@ -9,18 +8,18 @@ describe Atig::Command::Limit do
|
|
|
9
8
|
before do
|
|
10
9
|
@reset = ::Time.utc(2010,9,25,8,24,12)
|
|
11
10
|
@command = init Atig::Command::Limit
|
|
12
|
-
@api.
|
|
13
|
-
@api.
|
|
14
|
-
@api.
|
|
11
|
+
allow(@api).to receive(:limit).and_return(150)
|
|
12
|
+
allow(@api).to receive(:remain).and_return(148)
|
|
13
|
+
allow(@api).to receive(:reset).and_return(@reset)
|
|
15
14
|
end
|
|
16
15
|
|
|
17
16
|
it "should provide limit command" do
|
|
18
|
-
@gateway.names.
|
|
17
|
+
expect(@gateway.names).to eq(['rls','limit','limits'])
|
|
19
18
|
end
|
|
20
19
|
|
|
21
20
|
it "should show limit" do
|
|
22
|
-
@channel.
|
|
21
|
+
expect(@channel).to receive(:notify).with("148 / 150 (reset at 2010-09-25 08:24:12)")
|
|
23
22
|
call '#twitter', 'limit', []
|
|
24
|
-
@gateway.notified.
|
|
23
|
+
expect(@gateway.notified).to eq('#twitter')
|
|
25
24
|
end
|
|
26
25
|
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/command/location'
|
|
5
4
|
|
|
6
5
|
describe Atig::Command::Location do
|
|
@@ -11,14 +10,14 @@ describe Atig::Command::Location do
|
|
|
11
10
|
end
|
|
12
11
|
|
|
13
12
|
it "should update location" do
|
|
14
|
-
@api.
|
|
15
|
-
@channel.
|
|
13
|
+
expect(@api).to receive(:post).with('account/update_profile',:location=>'some place')
|
|
14
|
+
expect(@channel).to receive(:notify).with("You are in some place now.")
|
|
16
15
|
call '#twitter','location',%w(some place)
|
|
17
16
|
end
|
|
18
17
|
|
|
19
18
|
it "should reset location" do
|
|
20
|
-
@api.
|
|
21
|
-
@channel.
|
|
19
|
+
expect(@api).to receive(:post).with('account/update_profile',:location=>'')
|
|
20
|
+
expect(@channel).to receive(:notify).with("You are nowhere now.")
|
|
22
21
|
call '#twitter','location',%w()
|
|
23
22
|
end
|
|
24
23
|
end
|
data/spec/command/name_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/command/name'
|
|
5
4
|
|
|
6
5
|
describe Atig::Command::Name do
|
|
@@ -11,8 +10,8 @@ describe Atig::Command::Name do
|
|
|
11
10
|
end
|
|
12
11
|
|
|
13
12
|
it "should update name" do
|
|
14
|
-
@api.
|
|
15
|
-
@channel.
|
|
13
|
+
expect(@api).to receive(:post).with('account/update_profile',:name=>'mzp')
|
|
14
|
+
expect(@channel).to receive(:notify).with("You are named mzp.")
|
|
16
15
|
call '#twitter', 'name', %w(mzp)
|
|
17
16
|
end
|
|
18
17
|
end
|
data/spec/command/option_spec.rb
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
# -*- mode:ruby; coding:utf-8 -*-
|
|
2
2
|
|
|
3
|
-
require File.expand_path( '../spec_helper', File.dirname(__FILE__))
|
|
4
3
|
require 'atig/command/option'
|
|
5
4
|
|
|
6
5
|
describe Atig::Command::Option do
|
|
@@ -11,7 +10,7 @@ describe Atig::Command::Option do
|
|
|
11
10
|
end
|
|
12
11
|
|
|
13
12
|
it "should provide option command" do
|
|
14
|
-
@command.command_name.
|
|
13
|
+
expect(@command.command_name).to eq(%w(opt opts option options))
|
|
15
14
|
end
|
|
16
15
|
end
|
|
17
16
|
|
|
@@ -24,20 +23,20 @@ describe Atig::Command::Option, 'when have many property' do
|
|
|
24
23
|
@opts.foo2 = 42
|
|
25
24
|
@opts.foo3 = 42.1
|
|
26
25
|
|
|
27
|
-
@opts.
|
|
28
|
-
@opts.
|
|
29
|
-
@opts.
|
|
26
|
+
allow(@opts).to receive(:foo1=)
|
|
27
|
+
allow(@opts).to receive(:foo2=)
|
|
28
|
+
allow(@opts).to receive(:foo3=)
|
|
30
29
|
end
|
|
31
30
|
|
|
32
31
|
it "should list up values" do
|
|
33
32
|
xs = []
|
|
34
|
-
@channel.
|
|
33
|
+
allow(@channel).to receive(:notify){|x| xs << x}
|
|
35
34
|
call '#twitter', 'opt', %w()
|
|
36
|
-
xs.
|
|
35
|
+
expect(xs).to eq([
|
|
37
36
|
"foo1 => true",
|
|
38
37
|
"foo2 => 42",
|
|
39
38
|
"foo3 => 42.1",
|
|
40
|
-
]
|
|
39
|
+
])
|
|
41
40
|
end
|
|
42
41
|
end
|
|
43
42
|
|
|
@@ -47,19 +46,19 @@ describe Atig::Command::Option, 'when have bool property' do
|
|
|
47
46
|
|
|
48
47
|
before do
|
|
49
48
|
@command = init Atig::Command::Option
|
|
50
|
-
@opts.
|
|
51
|
-
@opts.
|
|
52
|
-
@channel.
|
|
49
|
+
allow(@opts).to receive(:foo).and_return true
|
|
50
|
+
allow(@opts).to receive(:foo=){|v| @value = v }
|
|
51
|
+
allow(@channel).to receive(:notify)
|
|
53
52
|
end
|
|
54
53
|
|
|
55
54
|
it "should show the value" do
|
|
56
|
-
@channel.
|
|
55
|
+
expect(@channel).to receive(:notify).with("foo => true")
|
|
57
56
|
call '#twitter', 'opt', %w(foo)
|
|
58
57
|
end
|
|
59
58
|
|
|
60
59
|
it "should update the value" do
|
|
61
60
|
call '#twitter', 'opt', %w(foo false)
|
|
62
|
-
@value.
|
|
61
|
+
expect(@value).to be_falsey
|
|
63
62
|
end
|
|
64
63
|
end
|
|
65
64
|
|
|
@@ -68,19 +67,19 @@ describe Atig::Command::Option, 'when have int property' do
|
|
|
68
67
|
|
|
69
68
|
before do
|
|
70
69
|
@command = init Atig::Command::Option
|
|
71
|
-
@opts.
|
|
72
|
-
@opts.
|
|
73
|
-
@channel.
|
|
70
|
+
allow(@opts).to receive(:foo).and_return 42
|
|
71
|
+
allow(@opts).to receive(:foo=){|v| @value = v }
|
|
72
|
+
allow(@channel).to receive(:notify)
|
|
74
73
|
end
|
|
75
74
|
|
|
76
75
|
it "should show the value" do
|
|
77
|
-
@channel.
|
|
76
|
+
expect(@channel).to receive(:notify).with("foo => 42")
|
|
78
77
|
call '#twitter', 'opt', %w(foo)
|
|
79
78
|
end
|
|
80
79
|
|
|
81
80
|
it "should update the value" do
|
|
82
81
|
call '#twitter', 'opt', %w(foo 42)
|
|
83
|
-
@value.
|
|
82
|
+
expect(@value).to eq(42)
|
|
84
83
|
end
|
|
85
84
|
end
|
|
86
85
|
|
|
@@ -89,19 +88,19 @@ describe Atig::Command::Option, 'when have float property' do
|
|
|
89
88
|
|
|
90
89
|
before do
|
|
91
90
|
@command = init Atig::Command::Option
|
|
92
|
-
@opts.
|
|
93
|
-
@opts.
|
|
94
|
-
@channel.
|
|
91
|
+
allow(@opts).to receive(:foo).and_return 1.23
|
|
92
|
+
allow(@opts).to receive(:foo=){|v| @value = v }
|
|
93
|
+
allow(@channel).to receive(:notify)
|
|
95
94
|
end
|
|
96
95
|
|
|
97
96
|
it "should show the value" do
|
|
98
|
-
@channel.
|
|
97
|
+
expect(@channel).to receive(:notify).with("foo => 1.23")
|
|
99
98
|
call '#twitter', 'opt', %w(foo)
|
|
100
99
|
end
|
|
101
100
|
|
|
102
101
|
it "should update the value" do
|
|
103
102
|
call '#twitter', 'opt', %w(foo 1.24)
|
|
104
|
-
@value.
|
|
103
|
+
expect(@value).to eq(1.24)
|
|
105
104
|
end
|
|
106
105
|
end
|
|
107
106
|
|
|
@@ -110,23 +109,23 @@ describe Atig::Command::Option, 'when have string property' do
|
|
|
110
109
|
|
|
111
110
|
before do
|
|
112
111
|
@command = init Atig::Command::Option
|
|
113
|
-
@opts.
|
|
114
|
-
@opts.
|
|
115
|
-
@channel.
|
|
112
|
+
allow(@opts).to receive(:foo).and_return "bar"
|
|
113
|
+
allow(@opts).to receive(:foo=){|v| @value = v }
|
|
114
|
+
allow(@channel).to receive(:notify)
|
|
116
115
|
end
|
|
117
116
|
|
|
118
117
|
it "should show the value" do
|
|
119
|
-
@channel.
|
|
118
|
+
expect(@channel).to receive(:notify).with("foo => bar")
|
|
120
119
|
call '#twitter', 'opt', %w(foo)
|
|
121
120
|
end
|
|
122
121
|
|
|
123
122
|
it "should update the value" do
|
|
124
123
|
call '#twitter', 'opt', %w(foo baz)
|
|
125
|
-
@value.
|
|
124
|
+
expect(@value).to eq('baz')
|
|
126
125
|
end
|
|
127
126
|
|
|
128
127
|
it "should update the value" do
|
|
129
128
|
call '#twitter', 'opt', %w(foo blah Blah)
|
|
130
|
-
@value.
|
|
129
|
+
expect(@value).to eq('blah Blah')
|
|
131
130
|
end
|
|
132
131
|
end
|