Class: MaskSQL::Converter
- Inherits:
-
Object
- Object
- MaskSQL::Converter
- Defined in:
- lib/mask_sql/converter.rb
Instance Method Summary collapse
-
#initialize(options) ⇒ Converter
constructor
A new instance of Converter.
- #mask ⇒ Object
Constructor Details
#initialize(options) ⇒ Converter
Returns a new instance of Converter.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/mask_sql/converter.rb', line 7 def initialize() = config = YAML.load_file([:config]) @mark = config['mark'] @targets = config['targets'] if [:insert].nil? && [:replace].nil? && [:copy].nil? [:insert] = true [:replace] = true [:copy] = true end @matched_copy = {} end |
Instance Method Details
#mask ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/mask_sql/converter.rb', line 23 def mask encoding = NKF.guess(File.read([:in])).name File.open([:out], "w:#{encoding}") do |out_file| File.open([:in], "r:#{encoding}") do |in_file| in_file.each_line do |line| @matched_copy.empty? ? write_line(line, out_file) : write_copy_line(line, out_file) end end end end |