Class: Modularity::Migrator

Inherits:
Object
  • Object
show all
Defined in:
lib/modularity/migrator.rb

Class Method Summary collapse

Class Method Details

.migrate(old_path) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/modularity/migrator.rb', line 9

def migrate(old_path)
  old_path = File.expand_path(old_path)
  new_path = fix_filename(old_path)
  rename(old_path, new_path) unless old_path == new_path
  old_code = File.read(new_path)
  new_code = fix_code(old_code)
  rewrite_file(new_path, new_code) unless old_code == new_code
  puts "Migrated #{old_path}"
  `ruby -c #{new_path}`
  new_code
end