tweetomator 1.1.8 → 1.1.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/composers/markov_composer.rb +19 -5
- data/lib/tweet.rb +4 -0
- data/lib/tweetomator/version.rb +1 -1
- data/lib/tweetomator.rb +3 -3
- data/test/lib/composers/markov_composer_test.rb +1 -1
- data/test/lib/composers/random_composer_test.rb +4 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b5d25f56d5ff4f9bcf039eef79b1e3f305e56924
|
4
|
+
data.tar.gz: d228c5535d82e0cde622b2a41ac132a49bead8d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f057d70b33b1405e7e66aebe093454c998bf54adfb0376305526e46abbcc4a7bccf17250b4999da9b7f17dd1eb9f2f20bfea0acf6e51cd5c04dc6c5c117a9627
|
7
|
+
data.tar.gz: e42afa09452a2676a96d180756c69b0a32a6bd576b91bd3aa01ba82b2fd8c6acb04a4156a962122269fb7051fe8912b1b3c6d52d8223865869db4a2d5f48b63e
|
data/Gemfile.lock
CHANGED
@@ -21,11 +21,9 @@ class MarkovComposer < Composer
|
|
21
21
|
word = get(word)
|
22
22
|
end
|
23
23
|
text = clean_up(text)
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
end
|
28
|
-
return Tweet.new(clean_up(text), '', @twitter_client)
|
24
|
+
tweet = create_tweet(text)
|
25
|
+
insert_emoji(tweet) if [true, false].sample
|
26
|
+
tweet
|
29
27
|
end
|
30
28
|
|
31
29
|
def compose_image_query(query)
|
@@ -63,4 +61,20 @@ class MarkovComposer < Composer
|
|
63
61
|
end
|
64
62
|
text
|
65
63
|
end
|
64
|
+
|
65
|
+
def create_tweet(text)
|
66
|
+
if [1, 2, 3].sample < 3
|
67
|
+
hashtag = @lines.sample.split.reject { |w| w.strip.nil? || /[^A-Za-z]/.match(w.strip) != nil || @stop_words.include?(w.strip) }.sample
|
68
|
+
if hashtag != nil && (text.length + hashtag.length + 1) < @max_length
|
69
|
+
return Tweet.new(text, hashtag.downcase, @twitter_client)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
return Tweet.new(text, '', @twitter_client)
|
73
|
+
end
|
74
|
+
|
75
|
+
def insert_emoji(tweet)
|
76
|
+
if tweet.length < @max_length + " #{127872.chr('utf-8')}".length
|
77
|
+
tweet.append(@emoji_finder.find)
|
78
|
+
end
|
79
|
+
end
|
66
80
|
end
|
data/lib/tweet.rb
CHANGED
data/lib/tweetomator/version.rb
CHANGED
data/lib/tweetomator.rb
CHANGED
@@ -8,7 +8,7 @@ class TestMarkovComposer < Minitest::Unit::TestCase
|
|
8
8
|
riveting_tale = "And even in this cosmopolitan trend, he did that precede and open the way to other more advanced civilizations. \n About henceforth in Europe, no cease to be a citizen of his country, it is not, in any way, International? no one \n can shut, like the snail, by its shell: all need air, space wider for match the new needs, their aspirations."
|
9
9
|
@amazing_narrative = "#{cool_story} #{riveting_tale}"
|
10
10
|
mock_emoji_finder = Minitest::Mock.new
|
11
|
-
mock_emoji_finder.expect :find, '
|
11
|
+
mock_emoji_finder.expect :find, 127872.chr('utf-8')
|
12
12
|
mock_tweet_finder = Minitest::Mock.new
|
13
13
|
mock_tweet_client = Minitest::Mock.new
|
14
14
|
@max_length = 100
|
@@ -8,7 +8,7 @@ class TestRandomComposer < Minitest::Unit::TestCase
|
|
8
8
|
tweet_2 = 'I HAVE NYANED FOR 48.9 SECONDS! http://nyan.cat via @nyannyancat'
|
9
9
|
cool_story = "So there I am, in Sri Lanka, formerly Ceylon, at about 3 o'clock in the morning, looking for one thousand brown M&Ms to fill a brandy glass, or Ozzy wouldn't go on stage that night. So, Jeff Beck pops his head 'round the door, and mentions there's a little sweets shop on the edge of town. So - we go. And - it's closed. So there's me, and Keith Moon, and David Crosby, breaking into that little sweets shop, eh. Well, instead of a guard dog, they've got this bloody great big Bengal tiger. I managed to take out the tiger with a can of mace, but the shopkeeper and his son... that's a different story altogether. I had to beat them to death with their own shoes. Nasty business, really, but sure enough I got the M&Ms, and Ozzy went on stage and did a great show."
|
10
10
|
mock_emoji_finder = Minitest::Mock.new
|
11
|
-
mock_emoji_finder.expect :find, '
|
11
|
+
mock_emoji_finder.expect :find, 127872.chr('utf-8')
|
12
12
|
mock_tweet_finder = Minitest::Mock.new
|
13
13
|
mock_tweet_finder.expect :find_tweets, [tweet_1, tweet_2, cool_story]
|
14
14
|
mock_tweet_finder.expect :find_tweet, tweet_1, [String]
|
@@ -17,7 +17,10 @@ class TestRandomComposer < Minitest::Unit::TestCase
|
|
17
17
|
@max_length = 100
|
18
18
|
@blacklist = %w(sri lanka)
|
19
19
|
@stop_words = %w(Potato Salad)
|
20
|
+
mock_twitter_config = Minitest::Mock.new
|
21
|
+
mock_twitter_config.expect :tweet_max_length, @max_length
|
20
22
|
mock_config = Minitest::Mock.new
|
23
|
+
mock_config.expect :twitter_config, mock_twitter_config
|
21
24
|
mock_config.expect :max_length, @max_length
|
22
25
|
mock_config.expect :blacklist, @blacklist
|
23
26
|
mock_config.expect :stop_words, @stop_words
|