2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/read_schema.rb', line 2
def self.read_schema(tables)
begin
File.open("db/schema.rb", "r") do |f|
f.each_line do |line|
if line.include?("create_table")
short_line = line.delete(' ')
table_name = ""
i = 13
while short_line[i] != "'" && short_line[i] != '"'
table_name << short_line[i].to_s
i = i + 1
end
tables.push(table_name)
end
end
rescue StandardError => e
puts "Something went wrong, missing schema.rb or syntax error...".red
end
end
end
|