Class: DataKeeper::Loader::InflatedFiles
- Inherits:
-
Object
- Object
- DataKeeper::Loader::InflatedFiles
- Defined in:
- lib/data_keeper/loader.rb
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
Instance Method Summary collapse
-
#initialize(dump, paths) ⇒ InflatedFiles
constructor
A new instance of InflatedFiles.
- #schema_path ⇒ Object
- #sequences_path ⇒ Object
- #sql_dumps ⇒ Object
- #tables_path ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(dump, paths) ⇒ InflatedFiles
Returns a new instance of InflatedFiles.
156 157 158 159 160 |
# File 'lib/data_keeper/loader.rb', line 156 def initialize(dump, paths) @dump = dump @paths = paths @errors = [] end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
154 155 156 |
# File 'lib/data_keeper/loader.rb', line 154 def errors @errors end |
Instance Method Details
#schema_path ⇒ Object
171 172 173 |
# File 'lib/data_keeper/loader.rb', line 171 def schema_path @schema_path ||= @paths.find { |x| File.basename(x) == "schema.dump" } end |
#sequences_path ⇒ Object
179 180 181 |
# File 'lib/data_keeper/loader.rb', line 179 def sequences_path @sequences_path ||= @paths.find { |x| File.basename(x) == "sequences.dump" } end |
#sql_dumps ⇒ Object
183 184 185 186 187 188 189 190 |
# File 'lib/data_keeper/loader.rb', line 183 def sql_dumps @sql_dumps ||= @dump.sqls.map do |name, (table, _proc)| path = @paths.find { |x| File.basename(x) == "#{name}.csv" } next unless path [table, path] end.compact end |
#tables_path ⇒ Object
175 176 177 |
# File 'lib/data_keeper/loader.rb', line 175 def tables_path @tables_path ||= @paths.find { |x| File.basename(x) == "tables.dump" } end |
#valid? ⇒ Boolean
162 163 164 165 166 167 168 169 |
# File 'lib/data_keeper/loader.rb', line 162 def valid? @errors = [] validate("Schema file is missing") { !!schema_path } && validate("Tables file is missing") { !!tables_path } && validate("Not all sql custom dumps are present") { sql_dumps.size == @dump.sqls.keys.size } && validate("Sequences file is missing") { !!sequences_path } end |