Module: Assimilate
- Defined in:
- lib/assimilate.rb,
lib/assimilate/version.rb
Defined Under Namespace
Classes: Batch, Catalog, Command, CorruptDataError, DuplicateImportError, Extender, InvalidConfiguration
Constant Summary
collapse
- VERSION =
"0.0.3"
Class Method Summary
collapse
Class Method Details
.extend_data(filename, opts = {}) ⇒ Object
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/assimilate.rb', line 36
def self.extend_data(filename, opts = {})
begin
catalog = Catalog.new(:config => opts[:config])
extender = catalog.extend_data(opts)
records = CSV.read(filename, :headers => true)
records.each do |rec|
extender << rec
end
if opts[:commit]
extender.commit
else
$stderr.puts "suppressing data commit"
end
extender.stats
end
end
|
.load(filename, opts = {}) ⇒ Object
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/assimilate.rb', line 14
def self.load(filename, opts = {})
begin
catalog = Catalog.new(:config => opts[:config])
batcher = catalog.start_batch(opts.merge(:filename => filename))
records = CSV.read(filename, :headers => true)
records.each do |rec|
batcher << rec
end
if opts[:commit]
batcher.commit
else
$stderr.puts "suppressing data commit"
end
batcher.stats
end
end
|