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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 75184920fcc8565f58e1048072a439a4d6b41773
4
- data.tar.gz: 45fd555f9194cc36e2f02f700efa16379ca1c877
3
+ metadata.gz: b5d25f56d5ff4f9bcf039eef79b1e3f305e56924
4
+ data.tar.gz: d228c5535d82e0cde622b2a41ac132a49bead8d4
5
5
  SHA512:
6
- metadata.gz: 24db3bfa199ce4d4a3a4979faf65ac21b56f68e4c12afcc15a09298dcb598e4939c946fa525f86c16324f923d1b855660b99baea9752b844bcacb7fa9ae291e7
7
- data.tar.gz: 57733d19766fdd0aa410ff6584620917556f32f89319f78c6bfd448ecd7d3ba9ca29b84b45d608db05c64add4196998d103c4f83c5cb1f27163cb46f0d5bf9c0
6
+ metadata.gz: f057d70b33b1405e7e66aebe093454c998bf54adfb0376305526e46abbcc4a7bccf17250b4999da9b7f17dd1eb9f2f20bfea0acf6e51cd5c04dc6c5c117a9627
7
+ data.tar.gz: e42afa09452a2676a96d180756c69b0a32a6bd576b91bd3aa01ba82b2fd8c6acb04a4156a962122269fb7051fe8912b1b3c6d52d8223865869db4a2d5f48b63e
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- tweetomator (1.1.7)
4
+ tweetomator (1.1.9)
5
5
  flickraw
6
6
  rufus-scheduler
7
7
  twitter
@@ -21,11 +21,9 @@ class MarkovComposer < Composer
21
21
  word = get(word)
22
22
  end
23
23
  text = clean_up(text)
24
- hashtag = @lines.sample.split.reject { |w| w.strip.nil? || /[^A-Za-z]/.match(w.strip) != nil || @stop_words.include?(w.strip) }.sample
25
- if hashtag != nil && (text.length + hashtag.length + 1) < @max_length && (1..4).to_a.sample == 4
26
- return Tweet.new(clean_up(text), hashtag.downcase, @twitter_client)
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
@@ -23,4 +23,8 @@ class Tweet
23
23
  def length
24
24
  with_hashtag.length
25
25
  end
26
+
27
+ def append(text)
28
+ @text << ' ' << text
29
+ end
26
30
  end
@@ -1,3 +1,3 @@
1
1
  class Tweetomator
2
- VERSION = '1.1.8'
2
+ VERSION = '1.1.9'
3
3
  end
data/lib/tweetomator.rb CHANGED
@@ -46,10 +46,10 @@ class Tweetomator
46
46
  end
47
47
 
48
48
  def do_stuff
49
- r = (1..10).to_a.sample
50
- if r < 3
49
+ r = (1..9).to_a.sample
50
+ if r < 4
51
51
  tweet_with_image!
52
- elsif r < 9
52
+ elsif r < 7
53
53
  tweet!
54
54
  else
55
55
  follow!
@@ -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, ':trollface:'
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, ':trollface:'
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tweetomator
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.8
4
+ version: 1.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nat Young