Module: Geert

Defined in:
lib/geert.rb,
lib/geert/cli.rb,
lib/geert/model.rb,
lib/geert/project.rb,
lib/geert/association.rb

Defined Under Namespace

Classes: Association, CLI, Model, Project

Constant Summary collapse

VERSION =
File.read(File.dirname(__FILE__) + '/../VERSION').chomp

Class Method Summary collapse

Class Method Details

.migration(stdout, path, options = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/geert.rb', line 7

def self.migration(stdout, path, options = {})
  project = Project.new(path, options)
  if project.output.blank?
    stdout.puts "No new foreign keys found to be added. Lucky you!"
    exit
  end
  if options[:migration]
    File.open(project.filename, 'w') do |f|
      f.puts project.migration
    end
    stdout.puts "Generated migration #{project.filename}"
  else
    stdout.puts project.output
  end
end