class BabelishRnc::Php2CSV
Public Class Methods
new(args = {:filenames => []})
click to toggle source
Calls superclass method
BabelishRnc::Base2Csv::new
# File lib/babelish_rnc/php2csv.rb, line 4 def initialize(args = {:filenames => []}) super(args) end
Public Instance Methods
load_strings(strings_filename)
click to toggle source
# File lib/babelish_rnc/php2csv.rb, line 8 def load_strings(strings_filename) strings = {} File.open(strings_filename, 'r') do |strings_file| strings_file.read.each_line do |line| parsed_line = parse_dotstrings_line(line) unless parsed_line.nil? converted_line = parse_dotstrings_line(line) strings.merge!(converted_line) unless converted_line.nil? end end end strings end
parse_dotstrings_line(line)
click to toggle source
# File lib/babelish_rnc/php2csv.rb, line 22 def parse_dotstrings_line(line) line.strip! if line[0] != ?# && line[0] != ?= m = line.match(/^[\$].*\[[\"\'](.*)[\"\']\]\s*=\s*[\"\'](.*)[\"\'];/) return {m[1] => m[2]} unless m.nil? end end