lib/lolcommits/plugin/twitter.rb in lolcommits-twitter-0.2.0 vs lib/lolcommits/plugin/twitter.rb in lolcommits-twitter-0.3.0
- old
+ new
@@ -19,11 +19,12 @@
!!(configuration[:token] && configuration[:token_secret])
end
##
# Prompts the user to configure plugin options.
- # Options are enabled (true/false), Twitter auth, and prefix/suffix text.
+ # Options are enabled (true/false), Twitter auth, and
+ # prefix/suffix text.
#
# @return [Hash] a hash of configured plugin options
#
def configure_options!
options = super
@@ -40,19 +41,24 @@
end
options
end
##
- # Capture ready hook, runs after lolcommits captures a snapshot and image
- # processing has completed.
+ # Capture ready hook, runs after lolcommits captures a snapshot
+ # and image processing has completed.
#
- # Posts the lolcommit to Twitter, first uploading the capture media, then
- # posting a new Tweet with the media_id attached.
+ # Posts the lolcommit to Twitter, first uploading the capture
+ # media, then posting a new Tweet with the media_id attached.
#
def run_capture_ready
+ if runner.capture_video && !runner.capture_gif
+ debug "unable to post lolcommit videos, (gif's and jpgs only)"
+ return
+ end
+
status = build_tweet(runner.message)
- file = File.open(runner.main_image, 'rb')
+ file = File.open(image_path, 'rb')
print "Tweeting ... "
begin
client = twitter_client.new(
@@ -72,9 +78,13 @@
puts "ERROR: Tweeting FAILED! - #{e.message}"
end
end
private
+
+ def image_path
+ runner.capture_image? ? runner.lolcommit_path : runner.lolcommit_gif_path
+ end
def twitter_client
Lolcommits::Twitter::Client
end