twuckoo 0.5.0 → 0.5.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.
- data/VERSION +1 -1
- data/lib/modules/wikipedia_tfa.rb +1 -6
- data/lib/twuckoo/runner.rb +6 -2
- data/lib/twuckoo/twitter_oauth_module.rb +10 -1
- data/spec/wikipedia_tfa_spec.rb +3 -4
- data/twuckoo.gemspec +1 -1
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.5.
|
1
|
+
0.5.1
|
@@ -24,14 +24,9 @@ module WikipediaTFA
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def next
|
27
|
-
prev_tweet =
|
27
|
+
prev_tweet = twitter_module.latest_tweet(config)
|
28
28
|
next_tweet = fetch_tfa
|
29
29
|
prev_tweet == next_tweet ? '' : next_tweet
|
30
30
|
end
|
31
31
|
|
32
|
-
private
|
33
|
-
def get_last_tweet
|
34
|
-
last_tweet = twitter.timeline_for(:me).first
|
35
|
-
last_tweet.text if last_tweet
|
36
|
-
end
|
37
32
|
end
|
data/lib/twuckoo/runner.rb
CHANGED
@@ -83,7 +83,7 @@ class Twuckoo::Runner
|
|
83
83
|
unless message.nil? or message.empty?
|
84
84
|
begin
|
85
85
|
send_tweet(message, config)
|
86
|
-
rescue
|
86
|
+
rescue twitter_module.exception
|
87
87
|
return message
|
88
88
|
else
|
89
89
|
inc_tweet_counter
|
@@ -133,8 +133,12 @@ class Twuckoo::Runner
|
|
133
133
|
end
|
134
134
|
end
|
135
135
|
|
136
|
+
def twitter_module
|
137
|
+
@twitter_module
|
138
|
+
end
|
139
|
+
|
136
140
|
def send_tweet(message, options)
|
137
|
-
|
141
|
+
twitter_module._tweet(message, options)
|
138
142
|
end
|
139
143
|
|
140
144
|
def inc_tweet_counter
|
@@ -4,13 +4,22 @@ require 'twitter_oauth'
|
|
4
4
|
module Twuckoo::TwitterOauth
|
5
5
|
|
6
6
|
def self._tweet(message, options)
|
7
|
+
client(options).update(message)
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.latest_tweet(options)
|
11
|
+
last_tweet = client(options).home_timeline.first
|
12
|
+
last_tweet['text'] if last_tweet
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
def self.client(options)
|
7
17
|
@client ||= TwitterOAuth::Client.new(
|
8
18
|
:consumer_key => options[:consumer_key],
|
9
19
|
:consumer_secret => options[:consumer_secret],
|
10
20
|
:token => options[:oauth_token],
|
11
21
|
:secret => options[:oauth_token_secret]
|
12
22
|
)
|
13
|
-
@client.update(message)
|
14
23
|
end
|
15
24
|
|
16
25
|
end
|
data/spec/wikipedia_tfa_spec.rb
CHANGED
@@ -12,10 +12,9 @@ describe "A cuckoo twitterer for wikipedia featured article" do
|
|
12
12
|
end
|
13
13
|
|
14
14
|
it "should not tweet the same thing twice subsequently" do
|
15
|
-
|
16
|
-
@twuckoo.stubs(:
|
17
|
-
|
18
|
-
returns(@twuckoo.fetch_tfa).then.
|
15
|
+
article_url = "Twitter: http://en.wikipedia.org/wiki/Twitter"
|
16
|
+
@twuckoo.stubs(:next).returns(article_url).then.
|
17
|
+
returns(article_url).then.
|
19
18
|
returns(nil)
|
20
19
|
@twuckoo.expects(:send_tweet).once
|
21
20
|
@twuckoo.run
|
data/twuckoo.gemspec
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: twuckoo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 9
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 5
|
9
|
-
-
|
10
|
-
version: 0.5.
|
9
|
+
- 1
|
10
|
+
version: 0.5.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Balint Erdi
|