Class: Lolcommits::DotCom
- Inherits:
-
Plugin
- Object
- Plugin
- Lolcommits::DotCom
show all
- Defined in:
- lib/lolcommits/plugins/dot_com.rb
Constant Summary
collapse
- BASE_URL =
'http://lolcommits-dot-com.herokuapp.com'.freeze
Instance Attribute Summary
Attributes inherited from Plugin
#options, #runner
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Plugin
#configuration, #configure_options!, #debug, #enabled?, #execute_postcapture, #execute_precapture, #log_error, #parse_user_input, #puts, #run_precapture, #valid_configuration?
Constructor Details
#initialize(runner) ⇒ DotCom
8
9
10
11
|
# File 'lib/lolcommits/plugins/dot_com.rb', line 8
def initialize(runner)
super
options.concat(%w(api_key api_secret repo_id))
end
|
Class Method Details
.name ⇒ Object
43
44
45
|
# File 'lib/lolcommits/plugins/dot_com.rb', line 43
def self.name
'dot_com'
end
|
.runner_order ⇒ Object
47
48
49
|
# File 'lib/lolcommits/plugins/dot_com.rb', line 47
def self.runner_order
:postcapture
end
|
Instance Method Details
36
37
38
39
40
41
|
# File 'lib/lolcommits/plugins/dot_com.rb', line 36
def configured?
!configuration['enabled'].nil? &&
configuration['api_key'] &&
configuration['api_secret'] &&
configuration['repo_id']
end
|
#run_postcapture ⇒ Object
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/lolcommits/plugins/dot_com.rb', line 13
def run_postcapture
return unless valid_configuration?
t = Time.now.to_i.to_s
HTTMultiParty.post(
"#{BASE_URL}/git_commits.json",
:body => {
:git_commit => {
:sha => runner.sha,
:repo_external_id => configuration['repo_id'],
:image => File.open(runner.main_image),
:raw => File.open(runner.snapshot_loc)
},
:key => configuration['api_key'],
:t => t,
:token => Digest::SHA1.hexdigest(configuration['api_secret'] + t)
}
)
rescue => e
log_error(e, "ERROR: HTTMultiParty POST FAILED #{e.class} - #{e.message}")
end
|