Class: ActiveMigration::SpellingFix

Inherits:
Object
  • Object
show all
Defined in:
lib/active_migration/spelling_fix.rb

Instance Method Summary collapse

Constructor Details

#initialize(url) ⇒ SpellingFix

Returns a new instance of SpellingFix.



5
6
7
# File 'lib/active_migration/spelling_fix.rb', line 5

def initialize(url)
  @rules = YAML::load(File.open(url))
end

Instance Method Details

#fix!(term) ⇒ Object



9
10
11
12
13
14
15
16
# File 'lib/active_migration/spelling_fix.rb', line 9

def fix!(term)
  return term if term.nil? || term.empty?
  @rules.each do |before,after|
    term.gsub! before, after
  end
  
  term
end