lib/lolcommits/plugin/tumblr.rb in lolcommits-tumblr-0.3.0 vs lib/lolcommits/plugin/tumblr.rb in lolcommits-tumblr-0.4.0

- old
+ new

@@ -14,28 +14,26 @@ TUMBLR_API_ENDPOINT = 'https://www.tumblr.com'.freeze TUMBLR_CONSUMER_KEY = '2FtMEDpEPkxjoUdkpHh42h9wqTu9IVS7Ra0QyNZGixdCvhllN2'.freeze TUMBLR_CONSUMER_SECRET = 'qWuvxgFUR2YyWKtbWOkDTMAiBEbj7ZGaNLaNQPba0PI1N4JpBs'.freeze ## - # Post-capture hook, runs after lolcommits captures a snapshot. Uploads - # the lolcommit image to the remote server with an optional Authorization - # header and the following request params. + # Post-capture hook, runs after lolcommits captures a snapshot. # - # `file` - captured lolcommit image file - # `message` - the commit message - # `repo` - repository name e.g. mroth/lolcommits - # `sha` - commit SHA - # `key` - key (string) from plugin configuration (optional) - # `author_name` - the commit author name - # `author_email` - the commit author email address + # Posts the lolcommit main image to Tumblr, printing success or + # failure message to stdout. # - # @return [RestClient::Response] response object from POST request - # @return [Nil] if any error occurs - # def run_capture_ready + if runner.capture_video && !runner.capture_gif + debug "unable to post lolcommit videos, (gif's and jpgs only)" + return + end + print "*** Posting to Tumblr ... " - post = client.photo(configuration[:tumblr_name], data: runner.main_image) + post = client.photo( + configuration[:tumblr_name], + data: image_path + ) if post.key?('id') post_url = tumblr_post_url(post) open_url(post_url) if configuration[:open_url] print "done! #{post_url}\n" @@ -77,9 +75,13 @@ options end private + + def image_path + runner.capture_image? ? runner.lolcommit_path : runner.lolcommit_gif_path + end def configure_auth! puts '' puts '----------------------------------------' puts ' Need to grab Tumblr Oauth token '