Class: Lolcommits::Plugin::DotCom
- Inherits:
-
Base
- Object
- Base
- Lolcommits::Plugin::DotCom
show all
- Defined in:
- lib/lolcommits/plugin/dot_com.rb
Constant Summary
collapse
- BASE_URL =
'http://lolcommits-dot-com.herokuapp.com'.freeze
Instance Attribute Summary
Attributes inherited from Base
#options, #runner
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
#configuration, #configure_options!, #debug, #enabled?, #execute_postcapture, #execute_precapture, #log_error, #parse_user_input, #puts, #run_precapture, #valid_configuration?
Constructor Details
#initialize(runner) ⇒ DotCom
Returns a new instance of DotCom.
8
9
10
11
|
# File 'lib/lolcommits/plugin/dot_com.rb', line 8
def initialize(runner)
super
options.concat(%w(api_key api_secret repo_id))
end
|
Class Method Details
.name ⇒ Object
41
42
43
|
# File 'lib/lolcommits/plugin/dot_com.rb', line 41
def self.name
'dot_com'
end
|
.runner_order ⇒ Object
45
46
47
|
# File 'lib/lolcommits/plugin/dot_com.rb', line 45
def self.runner_order
:postcapture
end
|
Instance Method Details
34
35
36
37
38
39
|
# File 'lib/lolcommits/plugin/dot_com.rb', line 34
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
|
# File 'lib/lolcommits/plugin/dot_com.rb', line 13
def run_postcapture
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
|