Class: DatabaseSchemaOwnership::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/database_schema_ownership/runner.rb

Overview

:nodoc

Constant Summary collapse

RUBY_SCHEMA_PATH =
"db/schema.rb"
SQL_SCHEMA_PATH =
"db/structure.sql"
OWNERSHIP_PATH =
"db/database_schema_ownership"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(schema_path = nil, folder_path = OWNERSHIP_PATH) ⇒ Runner

Returns a new instance of Runner.



12
13
14
15
16
# File 'lib/database_schema_ownership/runner.rb', line 12

def initialize(schema_path = nil, folder_path = OWNERSHIP_PATH)
  @schema_path = schema_path || find_schema_path
  @folder_path = folder_path
  @schema_extension = File.extname(@schema_path)
end

Instance Attribute Details

#folder_pathObject (readonly)

Returns the value of attribute folder_path.



10
11
12
# File 'lib/database_schema_ownership/runner.rb', line 10

def folder_path
  @folder_path
end

#schema_extensionObject (readonly)

Returns the value of attribute schema_extension.



10
11
12
# File 'lib/database_schema_ownership/runner.rb', line 10

def schema_extension
  @schema_extension
end

#schema_pathObject (readonly)

Returns the value of attribute schema_path.



10
11
12
# File 'lib/database_schema_ownership/runner.rb', line 10

def schema_path
  @schema_path
end

Instance Method Details

#runObject



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/database_schema_ownership/runner.rb', line 18

def run
  entities = parser.parse

  FileUtils.mkdir_p(folder_path) if entities.any?

  grouped = group_entities(entities)

  grouped.each do |name, |
    File.write(file_name(name), )
  end
end