Skip to content

Commit 62af850

Browse files
committed
include winner url in the summary tweet
1 parent b28066b commit 62af850

File tree

3 files changed

+10
-11
lines changed

3 files changed

+10
-11
lines changed

spec/utils_spec.rb

+5-6
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,13 @@
2424
end
2525

2626
describe '#summary_text' do
27-
it 'renders the text' do
28-
expect(summary_text(['a', 'b']).length).to be <= LIMIT
29-
end
3027
it 'truncates a really long list of makers' do
3128
makers = (1..15).map { |i| "maker#{i}" }
32-
expect(summary_text(makers).length).to be <= LIMIT
33-
expect(summary_text(makers)).to include Time.now.year.to_s
34-
expect(summary_text(makers)).to include '@maker2'
29+
url = 'http://www.google.com'
30+
expect(summary_text(makers, url)).to include Time.now.year.to_s
31+
expect(summary_text(makers, url)).to include '@maker2'
32+
expect(summary_text(makers, url)).not_to include '@maker15'
33+
expect(summary_text(makers, url)).to include 'google.com'
3534
end
3635
end
3736

tweet_client.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def run(subject:, rank:)
3030
case subject
3131
when 'summary'
3232
# send summary tweet
33-
@client.update_with_media(summary_text(entry_data['makers']), img)
33+
@client.update_with_media(summary_text(entry_data['makers'], url), img)
3434
# add makers and hunters to respective twitter lists
3535
add_list_members(hunters: entry_data['hunters'],
3636
makers: entry_data['makers'])

utils.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
ACTIONS = ['👍', '👏']
2-
THINGS = ['🌟', '🏆', '🏅', '💯', '🚀', '🎉', '😎', '😻', '🤘']
2+
THINGS = ['🌟', '🏅', '💯', '🚀', '🎉', '😎', '😻', '🤘']
33
DRINKS = ['🍾', '🍻']
44
WORDS = ['Woot', 'Yay', 'Nice', 'Sweet', 'Radical', 'Hurray', 'Epic',
55
'Like a boss', 'Whoa', 'Wow']
@@ -32,11 +32,11 @@ def init_client
3232
end
3333
end
3434

35-
def summary_text(makers_array)
35+
def summary_text(makers_array, winner_url)
3636
handles = makers_array.map{ |m| "@#{m}" }.join(' ')
3737
str = "#TopHunts of #{date_str} on @producthunt #{THINGS.sample(2).join} " \
38-
"Products by #{handles} #{ACTIONS.sample}"
39-
truncate(str, LIMIT)
38+
"Products by #{handles}"
39+
"#{truncate(str, LIMIT)} 🏆 #{shorten(winner_url)}"
4040
end
4141

4242
def hunter_text(hunter, rank, url)

0 commit comments

Comments
 (0)