Class: Rails::Schema::Extractor::SchemaFileParser
- Inherits:
-
Object
- Object
- Rails::Schema::Extractor::SchemaFileParser
- Defined in:
- lib/rails/schema/extractor/schema_file_parser.rb
Instance Method Summary collapse
-
#initialize(schema_path = nil) ⇒ SchemaFileParser
constructor
A new instance of SchemaFileParser.
- #parse ⇒ Object
- #parse_content(content) ⇒ Object
Constructor Details
#initialize(schema_path = nil) ⇒ SchemaFileParser
Returns a new instance of SchemaFileParser.
7 8 9 |
# File 'lib/rails/schema/extractor/schema_file_parser.rb', line 7 def initialize(schema_path = nil) @schema_path = schema_path end |
Instance Method Details
#parse ⇒ Object
11 12 13 14 15 16 |
# File 'lib/rails/schema/extractor/schema_file_parser.rb', line 11 def parse path = resolve_path return {} unless path && File.exist?(path) parse_content(File.read(path)) end |
#parse_content(content) ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/rails/schema/extractor/schema_file_parser.rb', line 18 def parse_content(content) @tables = {} @current_table = nil @pk_type = nil @has_pk = true content.each_line { |line| process_line(line.strip) } @tables end |