Sha256: 1643c75fec7e0c24c19ec6dbd3db8b63c92e8b4f2b53bb952a00bde11bfabe98
Contents?: true
Size: 781 Bytes
Versions: 2
Compression:
Stored size: 781 Bytes
Contents
#! /usr/bin/env ruby # coding: utf-8 # # USAGE: linesub [options] str0 str1 files ... require "pp" require "optparse" require "rubygems" #gem "tefil" require "tefil.rb" ## option analysis OPTIONS = {} op = OptionParser.new op.on("-o" , "--overwrite" , "Overwrite."){ OPTIONS[:overwrite] = true} op.on("-g" , "--global" , "Globally substitute."){ OPTIONS[:global] = true} op.parse!(ARGV) OLD_PATTERN = ARGV.shift NEW_STR = ARGV.shift module TextFilter def self.process_stream(in_io, out_io) in_io.each do |line| if OPTIONS[:global] out_io.puts line.gsub(OLD_PATTERN, NEW_STR) else out_io.puts line.sub(OLD_PATTERN, NEW_STR) end end end end OPTIONS[:overwrite] ||= false TextFilter.run(ARGV, OPTIONS[:overwrite])
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
tefil-0.0.2 | bin/linesub |
tefil-0.0.1 | bin/linesub |