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 CHANGED
@@ -1 +1 @@
1
- 0.5.0
1
+ 0.5.1
@@ -24,14 +24,9 @@ module WikipediaTFA
24
24
  end
25
25
 
26
26
  def next
27
- prev_tweet = get_last_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
@@ -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 @twitter_module.exception
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
- @twitter_module._tweet(message, options)
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
@@ -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
- @twuckoo.stubs(:get_last_tweet).returns("Twitter: http://en.wikipedia.org/wiki/Twitter")
16
- @twuckoo.stubs(:fetch_tfa).returns("Twitter: http://en.wikipedia.org/wiki/Twitter")
17
- @twuckoo.stubs(:next).returns(@twuckoo.get_last_tweet).then.
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
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{twuckoo}
8
- s.version = "0.5.0"
8
+ s.version = "0.5.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Balint Erdi"]
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: 11
4
+ hash: 9
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 5
9
- - 0
10
- version: 0.5.0
9
+ - 1
10
+ version: 0.5.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Balint Erdi