Class: Lolcommits::Installation
- Inherits:
-
Object
- Object
- Lolcommits::Installation
- Defined in:
- lib/lolcommits/installation.rb
Overview
Methods to handle enabling and disabling of lolcommits
Class Method Summary collapse
- .backend ⇒ Object
-
.do_disable ⇒ Object
IF –DISABLE, DO DISABLE.
-
.do_enable(options = {}) ⇒ Object
IF –ENABLE, DO ENABLE.
-
.extract_capture_args(options) ⇒ String
Extract any command line capture args from the parsed options hash, will be appended to the capture command within the commit hook script.
Class Method Details
.backend ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/lolcommits/installation.rb', line 8 def self.backend if GitInfo.repo_root? InstallationGit elsif MercurialInfo.repo_root? InstallationMercurial else fatal "You don't appear to be in the base directory of a supported vcs project." exit 1 end end |
.do_disable ⇒ Object
IF –DISABLE, DO DISABLE
36 37 38 |
# File 'lib/lolcommits/installation.rb', line 36 def self.do_disable backend.do_disable end |
.do_enable(options = {}) ⇒ Object
IF –ENABLE, DO ENABLE
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/lolcommits/installation.rb', line 22 def self.do_enable( = {}) capture_args = extract_capture_args() path = backend.do_enable(capture_args) info 'installed lolcommit hook to:' info " -> #{File.(path)}" info '(to remove later, you can use: lolcommits --disable)' # we dont symlink, but rather install a small stub that calls the one from path # that way, as gem version changes, script updates even if new file thus breaking symlink end |
.extract_capture_args(options) ⇒ String
Extract any command line capture args from the parsed options hash, will be appended to the capture command within the commit hook script
44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/lolcommits/installation.rb', line 44 def self.extract_capture_args() .map do |k, v| next unless %w(device animate delay stealth fork).include?(k) if k == 'device' "--device '#{v}'" else "--#{k}#{v == true ? '' : " #{v}"}" end end.compact.join(' ') end |