Class: CassSchema::StatementLoader
- Inherits:
-
Object
- Object
- CassSchema::StatementLoader
- Defined in:
- lib/cass_schema/statement_loader.rb
Class Method Summary collapse
Class Method Details
.statements(*path_parts) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/cass_schema/statement_loader.rb', line 4 def statements(*path_parts) file_path = File.join(path_parts) file = File.open(file_path).read # Parse the individual CQL statements as a list from the file. To do so: # - assume statements are separated by two new lines # - strip comments and empty lines from each statement # - remove statements that are empty statements = file.split(/\n{2,}/).map do |statement| statement .split(/\n/) .select { |l| l !~ /^\s*#/ } .select { |l| l !~ /^\s*$/ } .join("\n") end statements.select { |s| s.length > 0 } end |