From 8858ded6a8c6e4e8e1b0babdf347588cd5a6f06e Mon Sep 17 00:00:00 2001 From: robert Date: Fri, 6 Oct 2017 11:31:53 +0200 Subject: add play_motion_picture.rb --- lib/pry/commands/easter_eggs.rb | 19 ------------------- lib/pry/commands/play_motion_picture.rb | 27 +++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 19 deletions(-) create mode 100644 lib/pry/commands/play_motion_picture.rb diff --git a/lib/pry/commands/easter_eggs.rb b/lib/pry/commands/easter_eggs.rb index f5c27e17..e59e28c1 100644 --- a/lib/pry/commands/easter_eggs.rb +++ b/lib/pry/commands/easter_eggs.rb @@ -1,14 +1,6 @@ # coding: utf-8 class Pry Pry::Commands.instance_eval do - MOTION_PICTURES = [ - 'https://www.youtube.com/watch?v=nOSuObRNBUA', - 'https://www.youtube.com/watch?v=svJvT6ruolA', - 'https://www.youtube.com/watch?v=l-L3zeCNzH8', - 'https://www.youtube.com/watch?v=QrY9eHkXTa4', - 'https://www.youtube.com/watch?v=VhdHwphvhxU' - ] - command "nyan-cat", "", :requires_gem => ["nyancat"] do run ".nyancat" end @@ -18,17 +10,6 @@ class Pry run "show-input" end - # TODO: unicode aliases, Linux/Windows support, etc. - command "play-motion-picture", "" do - if _pry_.h.windows? - else - syscall = _pry_.config.system - syscall.call _pry_.output, "%s %s" % [_pry_.config.media_player, MOTION_PICTURES.sample].map{|shellinput| - Shellwords.shellescape(shellinput) - } - end - end - command "get-naked", "" do txt = %{ -- diff --git a/lib/pry/commands/play_motion_picture.rb b/lib/pry/commands/play_motion_picture.rb new file mode 100644 index 00000000..06e5d477 --- /dev/null +++ b/lib/pry/commands/play_motion_picture.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true +class Pry::Command::PlayMotionPicture < Pry::ClassCommand + MOTION_PICTURES = [ + 'https://www.youtube.com/watch?v=nOSuObRNBUA', + 'https://www.youtube.com/watch?v=svJvT6ruolA', + 'https://www.youtube.com/watch?v=l-L3zeCNzH8', + 'https://www.youtube.com/watch?v=QrY9eHkXTa4', + 'https://www.youtube.com/watch?v=VhdHwphvhxU', + 'https://www.youtube.com/watch?v=mcTKcMzembk', + 'https://www.youtube.com/watch?v=PGYAAsHT4QE' + ].freeze + + match 'play-motion-picture' + group 'Misc' + description 'Bored? Play a motion picture.' + + def process + if _pry_.h.windows? + else + syscall = _pry_.config.system + syscall.call _pry_.output, "%s %s" % [_pry_.config.media_player, MOTION_PICTURES.sample].map{|input| + Shellwords.shellescape(input) + } + end + end + Pry::Commands.add_command(self) +end -- cgit v1.2.1