ctrl+shift+p filters: :st2 :st3 :win :osx :linux
Browse

Ruby Pipe Text Processing

by grundprinzip ALL

RubyPipe allows you to pipe selected text in Sublime Text 2 or 3 through Ruby

Details

  • 2013.06.11.19.23.21
  • github.​com
  • github.​com
  • 11 years ago
  • 2 hours ago
  • 11 years ago

Installs

  • Total 2K
  • Win 944
  • Mac 596
  • Linux 280
Oct 12 Oct 11 Oct 10 Oct 9 Oct 8 Oct 7 Oct 6 Oct 5 Oct 4 Oct 3 Oct 2 Oct 1 Sep 30 Sep 29 Sep 28 Sep 27 Sep 26 Sep 25 Sep 24 Sep 23 Sep 22 Sep 21 Sep 20 Sep 19 Sep 18 Sep 17 Sep 16 Sep 15 Sep 14 Sep 13 Sep 12 Sep 11 Sep 10 Sep 9 Sep 8 Sep 7 Sep 6 Sep 5 Sep 4 Sep 3 Sep 2 Sep 1 Aug 31 Aug 30 Aug 29
Windows 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0
Mac 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Linux 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

Readme

Source
raw.​githubusercontent.​com

RubyPipe

RubyPipe allows you to pipe selected text in Sublime Text 2 or 3 through Ruby.

To run the command open the command palette and search for Ruby. The two choices are: “Pipe Selection with Ruby” and “Pipe Selection with Ruby (Replace)”. Both will perform similar actions but the latter will replace the selected text with the ouput of the Ruby command.

For example consider the following text:

This is a test and I want to know how many words have more than three characters.

Select the text and than run “Pipe Selection with Ruby” and enter the following Ruby code in the input panel.

$_.split(" ").select{|w| w.size > 3 }.size

After executing this will bring up a message box showing: 11. Other possibilities for this plugin are to use Ruby to quickly reformat text by using ruby to process the input.

In your Ruby script the content of the selection is available in all of the following variables: $_, $select, or $text.