Method: ActiveFacts::Generators::Rails::Models#generated_file_exists

Defined in:
lib/activefacts/generators/rails/models.rb

#generated_file_exists(pathname) ⇒ Object



93
94
95
96
97
98
99
100
101
102
103
# File 'lib/activefacts/generators/rails/models.rb', line 93

def generated_file_exists pathname
  File.open(pathname, 'r') do |existing|
    first_lines = existing.read(1024)     # Make it possible to pass over a magic charset comment
    if first_lines.length == 0 or first_lines =~ %r{^#{HEADER}}
      return true
    end
  end
  return false    # File exists, but is not generated
rescue Errno::ENOENT
  return nil      # File does not exist
end