Sha256: bbd964e1a7203eb02a99efbd2f8a8618140cc20d3503c03ba80872c7a5eb5463

Contents?: true

Size: 884 Bytes

Versions: 1

Compression:

Stored size: 884 Bytes

Contents

#! /usr/bin/env ruby
# coding: utf-8
#
# USAGE: textfilter [options] str0 str1 files ...

require "pp"
require "optparse"
require "rubygems"
gem "tefil"
require "tefil.rb"

## option analysis
OPTIONS = {}
op = OptionParser.new
op.on("-s"    , "--sort"    , "Sort."){    OPTIONS[:sort] = true}
op.on("-r"    , "--randomize" , "Randomize."){    OPTIONS[:random] = true}
op.on("-o"    , "--overwrite"    , "Overwrite."){    OPTIONS[:overwrite] = true}
op.parse!(ARGV)

module Tefil
  def self.process_stream(in_io, out_io)
    in_io.each do |line|
      if OPTIONS[:sort]
        out_io.puts line.chomp.split(//).sort.join('')
      end
      if OPTIONS[:random]
        out_io.puts line.chomp.split(//).sort_by{rand}.join('')
      end
    end
  end
end

OPTIONS[:overwrite] ||= false


#pp OPTIONS[:overwrite]
#Tefil.run(ARGV, OPTIONS[:overwrite])
Tefil.run(ARGV, OPTIONS[:overwrite])

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tefil-0.0.3 bin/lineedit