Module: Lolcommits::CLI::Fatals
- Includes:
- Lolcommits, Methadone::CLILogging
- Defined in:
- lib/lolcommits/cli/fatals.rb
Overview
Helper methods for failing on error conditions in the lolcommits CLI.
Constant Summary
Constants included from Lolcommits
Class Method Summary collapse
-
.die_if_no_valid_ffmpeg_installed! ⇒ Object
Die with an informative error message if ffmpeg is not installed.
-
.die_if_not_git_repo! ⇒ Object
If we are not in a git repo, we can’t do git related things! Die with an informative error message in that case.
-
.die_on_fatal_platform_conditions! ⇒ Object
Check for platform related conditions that could prevent lolcommits from working properly.
Class Method Details
.die_if_no_valid_ffmpeg_installed! ⇒ Object
Die with an informative error message if ffmpeg is not installed. This is only used for certain functions (such as animation), so only run this when you know the user wants to perform one of them.
58 59 60 61 62 63 |
# File 'lib/lolcommits/cli/fatals.rb', line 58 def self.die_if_no_valid_ffmpeg_installed! unless Platform.valid_ffmpeg_installed? fatal 'FATAL: ffmpeg does not appear to be properly installed!' exit 1 end end |
.die_if_not_git_repo! ⇒ Object
If we are not in a git repo, we can’t do git related things! Die with an informative error message in that case.
67 68 69 70 71 72 73 74 |
# File 'lib/lolcommits/cli/fatals.rb', line 67 def self.die_if_not_git_repo! debug 'Checking for valid git repo' Git.open('.') # FIXME: should be extracted to GitInfo class rescue ArgumentError # ruby-git throws an argument error if path isnt for a valid git repo. fatal "Erm? Can't do that since we're not in a valid git repository!" exit 1 end |
.die_on_fatal_platform_conditions! ⇒ Object
Check for platform related conditions that could prevent lolcommits from working properly.
Die with an informative error message if any occur.
16 17 18 19 20 21 22 23 24 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 50 51 52 53 |
# File 'lib/lolcommits/cli/fatals.rb', line 16 def self.die_on_fatal_platform_conditions! # make sure the capture binaries are in a good state if Platform.platform_mac? %w(imagesnap videosnap).each do |executable| next if File.executable? File.join(Configuration::LOLCOMMITS_ROOT, 'vendor', 'ext', executable, executable) fatal "Couldn't properly execute #{executable} for some reason, "\ 'please file a bug?!' exit 1 end elsif Platform.platform_linux? unless Platform.command_which('mplayer') fatal "Couldn't find mplayer in your PATH!" exit 1 end end # make sure we can find the default font unless File.readable? Lolcommits::Loltext::DEFAULT_FONT_PATH fatal "Couldn't properly read Impact font from gem package, "\ 'please file a bug?!' exit 1 end # make sure imagemagick is around and good to go unless Platform.valid_imagemagick_installed? fatal 'FATAL: ImageMagick does not appear to be properly installed!'\ '(or version is too old)' exit 1 end # check for a error condition with git config affecting ruby-git if Platform.git_config_color_always? fatal 'Due to a bug in the ruby-git library, git config for color.ui'\ " cannot be set to 'always'." fatal "Try setting it to 'auto' instead!" exit 1 end end |