Sha256: fdf15981f385304f6ab39b41d514e2c918306f5a1cc73c4e36f285c94e51f88f
Contents?: true
Size: 1021 Bytes
Versions: 6
Compression:
Stored size: 1021 Bytes
Contents
require 'bcdatabase/commands' module Bcdatabase::Commands class Encrypt def initialize(inputfile=nil, outputfile=nil) @input = (Pathname.new(inputfile) if inputfile) @output = (Pathname.new(outputfile) if outputfile) end def run begin # try to preserve the order by replacing everything using regexes contents = inio.read contents.gsub!(/\bpassword:.*?$/) { |line| "epassword: #{Bcdatabase.encrypt(YAML.load(line)['password'])}" } outio.write(contents) ensure @inio.close if @close_in && @inio @outio.close if @close_out && @outio end end private def inio @inio ||= if @input @close_in = true @input.open('r') else $stdin end end def outio @outio ||= if @output @output.dirname.mkpath @close_out = true @output.open('w') else $stdout end end end end
Version data entries
6 entries across 6 versions & 1 rubygems