Created
April 9, 2015 04:03
-
-
Save AlexandrBasan/949a774243c1c5d3a1e6 to your computer and use it in GitHub Desktop.
Ruby parser (schema.rb)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<% a = File.open("db/schema.rb") %> | |
<% a.each do |out| %> | |
<% if out.scan(/\s\s\s\st.[a-z]{1,12}\s{1,6}"(.*?)\"/) %> | |
<% if out.scan(/\s\s\s\st.[a-z]{1,12}\s{1,6}"(.*?)\"/).join(', ') == 'created_at' || out.scan(/\s\s\s\st.[a-z]{1,12}\s{1,6}"(.*?)\"/).join(', ') == 'updated_at' %> | |
<% else %> | |
:<%= out.scan(/\s\s\s\st.[a-z]{1,12}\s{1,6}"(.*?)\"/).join(', ') %>, | |
<% end %> | |
<% elsif out.scan(/\s\s\s\st.[a-z]{1,12}\s{1,6}"(.*?)\"\n\s\send/)%> | |
<% if out.scan(/\s\s\s\st.[a-z]{1,12}\s{1,6}"(.*?)\"\n\s\send/).join(', ') == 'created_at' || out.scan(/\s\s\s\st.[a-z]{1,12}\s{1,6}"(.*?)\"\n\s\send/).join(', ') == 'updated_at' %> | |
<% else %> | |
:<%= out.scan(/\s\s\s\st.[a-z]{1,12}\s{1,6}"(.*?)\"\n\s\send/).join(', ') %></br> | |
<% end %> | |
<% end %> | |
<% end %> | |
<!-- \s\s\s\st.[a-z]{1,12}\s{1,6}"(.*?)\" - regex for t.---------- "????" --> | |
<!-- \s\s\s\st.[a-z]{1,12}\s{1,6}"(.*?)\"\n\s\send" - regex for " end --> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment