Class: Lolcommits::Plugin::Flowdock

Inherits:
Base
  • Object
show all
Defined in:
lib/lolcommits/plugin/flowdock.rb

Instance Method Summary collapse

Instance Method Details

#configure_options!Hash

Prompts the user to configure plugin options. Options are enabled (true/false), a Flowdock Personal API token, and the Flowdock organization and flow names.

Returns:

  • (Hash)

    a hash of configured plugin options



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/lolcommits/plugin/flowdock.rb', line 19

def configure_options!
  options = super
  if options[:enabled]
    puts "\nCopy (or create) your Flowdock personal API token (paste it below)"
    open_url("https://flowdock.com/account/tokens")
    print "API token: "
    access_token = gets.strip
    flowdock.access_token = access_token

    organization = configure_organization
    flow         = configure_flow
    raise Interrupt unless flow && organization

    options.merge!(
      access_token: access_token,
      flow: flow,
      organization: organization
    )
  end

  options
end

#run_capture_readyHash, Nil

Post-capture hook, runs after lolcommits captures a snapshot. Posts the lolcommit image (as a file message) to the configured Flowdock flow.

Returns:

  • (Hash)

    JSON response object (newly created message hash)

  • (Nil)

    if an error occurs



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/lolcommits/plugin/flowdock.rb', line 49

def run_capture_ready
  print "Posting to Flowdock ... "
  message = flowdock.create_message(
    organization: configuration[:organization],
    flow: configuration[:flow],
    params: {
      event: 'file',
      content: File.new(runner.lolcommit_path),
      tags: %w(lolcommits)
    }
  )
  print "done!\n"
  message
rescue Lolcommits::Flowdock::RequestFailed => e
  print "failed :( (try again with --debug)\n"
  log_error(e, "ERROR: POST to Flowdock FAILED - #{e.message}")
  nil
end