Class: Lolcommits::Plugin::Lolsrv
- Inherits:
-
Base
- Object
- Base
- Lolcommits::Plugin::Lolsrv
- Defined in:
- lib/lolcommits/plugin/lolsrv.rb
Instance Method Summary collapse
-
#configure_options! ⇒ Hash
Prompts the user to configure text options.
-
#run_capture_ready(do_fork: true) ⇒ Integer
Post-capture hook, runs after lolcommits captures a snapshot.
-
#valid_configuration? ⇒ Boolean
Returns true/false indicating if the plugin has been correctly configured.
Instance Method Details
#configure_options! ⇒ Hash
Prompts the user to configure text options.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/lolcommits/plugin/lolsrv.rb', line 27 def = super if [:enabled] print "server: " .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 file' puts ' `url` - remote repository URL (with commit SHA appended)' puts ' `repo` - repository name e.g. lolcommits/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 end |
#run_capture_ready(do_fork: true) ⇒ Integer
Post-capture hook, runs after lolcommits captures a snapshot. Syncs lolcommits to the remote server (forked and detached)
60 61 62 63 64 65 66 67 |
# File 'lib/lolcommits/plugin/lolsrv.rb', line 60 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
18 19 20 |
# File 'lib/lolcommits/plugin/lolsrv.rb', line 18 def valid_configuration? !!(configuration[:server] =~ /^http(s)?:\/\//) end |