Class: Pure::Extractor::Extractors::InteractiveExtractor
- Inherits:
-
Extractor
- Object
- Extractor
- Pure::Extractor::Extractors::InteractiveExtractor
show all
- Defined in:
- lib/pure/extractor/extractors/interactive.rb
Class Method Summary
collapse
Methods inherited from Extractor
extract_collection_to_disk, filename_for_id, format_results_for_type, get_chunk_size, output_filepath_for_filename, random_delay, set_config, write_results_to_file
Class Method Details
9
10
11
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
44
|
# File 'lib/pure/extractor/extractors/interactive.rb', line 9
def self.
collection = Puree::::Collection.new config: @config, resource: @config[:collection]
collection_count = collection.count
puts "Extracting #{collection_count} records from #{@config[:collection]} collection"
progress_bar = ProgressBar.create(format: "%a %e %b\u{15E7}%i %p%% %t", progress_mark: ' ', remainder_mark: "\u{FF65}", total: collection_count)
offset = 0
file_id = 0
chunk_size = get_chunk_size
while offset < collection_count do
random_delay if (offset != 0) && @config[:delay]
file_id += 1
filename = filename_for_id file_id
output_file = output_filepath_for_filename filename
collection, chunk_size, offset, output_file
update_progress_bar progress_bar, chunk_size, collection_count
offset += chunk_size
end
puts "Finished extracting #{collection_count} records from #{@config[:collection]} collection"
end
|
.update_progress_bar(progress_bar, limit, collection_count) ⇒ Object
46
47
48
49
50
51
52
53
54
|
# File 'lib/pure/extractor/extractors/interactive.rb', line 46
def self.update_progress_bar progress_bar, limit, collection_count
if (progress_bar.progress + limit) < collection_count
progress_bar.progress += limit
else
progress_bar.progress = collection_count
end
end
|