Class: Lolcommits::LolFlowdock
- Inherits:
-
Plugin
- Object
- Plugin
- Lolcommits::LolFlowdock
show all
- Defined in:
- lib/lolcommits/plugins/lol_flowdock.rb
Constant Summary
collapse
- ENDPOINT_URL =
'api.flowdock.com/flows/'.freeze
- RETRY_COUNT =
2
Instance Attribute Summary
Attributes inherited from Plugin
#options, #runner
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Plugin
#configuration, #debug, #enabled?, #execute_postcapture, #execute_precapture, #initialize, #log_error, #parse_user_input, #puts, #run_precapture, #valid_configuration?
Class Method Details
.name ⇒ Object
9
10
11
|
# File 'lib/lolcommits/plugins/lol_flowdock.rb', line 9
def self.name
'flowdock'
end
|
.runner_order ⇒ Object
13
14
15
|
# File 'lib/lolcommits/plugins/lol_flowdock.rb', line 13
def self.runner_order
:postcapture
end
|
Instance Method Details
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/lolcommits/plugins/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 = STDIN.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 = STDIN.gets.to_s.strip.downcase
print "Enter the name of the organization for this Flowdock account.\n"
organization = STDIN.gets.to_s.strip.downcase
{
'access_token' => code,
'flow' => flow,
'organization' => organization
}
end
|
39
40
41
42
43
44
45
46
|
# File 'lib/lolcommits/plugins/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/plugins/lol_flowdock.rb', line 17
def configured?
!configuration['access_token'].nil?
end
|
#run_postcapture ⇒ Object
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
# File 'lib/lolcommits/plugins/lol_flowdock.rb', line 48
def run_postcapture
return unless valid_configuration?
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 => 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
|