twat 0.9.2 → 0.9.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +0 -1
- data/Gemfile.lock +13 -13
- data/lib/twat/follow_mixin.rb +3 -7
- data/lib/twat/version.rb +1 -1
- data/spec/follow_mixin_spec.rb +19 -0
- data/spec/helpers/{oauth.rb → mocks/oauth.rb} +2 -2
- data/spec/helpers/mocks/tweet.rb +19 -0
- data/spec/spec_helper.rb +1 -1
- data/spec/subcommands/finger_spec.rb +2 -2
- data/spec/subcommands/follow_tag_spec.rb +2 -2
- data/twat.gemspec +1 -1
- metadata +6 -4
- data/Gemfile.travis +0 -12
data/.travis.yml
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
twat (0.9.
|
4
|
+
twat (0.9.2)
|
5
5
|
oauth
|
6
6
|
readline-ng (>= 0.0.8)
|
7
7
|
twitter
|
@@ -18,23 +18,23 @@ GEM
|
|
18
18
|
i18n (0.6.0)
|
19
19
|
metaclass (0.0.1)
|
20
20
|
mktemp (0.0.1)
|
21
|
-
mocha (0.11.
|
21
|
+
mocha (0.11.4)
|
22
22
|
metaclass (~> 0.0.1)
|
23
|
-
multi_json (1.3.
|
23
|
+
multi_json (1.3.5)
|
24
24
|
multipart-post (1.1.5)
|
25
25
|
oauth (0.4.6)
|
26
26
|
rake (0.9.2.2)
|
27
|
-
readline-ng (0.0.
|
28
|
-
rspec (2.
|
29
|
-
rspec-core (~> 2.
|
30
|
-
rspec-expectations (~> 2.
|
31
|
-
rspec-mocks (~> 2.
|
32
|
-
rspec-core (2.
|
33
|
-
rspec-expectations (2.
|
27
|
+
readline-ng (0.0.9)
|
28
|
+
rspec (2.10.0)
|
29
|
+
rspec-core (~> 2.10.0)
|
30
|
+
rspec-expectations (~> 2.10.0)
|
31
|
+
rspec-mocks (~> 2.10.0)
|
32
|
+
rspec-core (2.10.1)
|
33
|
+
rspec-expectations (2.10.0)
|
34
34
|
diff-lcs (~> 1.1.3)
|
35
|
-
rspec-mocks (2.
|
36
|
-
simple_oauth (0.1.
|
37
|
-
twitter (2.
|
35
|
+
rspec-mocks (2.10.1)
|
36
|
+
simple_oauth (0.1.8)
|
37
|
+
twitter (2.4.0)
|
38
38
|
activesupport (>= 2.3.9, < 4)
|
39
39
|
faraday (~> 0.8)
|
40
40
|
multi_json (~> 1.3)
|
data/lib/twat/follow_mixin.rb
CHANGED
@@ -68,9 +68,10 @@ module FollowMixin
|
|
68
68
|
|
69
69
|
def process_input(inp)
|
70
70
|
case inp
|
71
|
-
when /^
|
71
|
+
when /^(?:retweet|rt) ([0-9]{1,2})/i
|
72
72
|
begin
|
73
|
-
|
73
|
+
twt = get_tweet($1.to_i)
|
74
|
+
Twitter.retweet(twt.id)
|
74
75
|
return true
|
75
76
|
rescue ::Twat::Exceptions::NoSuchTweet
|
76
77
|
return "#{inp.red} #{":: No such tweet".bold.red}"
|
@@ -105,11 +106,6 @@ module FollowMixin
|
|
105
106
|
@tweetstack[idx]
|
106
107
|
end
|
107
108
|
|
108
|
-
# Wrapper methods from the tweetstack implementation
|
109
|
-
def retweet(idx)
|
110
|
-
Twitter.retweet(get_tweet(idx).id)
|
111
|
-
end
|
112
|
-
|
113
109
|
def fail_or_bail
|
114
110
|
if @failcount > 2
|
115
111
|
puts "3 consecutive failures, giving up"
|
data/lib/twat/version.rb
CHANGED
@@ -0,0 +1,19 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe FollowMixin do
|
4
|
+
|
5
|
+
it "Should not retweet users with numbers for usernames" do
|
6
|
+
# 58 seems to be a magic number
|
7
|
+
subcmd = Twat::Subcommands::FollowTag.new([])
|
8
|
+
def subcmd.tweetstack
|
9
|
+
@tweetstack ||= ::Twat::TweetStack.new
|
10
|
+
end
|
11
|
+
|
12
|
+
# We start tweetstack offsets at 1 for easy readability
|
13
|
+
(1..60).each { |n| subcmd.tweetstack << Twat::Mocks::Tweet.new(:id => n) }
|
14
|
+
|
15
|
+
Twitter.expects(:retweet).with(10058)
|
16
|
+
subcmd.send(:process_input, "rt 58")
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
@@ -1,14 +1,14 @@
|
|
1
1
|
STUB_URL = "url"
|
2
2
|
STUB_PIN = "1234"
|
3
3
|
def mock_request_token
|
4
|
-
t =
|
4
|
+
t = ::Mocha::Mock.new(Object)
|
5
5
|
t.expects(:authorize_url).returns(STUB_URL)
|
6
6
|
t.expects(:get_access_token).with(oauth_verifier: STUB_PIN).returns(mock_access_token)
|
7
7
|
return t
|
8
8
|
end
|
9
9
|
|
10
10
|
def mock_access_token
|
11
|
-
t =
|
11
|
+
t = ::Mocha::Mock.new(Object)
|
12
12
|
t.expects(:token).returns("I'mtotallyatokenbrah")
|
13
13
|
t.expects(:secret).returns("I'mtotallyasecretbrah")
|
14
14
|
return t
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Twat::Mocks
|
2
|
+
class Tweet
|
3
|
+
def initialize(opts={})
|
4
|
+
@opts = opts
|
5
|
+
end
|
6
|
+
|
7
|
+
def id
|
8
|
+
@opts[:id]+10000
|
9
|
+
end
|
10
|
+
|
11
|
+
# def method_missing(sym, *args)
|
12
|
+
# if opts.include? sym
|
13
|
+
# opts[sym]
|
14
|
+
# else
|
15
|
+
# raise "#{sym}"
|
16
|
+
# end
|
17
|
+
# end
|
18
|
+
end
|
19
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -13,7 +13,7 @@ describe Twat do
|
|
13
13
|
|
14
14
|
it "Should retrieve a tweet for user if called with only a user" do #{{{
|
15
15
|
with_config(Fixtures::multiuser_config) do
|
16
|
-
tweet =
|
16
|
+
tweet = Twat::Mocks::Tweet.new
|
17
17
|
tweet.expects(:each).yields(tweet)
|
18
18
|
Twitter.expects(:user_timeline).with("hanke", :count => 1).returns(tweet)
|
19
19
|
Twat::Subcommands::Finger.any_instance.expects(:format).with(tweet)
|
@@ -27,7 +27,7 @@ describe Twat do
|
|
27
27
|
|
28
28
|
it "Should retrieve n tweets for user if invoked with count" do #{{{
|
29
29
|
with_config(Fixtures::multiuser_config) do
|
30
|
-
tweet =
|
30
|
+
tweet = Twat::Mocks::Tweet.new
|
31
31
|
Twitter.expects(:user_timeline).with("hanke", :count => 3).returns([tweet, tweet, tweet])
|
32
32
|
Twat::Subcommands::Finger.any_instance.expects(:format).with(tweet).times(3)
|
33
33
|
|
@@ -26,7 +26,7 @@ describe Twat do
|
|
26
26
|
|
27
27
|
it "Should call search with the argument if called with one" do #{{{
|
28
28
|
with_config(Fixtures::multiuser_config) do
|
29
|
-
mock_opts =
|
29
|
+
mock_opts = Mocha::Mock.new(Object)
|
30
30
|
Twitter.expects(:search).with("#hackmelb", count: 5)
|
31
31
|
Twat::Subcommands::FollowTag.any_instance.expects(:untested).returns(false).at_least_once
|
32
32
|
set_argv ["follow_tag", "#hackmelb"]
|
@@ -38,7 +38,7 @@ describe Twat do
|
|
38
38
|
|
39
39
|
it "Should cat together all commandline args" do #{{{
|
40
40
|
with_config(Fixtures::multiuser_config) do
|
41
|
-
mock_opts =
|
41
|
+
mock_opts = Mocha::Mock.new(Object)
|
42
42
|
Twitter.expects(:search).with("#hackmelb richo", count: 5)
|
43
43
|
Twat::Subcommands::FollowTag.any_instance.expects(:untested).returns(false).at_least_once
|
44
44
|
set_argv ["follow_tag", "#hackmelb", "richo"]
|
data/twat.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: twat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-06-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: twitter
|
@@ -136,7 +136,6 @@ files:
|
|
136
136
|
- .travis.yml
|
137
137
|
- Gemfile
|
138
138
|
- Gemfile.lock
|
139
|
-
- Gemfile.travis
|
140
139
|
- README
|
141
140
|
- Rakefile
|
142
141
|
- TODO
|
@@ -172,11 +171,13 @@ files:
|
|
172
171
|
- lib/twat/version.rb
|
173
172
|
- man/twat.1
|
174
173
|
- spec/argparse_spec.rb
|
174
|
+
- spec/follow_mixin_spec.rb
|
175
175
|
- spec/helpers/environment.rb
|
176
176
|
- spec/helpers/fileutils.rb
|
177
177
|
- spec/helpers/fixtures/core.rb
|
178
178
|
- spec/helpers/fixtures/migrations.rb
|
179
|
-
- spec/helpers/oauth.rb
|
179
|
+
- spec/helpers/mocks/oauth.rb
|
180
|
+
- spec/helpers/mocks/tweet.rb
|
180
181
|
- spec/spec_helper.rb
|
181
182
|
- spec/subcommands/add_spec.rb
|
182
183
|
- spec/subcommands/config_spec.rb
|
@@ -220,3 +221,4 @@ signing_key:
|
|
220
221
|
specification_version: 3
|
221
222
|
summary: Command line tool for tweeting and whatnot
|
222
223
|
test_files: []
|
224
|
+
has_rdoc:
|