Sha256: 9466e76209f21c48f9ba3529e979b2031cec00d5007af819474197b866de48e5
Contents?: true
Size: 831 Bytes
Versions: 1
Compression:
Stored size: 831 Bytes
Contents
require "git/gsub/version" require 'shellwords' module Git module Gsub def self.run case ARGV.first when '-v', '--version' version else gsub *ARGV end end def self.version puts Git::Gsub::VERSION end def self.gsub *args from, to, path, = args.map do |arg| Shellwords.escape arg if arg end if to.nil? abort "No argument to gsub was given" end target_files = (`git grep -l #{from} #{path}`).each_line.map(&:chomp).join ' ' if system_support_gsed? system %|gsed -i "" s/#{from}/#{to}/g #{target_files}| else system %|sed -i "" -e s/#{from}/#{to}/g #{target_files}| end end private def self.system_support_gsed? `which gsed` $?.success? end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
git-gsub-0.0.2 | lib/git/gsub.rb |