class SmartlingRails::SmartlingFile

Attributes

file_contents[RW]
locale_codes[RW]

Public Class Methods

new(file_contents, locale_codes) click to toggle source
# File lib/smartling_rails/models/smartling_file.rb, line 15
def initialize(file_contents, locale_codes)
  @file_contents = file_contents
  @locale_codes = locale_codes
end

Public Instance Methods

fix_file_issues() click to toggle source
# File lib/smartling_rails/models/smartling_file.rb, line 20
def fix_file_issues
  puts 'Fixing Issues:'
  fix_tab_size
  fix_space_after_tree_node
  fix_first_line_dashes
  fix_locale_root_node
end
fix_first_line_dashes() click to toggle source
# File lib/smartling_rails/models/smartling_file.rb, line 38
def fix_first_line_dashes
  return unless @file_contents.lines.first.match(/---\n/)
  puts '  remove "---" from first line'
  @file_contents.sub!(/---\n/, '')
  puts '  yes, replaced dashes'
end
fix_locale_root_node() click to toggle source
# File lib/smartling_rails/models/smartling_file.rb, line 45
def fix_locale_root_node
  puts "  converting smartling locale code to CB locale code from #{locale_codes['smartling']} to #{locale_codes['custom']}"
  @file_contents.sub!(locale_codes['smartling'], locale_codes['custom'])
end
fix_space_after_tree_node() click to toggle source
# File lib/smartling_rails/models/smartling_file.rb, line 33
def fix_space_after_tree_node
  puts '  removing space after branch root : \\n to :\\n'
  @file_contents.gsub!(/: \n/, ":\n")
end
fix_tab_size() click to toggle source
# File lib/smartling_rails/models/smartling_file.rb, line 28
def fix_tab_size
  puts '  fixing tabs from 4 spaces to 2 space'
  @file_contents.gsub!('    ', '  ')
end
print_contents() click to toggle source