Sha256: d9545608d9ba86e4731bccdff879d1d55cd25bf8d3a0ec65b05c6cbbe4ecd800

Contents?: true

Size: 899 Bytes

Versions: 2

Compression:

Stored size: 899 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 TextFilter
  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]
#TextFilter.run(ARGV, OPTIONS[:overwrite])
TextFilter.run(ARGV, OPTIONS[:overwrite])

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
tefil-0.0.2 bin/lineedit
tefil-0.0.1 bin/lineedit