diff options
author | robert <r@newton.osaka> | 2017-10-06 11:31:53 +0200 |
---|---|---|
committer | robert <r@newton.osaka> | 2017-10-06 11:48:46 +0200 |
commit | 8858ded6a8c6e4e8e1b0babdf347588cd5a6f06e (patch) | |
tree | af9885555c3e13eeb814fabe662b8ba86d7bc781 | |
parent | c2fff6499b7961cfe9bdb8f7d1c55483c050a54f (diff) | |
download | pry-eastereggs/music.tar.gz |
add play_motion_picture.rbeastereggs/music
-rw-r--r-- | lib/pry/commands/easter_eggs.rb | 19 | ||||
-rw-r--r-- | lib/pry/commands/play_motion_picture.rb | 27 |
2 files changed, 27 insertions, 19 deletions
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 |