Class: Geert::Project

Inherits:
Object
  • Object
show all
Defined in:
lib/geert/project.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, options = {}) ⇒ Project

Returns a new instance of Project.



7
8
9
# File 'lib/geert/project.rb', line 7

def initialize(path, options = {})
  @path, @options = path, options
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



5
6
7
# File 'lib/geert/project.rb', line 5

def options
  @options
end

#pathObject (readonly)

Returns the value of attribute path.



5
6
7
# File 'lib/geert/project.rb', line 5

def path
  @path
end

Instance Method Details

#filenameObject



25
26
27
# File 'lib/geert/project.rb', line 25

def filename
  @filename ||= File.join(path, "db", "migrate", Time.now.strftime("%Y%m%d%H%M%S") + "_" + migration_name + ".rb")
end

#migrationObject



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/geert/project.rb', line 11

def migration
  <<-MIGRATION.gsub(/^ {6}/,'')
  class #{migration_name.camelize} < ActiveRecord::Migration
    def self.up
  #{cleanup migration_up}
    end

    def self.down
  #{cleanup migration_down}
    end
  end
  MIGRATION
end

#outputObject



29
30
31
# File 'lib/geert/project.rb', line 29

def output
  models.map(&:output).flatten.compact
end