Class: Rails::Schema::Extractor::SchemaFileParser
- Inherits:
-
Object
- Object
- Rails::Schema::Extractor::SchemaFileParser
- Defined in:
- lib/rails/schema/extractor/schema_file_parser.rb
Instance Attribute Summary collapse
-
#views ⇒ Object
readonly
schema.rb does not declare SQL views, so this is always empty; the reader exists so SchemaFileParser and StructureSqlParser share an interface (see Rails::Schema.parse_schema).
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.
14 15 16 17 |
# File 'lib/rails/schema/extractor/schema_file_parser.rb', line 14 def initialize(schema_path = nil) @schema_path = schema_path @views = Set.new end |
Instance Attribute Details
#views ⇒ Object (readonly)
schema.rb does not declare SQL views, so this is always empty; the reader exists so SchemaFileParser and StructureSqlParser share an interface (see Rails::Schema.parse_schema).
12 13 14 |
# File 'lib/rails/schema/extractor/schema_file_parser.rb', line 12 def views @views end |
Instance Method Details
#parse ⇒ Object
19 20 21 22 23 24 |
# File 'lib/rails/schema/extractor/schema_file_parser.rb', line 19 def parse path = resolve_path return {} unless path && File.exist?(path) parse_content(File.read(path)) end |
#parse_content(content) ⇒ Object
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/rails/schema/extractor/schema_file_parser.rb', line 26 def parse_content(content) @tables = {} @current_table = nil @pk_type = nil @has_pk = true content.each_line { |line| process_line(line.strip) } @tables end |