Class: Lagoon::Parser::SchemaParser
- Inherits:
-
Object
- Object
- Lagoon::Parser::SchemaParser
- Defined in:
- lib/lagoon/parser/schema_parser.rb
Defined Under Namespace
Classes: ConnectionEntry, TableMetadata
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ SchemaParser
constructor
A new instance of SchemaParser.
- #parse ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ SchemaParser
Returns a new instance of SchemaParser.
11 12 13 14 |
# File 'lib/lagoon/parser/schema_parser.rb', line 11 def initialize( = {}) @options = .is_a?(Options) ? : Options.for(:er, ) @analyzer = Lagoon::Analyzer::DatabaseSchemaAnalyzer.new end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
9 10 11 |
# File 'lib/lagoon/parser/schema_parser.rb', line 9 def @options end |
Instance Method Details
#parse ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/lagoon/parser/schema_parser.rb', line 16 def parse entities = [] relationships = [] warnings = [] load_schema(warnings).each do |table| next if excluded?(table) analyze_table(table, entities, relationships) rescue StandardError => e raise if [:strict] warnings << "Failed to analyze table #{table.name}: #{e.}" end { entities: entities.sort_by { |entity| entity[:name] }, relationships: relationships.sort_by { |relationship| [relationship[:source], relationship[:target]] }, warnings: warnings, counts: { entities: entities.size, relationships: relationships.size, skipped: warnings.size } } end |