Sha256: b69285375fe9b41d642b6f1e4b4d3b58b2274e06c735b22973b199d6c29038ca
Contents?: true
Size: 771 Bytes
Versions: 1
Compression:
Stored size: 771 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 Tefil 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 Tefil.run(ARGV, OPTIONS[:overwrite])
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
tefil-0.0.3 | bin/linesub |