Class: Yescode::Queries
- Inherits:
-
Object
- Object
- Yescode::Queries
- Defined in:
- lib/yescode/queries.rb
Class Method Summary collapse
Class Method Details
.name(line) ⇒ Object
4 5 6 |
# File 'lib/yescode/queries.rb', line 4 def name(line) line.match(/^--\s*name\s*:\s*(\S+)/).to_a.last end |
.queries(filename) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/yescode/queries.rb', line 12 def queries(filename) queries = [] File.foreach filename do |line| query_name = name(line) query_sql = sql(line) queries << [query_name.to_sym, ""] if query_name queries.last[1] = "#{queries.last[1]} #{query_sql}".strip if query_sql end queries end |
.sql(line) ⇒ Object
8 9 10 |
# File 'lib/yescode/queries.rb', line 8 def sql(line) line.match(/^[^-{2}](.*)/).to_a.first end |