Class: Lolcommits::Plugin::Lolsrv

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

Instance Method Summary collapse

Instance Method Details

#configure_options!Hash

Prompts the user to configure text options.

Returns:

  • (Hash)

    of configured plugin options



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/lolcommits/plugin/lolsrv.rb', line 25

def configure_options!
  options = super
  if options[:enabled]
    print "server: "
    options.merge!(server: parse_user_input(gets.strip))
    puts '---------------------------------------------------------------'
    puts '  Lolsrv - Sync lolcommits to a remote server'
    puts ''
    puts '  Handle POST /uplol with these request params'
    puts ''
    puts '    `lol`  - captured lolcommit image file'
    puts '    `url`  - remote repository URL (with commit SHA appended)'
    puts '    `repo` - repository name e.g. mroth/lolcommits'
    puts '    `date` - UTC date time for the commit (ISO8601)'
    puts '    `sha`  - commit SHA'
    puts ''
    puts '  Handle GET /lols with JSON response'
    puts ''
    puts '  * Must return a JSON array of all lols already uploaded.'
    puts '    The commit `sha` is the only required JSON attribute.'
    puts ''
    puts '---------------------------------------------------------------'
  end
  options
end

#run_capture_ready(do_fork: true) ⇒ Integer

Post-capture hook, runs after lolcommits captures a snapshot.

Syncs lolcommit images to the remote server (forked and detached)

Returns:

  • (Integer)

    forked process id



59
60
61
62
63
64
65
66
# File 'lib/lolcommits/plugin/lolsrv.rb', line 59

def run_capture_ready(do_fork: true)
  if do_fork
    pid = fork { sync }
    Process.detach(pid)
  else
    sync
  end
end

#valid_configuration?Boolean

Returns true/false indicating if the plugin has been correctly configured. The ‘server` option must be set with a URL beginning with http(s)://

configured

Returns:

  • (Boolean)

    true/false indicating if plugin is correctly



16
17
18
# File 'lib/lolcommits/plugin/lolsrv.rb', line 16

def valid_configuration?
  !!(configuration[:server] =~ /^http(s)?:\/\//)
end