Module: Micdrop
- Defined in:
- lib/micdrop/record_context.rb,
lib/micdrop.rb,
lib/micdrop/errors.rb,
lib/micdrop/version.rb,
lib/micdrop/stop_skip.rb,
lib/micdrop/ext/sequel.rb,
lib/micdrop/ext/nokogiri.rb,
lib/micdrop/files_source.rb,
lib/micdrop/item_context.rb,
lib/micdrop/ext/json_lines.rb,
lib/micdrop/ext/microfocus.rb,
lib/micdrop/structure_builder.rb,
sig/micdrop.rbs
Overview
Represets
Defined Under Namespace
Modules: Ext Classes: FilesSource, FilesSourceRecord, ItemContext, PipelineError, RecordContext, RootRecordContext, SinkError, Skip, SourceError, Stop, StructureBuilder, SubRecordContext, ValueError
Constant Summary collapse
- VERSION =
"0.2.1"
Class Method Summary collapse
- .migrate(from, to, &block) ⇒ Object
- .migrate_item_helper(from, to, loop_item, loop_index, &block) ⇒ Object
-
.register_lookup(name, lookup) ⇒ Object
Register a lookup, allowing it to be used in subsequent migrations.
Class Method Details
.migrate(from, to, &block) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/micdrop.rb', line 12 def self.migrate(from, to, &block) # TODO: can we reduce the duplicated code? if from.respond_to? :each_with_index from.each_with_index do |loop_item, loop_index| migrate_item_helper(from, to, loop_item, loop_index, &block) rescue Skip next rescue Stop break end elsif from.respond_to? :each_pair from.each_pair do |loop_index, loop_item| migrate_item_helper(from, to, loop_item, loop_index, &block) rescue Skip next rescue Stop break end elsif from.respond_to? :each from.each.with_index do |loop_item, loop_index| migrate_item_helper(from, to, loop_item, loop_index, &block) rescue Skip next rescue Stop break end else # TODO: error end from.close if from.respond_to? :close to.close if to.respond_to? :close end |
.migrate_item_helper(from, to, loop_item, loop_index, &block) ⇒ Object
51 52 53 54 55 |
# File 'lib/micdrop.rb', line 51 def self.migrate_item_helper(from, to, loop_item, loop_index, &block) ctx = RootRecordContext.new(from, to, loop_item, loop_index) ctx.instance_eval(&block) ctx.flush reset: false # No need to reset; item processing is done end |
.register_lookup(name, lookup) ⇒ Object
Register a lookup, allowing it to be used in subsequent migrations
47 48 49 |
# File 'lib/micdrop.rb', line 47 def self.register_lookup(name, lookup) ItemContext.register_lookup name, lookup end |