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.
155 156 157 158 159 |
# File 'lib/data_keeper/loader.rb', line 155 def initialize(dump, paths) @dump = dump @paths = paths @errors = [] end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
153 154 155 |
# File 'lib/data_keeper/loader.rb', line 153 def errors @errors end |
Instance Method Details
#schema_path ⇒ Object
170 171 172 |
# File 'lib/data_keeper/loader.rb', line 170 def schema_path @schema_path ||= @paths.find { |x| File.basename(x) == "schema.dump" } end |
#sequences_path ⇒ Object
178 179 180 |
# File 'lib/data_keeper/loader.rb', line 178 def sequences_path @sequences_path ||= @paths.find { |x| File.basename(x) == "sequences.dump" } end |
#sql_dumps ⇒ Object
182 183 184 185 186 187 188 189 |
# File 'lib/data_keeper/loader.rb', line 182 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
174 175 176 |
# File 'lib/data_keeper/loader.rb', line 174 def tables_path @tables_path ||= @paths.find { |x| File.basename(x) == "tables.dump" } end |
#valid? ⇒ Boolean
161 162 163 164 165 166 167 168 |
# File 'lib/data_keeper/loader.rb', line 161 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 |