Class: DBCode::SQLFile
- Inherits:
-
Object
- Object
- DBCode::SQLFile
- Defined in:
- lib/dbcode/sql_file.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #dependency_names ⇒ Object
-
#initialize(path) ⇒ SQLFile
constructor
A new instance of SQLFile.
- #name ⇒ Object
- #to_sql ⇒ Object
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
#path ⇒ Object (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_names ⇒ Object
13 14 15 |
# File 'lib/dbcode/sql_file.rb', line 13 def dependency_names to_sql.scan(/^\s*-- require (\S+)\s*$/).flatten end |
#name ⇒ Object
9 10 11 |
# File 'lib/dbcode/sql_file.rb', line 9 def name path.basename('.sql').to_s end |
#to_sql ⇒ Object
17 18 19 |
# File 'lib/dbcode/sql_file.rb', line 17 def to_sql @sql ||= path.read end |