Class: DBCode::SQLFile

Inherits:
Object
  • Object
show all
Defined in:
lib/dbcode/sql_file.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ SQLFile



5
6
7
# File 'lib/dbcode/sql_file.rb', line 5

def initialize(path)
  @path = Pathname(path)
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



3
4
5
# File 'lib/dbcode/sql_file.rb', line 3

def path
  @path
end

Instance Method Details

#dependency_namesObject



13
14
15
# File 'lib/dbcode/sql_file.rb', line 13

def dependency_names
  to_sql.scan(/^\s*-- require (\S+)\s*$/).flatten
end

#nameObject



9
10
11
# File 'lib/dbcode/sql_file.rb', line 9

def name
  path.basename('.sql').to_s
end

#to_sqlObject



17
18
19
# File 'lib/dbcode/sql_file.rb', line 17

def to_sql
  @sql ||= path.read
end