lib/xcmultilingual/parser.rb in xcmultilingual-0.3.0 vs lib/xcmultilingual/parser.rb in xcmultilingual-0.3.1
- old
+ new
@@ -19,19 +19,15 @@
file_path = File.expand_path(file_path)
# bundle
if match = file_path.match(/(?<dir>(?<name>[^\/]*).bundle)/)
bundle_name = match["name"]
- relative_path = file_path[0, match.end("dir")]
-
- relative_path = create_relative_path(destination_path, relative_path)
else
bundle_name = nil
- relative_path = nil
end
- bundles[bundle_name] = {:relative_path => relative_path, :name => bundle_name, :tables => {}} unless bundles[bundle_name]
+ bundles[bundle_name] = {:name => bundle_name, :tables => {}} unless bundles[bundle_name]
# name
name = File.basename(file_path, ".strings")
bundles[bundle_name][:tables][name] = Set.new unless bundles[bundle_name][:tables].keys.include?(name)
@@ -45,11 +41,11 @@
end
end
bundle_data = []
bundles.each do |k, v|
- bundle = Bundle.new(v[:relative_path], v[:name], [])
+ bundle = Bundle.new(v[:name], [])
v[:tables].each do |o, p|
table = Table.new(o, p.to_a)
bundle.tables << table
end
@@ -62,33 +58,9 @@
bundle_data
end
private
-
- def create_relative_path(dest_path, src_path)
- dest_split = dest_path.split("/")
- src_split = src_path.split("/")
-
- src_extras = []
- src_split.each_with_index do |val, idx|
- next if val == dest_split[idx]
- src_extras << val
- end
-
- dest_extras = []
- dest_split.each_with_index do |val, idx|
- next if val == src_split[idx]
- dest_extras << val
- end
-
- prefix = ""
- (dest_extras.size - 1).times do |idx|
- prefix += "../"
- end
-
- prefix + src_extras.join("/")
- end
def find_key(line)
if match = line.match(/^\"(.*)\"\s*=\s*\"(.*)\"\;$/)
return match[1]
end