lolcommits 0.9.2 → 0.9.3.pre1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop_todo.yml +6 -0
- data/CHANGELOG.md +243 -105
- data/CONTRIBUTING.md +2 -2
- data/README.md +10 -3
- data/bin/lolcommits +9 -16
- data/features/step_definitions/lolcommits_steps.rb +0 -1
- data/features/support/env.rb +0 -1
- data/features/support/path_helpers.rb +0 -1
- data/lib/core_ext/mini_magick/utilities.rb +0 -1
- data/lib/lolcommits.rb +16 -16
- data/lib/lolcommits/backends/git_info.rb +0 -1
- data/lib/lolcommits/backends/installation_git.rb +0 -1
- data/lib/lolcommits/backends/installation_mercurial.rb +0 -1
- data/lib/lolcommits/backends/mercurial_info.rb +0 -1
- data/lib/lolcommits/capturer.rb +0 -1
- data/lib/lolcommits/capturer/capture_cygwin.rb +0 -1
- data/lib/lolcommits/capturer/capture_fake.rb +0 -1
- data/lib/lolcommits/capturer/capture_linux.rb +0 -1
- data/lib/lolcommits/capturer/capture_linux_animated.rb +0 -1
- data/lib/lolcommits/capturer/capture_mac.rb +0 -1
- data/lib/lolcommits/capturer/capture_mac_animated.rb +0 -1
- data/lib/lolcommits/capturer/capture_windows.rb +0 -1
- data/lib/lolcommits/cli/fatals.rb +0 -8
- data/lib/lolcommits/cli/launcher.rb +0 -1
- data/lib/lolcommits/cli/process_runner.rb +0 -2
- data/lib/lolcommits/cli/timelapse_gif.rb +0 -1
- data/lib/lolcommits/configuration.rb +10 -7
- data/lib/lolcommits/gem_plugin.rb +46 -0
- data/lib/lolcommits/installation.rb +0 -1
- data/lib/lolcommits/platform.rb +0 -1
- data/lib/lolcommits/plugin/base.rb +110 -0
- data/lib/lolcommits/plugin/dot_com.rb +50 -0
- data/lib/lolcommits/plugin/lol_flowdock.rb +69 -0
- data/lib/lolcommits/plugin/lol_hipchat.rb +124 -0
- data/lib/lolcommits/plugin/lol_protonet.rb +68 -0
- data/lib/lolcommits/plugin/lol_slack.rb +68 -0
- data/lib/lolcommits/plugin/lol_tumblr.rb +129 -0
- data/lib/lolcommits/plugin/lol_twitter.rb +176 -0
- data/lib/lolcommits/plugin/lol_yammer.rb +84 -0
- data/lib/lolcommits/plugin/lolsrv.rb +58 -0
- data/lib/lolcommits/plugin/loltext.rb +190 -0
- data/lib/lolcommits/plugin/term_output.rb +55 -0
- data/lib/lolcommits/{plugins → plugin}/tranzlate.rb +14 -15
- data/lib/lolcommits/plugin/uploldz.rb +65 -0
- data/lib/lolcommits/plugin_manager.rb +48 -0
- data/lib/lolcommits/runner.rb +4 -5
- data/lib/lolcommits/test_helpers/fake_io.rb +20 -0
- data/lib/lolcommits/test_helpers/git_repo.rb +44 -0
- data/lib/lolcommits/vcs_info.rb +0 -1
- data/lib/lolcommits/version.rb +2 -2
- data/lolcommits.gemspec +2 -2
- data/test/lolcommits_test.rb +1 -2
- data/test/plugins_test.rb +7 -8
- metadata +22 -19
- data/lib/core_ext/class.rb +0 -8
- data/lib/lolcommits/plugin.rb +0 -123
- data/lib/lolcommits/plugins/dot_com.rb +0 -51
- data/lib/lolcommits/plugins/lol_flowdock.rb +0 -70
- data/lib/lolcommits/plugins/lol_hipchat.rb +0 -125
- data/lib/lolcommits/plugins/lol_protonet.rb +0 -69
- data/lib/lolcommits/plugins/lol_slack.rb +0 -69
- data/lib/lolcommits/plugins/lol_tumblr.rb +0 -129
- data/lib/lolcommits/plugins/lol_twitter.rb +0 -176
- data/lib/lolcommits/plugins/lol_yammer.rb +0 -85
- data/lib/lolcommits/plugins/lolsrv.rb +0 -58
- data/lib/lolcommits/plugins/loltext.rb +0 -184
- data/lib/lolcommits/plugins/term_output.rb +0 -54
- data/lib/lolcommits/plugins/uploldz.rb +0 -66
@@ -1,69 +0,0 @@
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
2
|
-
require 'rest_client'
|
3
|
-
|
4
|
-
module Lolcommits
|
5
|
-
class LolSlack < Plugin
|
6
|
-
ENDPOINT_URL = 'https://slack.com/api/files.upload'.freeze
|
7
|
-
RETRY_COUNT = 2
|
8
|
-
|
9
|
-
def self.name
|
10
|
-
'slack'
|
11
|
-
end
|
12
|
-
|
13
|
-
def self.runner_order
|
14
|
-
:postcapture
|
15
|
-
end
|
16
|
-
|
17
|
-
def configured?
|
18
|
-
!configuration['access_token'].nil?
|
19
|
-
end
|
20
|
-
|
21
|
-
def configure
|
22
|
-
print "Open the URL below and issue a token for your user:\n"
|
23
|
-
print "https://api.slack.com/web\n"
|
24
|
-
print "Enter the generated token below, then press enter: (e.g. xxxx-xxxxxxxxx-xxxx) \n"
|
25
|
-
code = STDIN.gets.to_s.strip
|
26
|
-
print "Enter a comma-seperated list of channel IDs to post images in, then press enter: (e.g. C1234567890,C1234567890)\n"
|
27
|
-
print "NOTE: you must use channel IDs (not channel names). Grab them from here; https://api.slack.com/methods/channels.list/test\n"
|
28
|
-
channels = STDIN.gets.to_s.strip
|
29
|
-
|
30
|
-
{ 'access_token' => code,
|
31
|
-
'channels' => channels }
|
32
|
-
end
|
33
|
-
|
34
|
-
def configure_options!
|
35
|
-
options = super
|
36
|
-
if options['enabled']
|
37
|
-
config = configure
|
38
|
-
options.merge!(config)
|
39
|
-
end
|
40
|
-
options
|
41
|
-
end
|
42
|
-
|
43
|
-
def run_postcapture
|
44
|
-
return unless valid_configuration?
|
45
|
-
|
46
|
-
retries = RETRY_COUNT
|
47
|
-
begin
|
48
|
-
|
49
|
-
response = RestClient.post(
|
50
|
-
ENDPOINT_URL,
|
51
|
-
file: File.new(runner.main_image),
|
52
|
-
token: configuration['access_token'],
|
53
|
-
filetype: 'jpg',
|
54
|
-
filename: runner.sha,
|
55
|
-
title: runner.message + "[#{runner.vcs_info.repo}]",
|
56
|
-
channels: configuration['channels']
|
57
|
-
)
|
58
|
-
|
59
|
-
debug response
|
60
|
-
rescue => e
|
61
|
-
retries -= 1
|
62
|
-
retry if retries > 0
|
63
|
-
puts "Posting to slack failed - #{e.message}"
|
64
|
-
puts 'Try running config again:'
|
65
|
-
puts "\tlolcommits --config --plugin slack"
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
@@ -1,129 +0,0 @@
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
2
|
-
require 'yaml'
|
3
|
-
require 'oauth'
|
4
|
-
require 'webrick'
|
5
|
-
require 'cgi'
|
6
|
-
require 'tumblr_client'
|
7
|
-
|
8
|
-
module Lolcommits
|
9
|
-
class LolTumblr < Plugin
|
10
|
-
TUMBLR_API_ENDPOINT = 'https://www.tumblr.com'.freeze
|
11
|
-
TUMBLR_CONSUMER_KEY = '2FtMEDpEPkxjoUdkpHh42h9wqTu9IVS7Ra0QyNZGixdCvhllN2'.freeze
|
12
|
-
TUMBLR_CONSUMER_SECRET = 'qWuvxgFUR2YyWKtbWOkDTMAiBEbj7ZGaNLaNQPba0PI1N4JpBs'.freeze
|
13
|
-
|
14
|
-
def run_postcapture
|
15
|
-
return unless valid_configuration?
|
16
|
-
puts 'Posting to Tumblr'
|
17
|
-
r = client.photo(configuration['tumblr_name'], data: runner.main_image)
|
18
|
-
if r.key?('id')
|
19
|
-
puts "\t--> Post successful!"
|
20
|
-
else
|
21
|
-
puts "Tumblr post FAILED! #{r}"
|
22
|
-
end
|
23
|
-
rescue Faraday::Error => e
|
24
|
-
puts "Tumblr post FAILED! #{e.message}"
|
25
|
-
end
|
26
|
-
|
27
|
-
def configure_options!
|
28
|
-
options = super
|
29
|
-
# ask user to configure tokens if enabling
|
30
|
-
if options['enabled']
|
31
|
-
auth_config = configure_auth!
|
32
|
-
return unless auth_config
|
33
|
-
options = options.merge(auth_config).merge(configure_tumblr_name)
|
34
|
-
end
|
35
|
-
options
|
36
|
-
end
|
37
|
-
|
38
|
-
def configure_auth!
|
39
|
-
puts '---------------------------'
|
40
|
-
puts 'Need to grab tumblr tokens'
|
41
|
-
puts '---------------------------'
|
42
|
-
|
43
|
-
request_token = oauth_consumer.get_request_token(exclude_callback: true)
|
44
|
-
print "\n1) Please open this url in your browser to authorize lolcommits:\n\n"
|
45
|
-
puts request_token.authorize_url
|
46
|
-
print "\n2) Launching a local server to complete the OAuth authentication process:\n\n"
|
47
|
-
begin
|
48
|
-
server = WEBrick::HTTPServer.new Port: 3000
|
49
|
-
server.mount_proc '/', server_callback(server)
|
50
|
-
server.start
|
51
|
-
debug "Requesting Tumblr OAuth Token with verifier: #{@verifier}"
|
52
|
-
access_token = request_token.get_access_token(oauth_verifier: @verifier)
|
53
|
-
rescue Errno::EADDRINUSE
|
54
|
-
puts "\nERROR You have something running on port 3000. Please turn it off to complete the authorization process"
|
55
|
-
return
|
56
|
-
rescue OAuth::Unauthorized
|
57
|
-
puts "\nERROR: Tumblr OAuth verification faile!"
|
58
|
-
return
|
59
|
-
end
|
60
|
-
return unless access_token.token && access_token.secret
|
61
|
-
puts ''
|
62
|
-
puts '------------------------------'
|
63
|
-
puts 'Thanks! Tumblr Auth Succeeded'
|
64
|
-
puts '------------------------------'
|
65
|
-
|
66
|
-
{
|
67
|
-
'access_token' => access_token.token,
|
68
|
-
'secret' => access_token.secret
|
69
|
-
}
|
70
|
-
end
|
71
|
-
|
72
|
-
def configure_tumblr_name
|
73
|
-
print "\n3) What's your tumblr name? (i.e. 'http://[THIS PART HERE].tumblr.com'): "
|
74
|
-
{ 'tumblr_name' => STDIN.gets.strip }
|
75
|
-
end
|
76
|
-
|
77
|
-
def configured?
|
78
|
-
!configuration['enabled'].nil? &&
|
79
|
-
configuration['access_token'] &&
|
80
|
-
configuration['secret']
|
81
|
-
end
|
82
|
-
|
83
|
-
def client
|
84
|
-
@client ||= Tumblr.new(
|
85
|
-
consumer_key: TUMBLR_CONSUMER_KEY,
|
86
|
-
consumer_secret: TUMBLR_CONSUMER_SECRET,
|
87
|
-
oauth_token: configuration['access_token'],
|
88
|
-
oauth_token_secret: configuration['secret']
|
89
|
-
)
|
90
|
-
end
|
91
|
-
|
92
|
-
def oauth_consumer
|
93
|
-
@oauth_consumer ||= OAuth::Consumer.new(
|
94
|
-
TUMBLR_CONSUMER_KEY,
|
95
|
-
TUMBLR_CONSUMER_SECRET,
|
96
|
-
site: TUMBLR_API_ENDPOINT,
|
97
|
-
request_endpoint: TUMBLR_API_ENDPOINT,
|
98
|
-
http_method: :get
|
99
|
-
)
|
100
|
-
end
|
101
|
-
|
102
|
-
def config_with_default(key, default = nil)
|
103
|
-
if configuration[key]
|
104
|
-
configuration[key].strip.empty? ? default : configuration[key]
|
105
|
-
else
|
106
|
-
default
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
def self.name
|
111
|
-
'tumblr'
|
112
|
-
end
|
113
|
-
|
114
|
-
def self.runner_order
|
115
|
-
:postcapture
|
116
|
-
end
|
117
|
-
|
118
|
-
protected
|
119
|
-
|
120
|
-
def server_callback(server)
|
121
|
-
proc do |req, res|
|
122
|
-
q = CGI.parse req.request_uri.query
|
123
|
-
@verifier = q['oauth_verifier'][0]
|
124
|
-
server.stop
|
125
|
-
res.body = 'Lolcommits authorization complete!'
|
126
|
-
end
|
127
|
-
end
|
128
|
-
end
|
129
|
-
end
|
@@ -1,176 +0,0 @@
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
2
|
-
require 'yaml'
|
3
|
-
require 'oauth'
|
4
|
-
require 'simple_oauth'
|
5
|
-
require 'rest_client'
|
6
|
-
require 'addressable/uri'
|
7
|
-
|
8
|
-
module Lolcommits
|
9
|
-
class LolTwitter < Plugin
|
10
|
-
TWITTER_API_ENDPOINT = 'https://api.twitter.com'.freeze
|
11
|
-
TWITTER_CONSUMER_KEY = 'qc096dJJCxIiqDNUqEsqQ'.freeze
|
12
|
-
TWITTER_CONSUMER_SECRET = 'rvjNdtwSr1H0TvBvjpk6c4bvrNydHmmbvv7gXZQI'.freeze
|
13
|
-
TWITTER_RESERVED_MEDIA_CHARS = 24
|
14
|
-
TWITTER_RETRIES = 2
|
15
|
-
TWITTER_PIN_REGEX = /^\d{4,}$/ # 4 or more digits
|
16
|
-
DEFAULT_SUFFIX = '#lolcommits'.freeze
|
17
|
-
|
18
|
-
def run_postcapture
|
19
|
-
return unless valid_configuration?
|
20
|
-
tweet = build_tweet(runner.message)
|
21
|
-
|
22
|
-
attempts = 0
|
23
|
-
begin
|
24
|
-
attempts += 1
|
25
|
-
puts "Tweeting: #{tweet}"
|
26
|
-
debug "--> Tweeting! (attempt: #{attempts}, tweet length: #{tweet.length} chars)"
|
27
|
-
post_tweet(tweet, File.open(runner.main_image, 'r'))
|
28
|
-
rescue StandardError => e
|
29
|
-
debug "Tweet FAILED! #{e.class} - #{e.message}"
|
30
|
-
retry if attempts < TWITTER_RETRIES
|
31
|
-
puts "ERROR: Tweet FAILED! (after #{attempts} attempts) - #{e.message}"
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
def post_url
|
36
|
-
# TODO: this endpoint is deprecated, use the new approach instead
|
37
|
-
# https://dev.twitter.com/rest/reference/post/statuses/update_with_mediath_media
|
38
|
-
@post_url ||= TWITTER_API_ENDPOINT + '/1.1/statuses/update_with_media.json'
|
39
|
-
end
|
40
|
-
|
41
|
-
def post_tweet(status, media)
|
42
|
-
RestClient.post(
|
43
|
-
post_url,
|
44
|
-
{
|
45
|
-
'media[]' => media,
|
46
|
-
'status' => status
|
47
|
-
}, Authorization: oauth_header
|
48
|
-
)
|
49
|
-
end
|
50
|
-
|
51
|
-
def build_tweet(commit_message)
|
52
|
-
prefix = config_with_default('prefix', '')
|
53
|
-
suffix = " #{config_with_default('suffix', DEFAULT_SUFFIX)}"
|
54
|
-
prefix = "#{prefix} " unless prefix.empty?
|
55
|
-
|
56
|
-
available_commit_msg_size = max_tweet_size - (prefix.length + suffix.length)
|
57
|
-
if commit_message.length > available_commit_msg_size
|
58
|
-
commit_message = "#{commit_message[0..(available_commit_msg_size - 3)]}..."
|
59
|
-
end
|
60
|
-
|
61
|
-
"#{prefix}#{commit_message}#{suffix}"
|
62
|
-
end
|
63
|
-
|
64
|
-
def configure_options!
|
65
|
-
options = super
|
66
|
-
# ask user to configure tokens if enabling
|
67
|
-
if options['enabled']
|
68
|
-
auth_config = configure_auth!
|
69
|
-
return unless auth_config
|
70
|
-
options = options.merge(auth_config).merge(configure_prefix_suffix)
|
71
|
-
end
|
72
|
-
options
|
73
|
-
end
|
74
|
-
|
75
|
-
def configure_auth!
|
76
|
-
puts '---------------------------'
|
77
|
-
puts 'Need to grab twitter tokens'
|
78
|
-
puts '---------------------------'
|
79
|
-
|
80
|
-
request_token = oauth_consumer.get_request_token
|
81
|
-
rtoken = request_token.token
|
82
|
-
rsecret = request_token.secret
|
83
|
-
|
84
|
-
print "\n1) Please open this url in your browser to get a PIN for lolcommits:\n\n"
|
85
|
-
puts request_token.authorize_url
|
86
|
-
print "\n2) Enter PIN, then press enter: "
|
87
|
-
twitter_pin = STDIN.gets.strip.downcase.to_s
|
88
|
-
|
89
|
-
unless twitter_pin =~ TWITTER_PIN_REGEX
|
90
|
-
puts "\nERROR: '#{twitter_pin}' is not a valid Twitter Auth PIN"
|
91
|
-
return
|
92
|
-
end
|
93
|
-
|
94
|
-
begin
|
95
|
-
debug "Requesting Twitter OAuth Token with PIN: #{twitter_pin}"
|
96
|
-
OAuth::RequestToken.new(oauth_consumer, rtoken, rsecret)
|
97
|
-
access_token = request_token.get_access_token(oauth_verifier: twitter_pin)
|
98
|
-
rescue OAuth::Unauthorized
|
99
|
-
puts "\nERROR: Twitter PIN Auth FAILED!"
|
100
|
-
return
|
101
|
-
end
|
102
|
-
|
103
|
-
return unless access_token.token && access_token.secret
|
104
|
-
puts ''
|
105
|
-
puts '------------------------------'
|
106
|
-
puts 'Thanks! Twitter Auth Succeeded'
|
107
|
-
puts '------------------------------'
|
108
|
-
{
|
109
|
-
'access_token' => access_token.token,
|
110
|
-
'secret' => access_token.secret
|
111
|
-
}
|
112
|
-
end
|
113
|
-
|
114
|
-
def configure_prefix_suffix
|
115
|
-
print "\n3) Prefix all tweets with something? e.g. @user (leave blank for no prefix): "
|
116
|
-
prefix = STDIN.gets.strip
|
117
|
-
print "\n4) End all tweets with something? e.g. #hashtag (leave blank for default suffix #{DEFAULT_SUFFIX}): "
|
118
|
-
suffix = STDIN.gets.strip
|
119
|
-
|
120
|
-
config = {}
|
121
|
-
config['prefix'] = prefix unless prefix.empty?
|
122
|
-
config['suffix'] = suffix unless suffix.empty?
|
123
|
-
config
|
124
|
-
end
|
125
|
-
|
126
|
-
def configured?
|
127
|
-
!configuration['enabled'].nil? &&
|
128
|
-
configuration['access_token'] &&
|
129
|
-
configuration['secret']
|
130
|
-
end
|
131
|
-
|
132
|
-
def oauth_header
|
133
|
-
uri = Addressable::URI.parse(post_url)
|
134
|
-
SimpleOAuth::Header.new(:post, uri, {}, oauth_credentials)
|
135
|
-
end
|
136
|
-
|
137
|
-
def oauth_credentials
|
138
|
-
{
|
139
|
-
consumer_key: TWITTER_CONSUMER_KEY,
|
140
|
-
consumer_secret: TWITTER_CONSUMER_SECRET,
|
141
|
-
token: configuration['access_token'],
|
142
|
-
token_secret: configuration['secret']
|
143
|
-
}
|
144
|
-
end
|
145
|
-
|
146
|
-
def oauth_consumer
|
147
|
-
@oauth_consumer ||= OAuth::Consumer.new(
|
148
|
-
TWITTER_CONSUMER_KEY,
|
149
|
-
TWITTER_CONSUMER_SECRET,
|
150
|
-
site: TWITTER_API_ENDPOINT,
|
151
|
-
request_endpoint: TWITTER_API_ENDPOINT,
|
152
|
-
sign_in: true
|
153
|
-
)
|
154
|
-
end
|
155
|
-
|
156
|
-
def config_with_default(key, default = nil)
|
157
|
-
if configuration[key]
|
158
|
-
configuration[key].strip.empty? ? default : configuration[key]
|
159
|
-
else
|
160
|
-
default
|
161
|
-
end
|
162
|
-
end
|
163
|
-
|
164
|
-
def max_tweet_size
|
165
|
-
139 - TWITTER_RESERVED_MEDIA_CHARS
|
166
|
-
end
|
167
|
-
|
168
|
-
def self.name
|
169
|
-
'twitter'
|
170
|
-
end
|
171
|
-
|
172
|
-
def self.runner_order
|
173
|
-
:postcapture
|
174
|
-
end
|
175
|
-
end
|
176
|
-
end
|
@@ -1,85 +0,0 @@
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
2
|
-
require 'yammer'
|
3
|
-
require 'rest_client'
|
4
|
-
|
5
|
-
# https://developer.yammer.com/oauth2-quickstart/
|
6
|
-
YAMMER_CLIENT_ID = 'bgORyeKtnjZJSMwp8oln9g'.freeze
|
7
|
-
YAMMER_CLIENT_SECRET = 'oer2WdGzh74a5QBbW3INUxblHK3yg9KvCZmiBa2r0'.freeze
|
8
|
-
YAMMER_ACCESS_TOKEN_URL = 'https://www.yammer.com/oauth2/access_token.json'.freeze
|
9
|
-
YAMMER_RETRY_COUNT = 2
|
10
|
-
|
11
|
-
module Lolcommits
|
12
|
-
class LolYammer < Plugin
|
13
|
-
def self.name
|
14
|
-
'yammer'
|
15
|
-
end
|
16
|
-
|
17
|
-
def self.runner_order
|
18
|
-
:postcapture
|
19
|
-
end
|
20
|
-
|
21
|
-
def configured?
|
22
|
-
!configuration['access_token'].nil?
|
23
|
-
end
|
24
|
-
|
25
|
-
def configure_access_token
|
26
|
-
print "Open the URL below and copy the `code` param from query after redirected, enter it as `access_token`:\n"
|
27
|
-
print "https://www.yammer.com/dialog/oauth?client_id=#{YAMMER_CLIENT_ID}&response_type=code\n"
|
28
|
-
print 'Enter code param from the redirected URL, then press enter: '
|
29
|
-
code = STDIN.gets.to_s.strip
|
30
|
-
|
31
|
-
url = YAMMER_ACCESS_TOKEN_URL
|
32
|
-
debug "access_token url: #{url}"
|
33
|
-
params = {
|
34
|
-
'client_id' => YAMMER_CLIENT_ID,
|
35
|
-
'client_secret' => YAMMER_CLIENT_SECRET,
|
36
|
-
'code' => code
|
37
|
-
}
|
38
|
-
debug "params : #{params.inspect}"
|
39
|
-
result = JSON.parse(RestClient.post(url, params))
|
40
|
-
debug "response : #{result.inspect}"
|
41
|
-
# no need for 'return', last line is always the return value
|
42
|
-
{ 'access_token' => result['access_token']['token'] }
|
43
|
-
end
|
44
|
-
|
45
|
-
def configure_options!
|
46
|
-
options = super
|
47
|
-
# ask user to configure tokens if enabling
|
48
|
-
if options['enabled']
|
49
|
-
auth_config = configure_access_token
|
50
|
-
return unless auth_config
|
51
|
-
options.merge!(auth_config)
|
52
|
-
end
|
53
|
-
options
|
54
|
-
end
|
55
|
-
|
56
|
-
def run_postcapture
|
57
|
-
return unless valid_configuration?
|
58
|
-
|
59
|
-
commit_msg = runner.message
|
60
|
-
post = "#{commit_msg} #lolcommits"
|
61
|
-
puts "Yammer post: #{post}" unless runner.capture_stealth
|
62
|
-
|
63
|
-
Yammer.configure do |c|
|
64
|
-
c.client_id = YAMMER_CLIENT_ID
|
65
|
-
c.client_secret = YAMMER_CLIENT_SECRET
|
66
|
-
end
|
67
|
-
|
68
|
-
client = Yammer::Client.new(access_token: configuration['access_token'])
|
69
|
-
|
70
|
-
retries = YAMMER_RETRY_COUNT
|
71
|
-
begin
|
72
|
-
lolimage = File.new(runner.main_image)
|
73
|
-
response = client.create_message(post, attachment1: lolimage)
|
74
|
-
debug response.body.inspect
|
75
|
-
puts "\t--> Status posted!" if response
|
76
|
-
rescue => e
|
77
|
-
retries -= 1
|
78
|
-
retry if retries > 0
|
79
|
-
puts "Status not posted - #{e.message}"
|
80
|
-
puts 'Try running config again:'
|
81
|
-
puts "\tlolcommits --config --plugin yammer"
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|