Class: Lolcommits::Plugin::LolFlowdock
- Inherits:
-
Base
- Object
- Base
- Lolcommits::Plugin::LolFlowdock
show all
- Defined in:
- lib/lolcommits/plugin/lol_flowdock.rb
Constant Summary
collapse
- ENDPOINT_URL =
'api.flowdock.com/flows/'.freeze
- RETRY_COUNT =
2
Instance Attribute Summary
Attributes inherited from Base
#config, #options, #runner
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
#configuration, #configured_and_enabled?, #debug, #enabled?, #execute_capture_ready, #execute_post_capture, #execute_pre_capture, #initialize, #log_error, #parse_user_input, #print, #puts, #run_post_capture, #run_pre_capture, #valid_configuration?
Class Method Details
.name ⇒ Object
9
10
11
|
# File 'lib/lolcommits/plugin/lol_flowdock.rb', line 9
def self.name
'flowdock'
end
|
.runner_order ⇒ Object
13
14
15
|
# File 'lib/lolcommits/plugin/lol_flowdock.rb', line 13
def self.runner_order
:capture_ready
end
|
Instance Method Details
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/lolcommits/plugin/lol_flowdock.rb', line 21
def configure
print "Open the URL below and issue a token for your user (Personal API token):\n"
print "https://flowdock.com/account/tokens\n"
print "Enter the generated token below, then press enter: \n"
code = gets.to_s.strip
print "Enter the machine name of the flow you want to post to from this repo.\n"
print "Go to https://www.flowdock.com/account and click Flows, then click the flow, then get the machine name from the URL:\n"
flow = gets.to_s.strip.downcase
print "Enter the name of the organization for this Flowdock account.\n"
organization = gets.to_s.strip.downcase
{
'access_token' => code,
'flow' => flow,
'organization' => organization
}
end
|
39
40
41
42
43
44
45
46
|
# File 'lib/lolcommits/plugin/lol_flowdock.rb', line 39
def configure_options!
options = super
if options['enabled']
config = configure
options.merge!(config)
end
options
end
|
17
18
19
|
# File 'lib/lolcommits/plugin/lol_flowdock.rb', line 17
def configured?
!configuration['access_token'].nil?
end
|
#run_capture_ready ⇒ Object
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
# File 'lib/lolcommits/plugin/lol_flowdock.rb', line 48
def run_capture_ready
retries = RETRY_COUNT
begin
endpoint = 'https://' + configuration['access_token'] + '@' + ENDPOINT_URL + configuration['organization'] + '/' + configuration['flow'] + '/messages'
response = RestClient.post(
endpoint,
event: 'file',
content: File.new(runner.main_image)
)
debug response
rescue StandardError => e
retries -= 1
retry if retries > 0
puts "Posting to flowdock failed - #{e.message}"
puts 'Try running config again:'
puts "\tlolcommits --config --plugin flowdock"
end
end
|