Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[TwitterNotifier] Cleanup

  • Loading branch information...
commit d80e613efd8c7e3a8ae964955f171963d30e0997 1 parent 6f79a0a
Fabio Pelosin fabiopelosin authored
2  Gemfile.lock
View
@@ -1,6 +1,6 @@
GIT
remote: https://github.com/CocoaPods/Core.git
- revision: 16b15ee5d783653ba2ccac8735abd49c039ca4d3
+ revision: 4ed00ac1d09befa6a309d90d31cb4fafb3a08f65
branch: master
specs:
cocoapods-core (0.28.0)
2  app.rb
View
@@ -97,7 +97,7 @@ def self.update
@pods_count = pods.length
@new_pods = RSS.new(pods, @creation_dates).pods_for_feed
@pods_tweets = {}
- @new_pods.each { |pod| @pods_tweets[pod.name] = TwitterNotifier.new.tweet_preview(pod) }
+ @new_pods.each { |pod| @pods_tweets[pod.name] = TwitterNotifier.new.status_for_pod(pod) }
haml :index
rescue Exception => e
20 lib/cocoapods_notifier/twitter_notifier.rb
View
@@ -22,19 +22,16 @@ def initialize(client = nil)
# @return [void]
#
def tweet(pod)
- status = message_for_pod(pod.name, pod.summary, pod.homepage)
+ status = status_for_pod(pod)
client.update(status)
end
- def tweet_preview(pod)
- message_for_pod(pod.name, pod.summary, pod.homepage)
+ # @return [String]
+ #
+ def status_for_pod(pod)
+ make_status(pod.name, pod.summary, pod.homepage)
end
- private
-
- # Private Helpers
- #-------------------------------------------------------------------------#
-
# Returns the body for the tweet of the given Pod taking into account
# to truncate the summary.
#
@@ -44,7 +41,7 @@ def tweet_preview(pod)
#
# @return [String] The body of the tweet.
#
- def message_for_pod(pod_name, pod_summary, pod_homepage)
+ def make_status(pod_name, pod_summary, pod_homepage)
message = "[#{pod_name}] #{pod_summary}"
if message.length > message_max_length
message = truncate_message(message, message_max_length, ELLIPSIS_STRING)
@@ -54,6 +51,11 @@ def message_for_pod(pod_name, pod_summary, pod_homepage)
message
end
+ private
+
+ # Private Helpers
+ #-------------------------------------------------------------------------#
+
# Truncates the given message to the given length using the given ellipsis
# string. Trailing whitespace, comas and punctuation is removed.
#
6 spec/unit/twitter_spec.rb
View
@@ -26,17 +26,17 @@
describe "Private Helpers" do
- describe "#message_for_pod" do
+ describe "#make_status" do
it "doesn't modifies short messages" do
- result = @sut.send(:message_for_pod, 'Pod', "A short description.", 'www.example.com')
+ result = @sut.send(:make_status, 'Pod', "A short description.", 'www.example.com')
result.should == "[Pod] A short description. www.example.com"
end
it "truncates a long messages" do
pod_summary = "A short description"
pod_summary << "#" * 140
- result = @sut.send(:message_for_pod, 'Pod', pod_summary, 'www.example.com')
+ result = @sut.send(:make_status, 'Pod', pod_summary, 'www.example.com')
result.gsub('www.example.com', '').length.should == 119
result.should.match /\[Pod\] A short description.+ www.example.com/
end
Please sign in to comment.
Something went wrong with that request. Please try again.