cranium 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/cranium.gemspec +1 -1
- data/lib/cranium.rb +1 -0
- data/lib/cranium/data_reader.rb +1 -2
- data/lib/cranium/data_transformer.rb +1 -2
- data/lib/cranium/file_utils.rb +7 -0
- data/spec/cranium/file_utils_spec.rb +33 -0
- metadata +6 -4
- data/lib/cranium/extensions/file.rb +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b443b2b93e702139014a95256215bf7a8b22c1cc
|
4
|
+
data.tar.gz: 9c19653223b7958efe0ed35243a5308823c4849a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6a722521a2a2b2a1f6843f3d80925f47fedbab6a84571ecc2d20d2fcd8483a410fec3832ff72b8673381f0d54b4b9edd367dda9847540cc744b3734c10509064
|
7
|
+
data.tar.gz: cb0caba449594c18c1d301991263af28d158431cee96e630af0665dd2e0eac7b4e8e26120404694ba6cae1386e297ee4eda40ab09c37adb4d3b5fda5ba4eb8fd
|
data/cranium.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |spec|
|
2
2
|
spec.name = 'cranium'
|
3
|
-
spec.version = '0.3.
|
3
|
+
spec.version = '0.3.1'
|
4
4
|
spec.authors = ['Emarsys Technologies']
|
5
5
|
spec.email = ['smart-insight-dev@emarsys.com']
|
6
6
|
spec.description = %q{Provides Extract, Transform and Load functionality for loading data from CSV files to a Greenplum database.}
|
data/lib/cranium.rb
CHANGED
@@ -14,6 +14,7 @@ module Cranium
|
|
14
14
|
autoload :DSL, 'cranium/dsl'
|
15
15
|
autoload :ExternalTable, 'cranium/external_table'
|
16
16
|
autoload :Extract, 'cranium/extract'
|
17
|
+
autoload :FileUtils, 'cranium/file_utils'
|
17
18
|
autoload :ImportStrategy, 'cranium/import_strategy'
|
18
19
|
autoload :Logging, 'cranium/logging'
|
19
20
|
autoload :ProgressOutput, 'cranium/progress_output'
|
data/lib/cranium/data_reader.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'csv'
|
2
|
-
require 'cranium/extensions/file'
|
3
2
|
|
4
3
|
class Cranium::DataReader
|
5
4
|
|
@@ -21,7 +20,7 @@ class Cranium::DataReader
|
|
21
20
|
private
|
22
21
|
|
23
22
|
def read_input_file(input_file, read_block)
|
24
|
-
Cranium::ProgressOutput.show_progress File.basename(input_file),
|
23
|
+
Cranium::ProgressOutput.show_progress File.basename(input_file), Cranium::FileUtils.line_count(input_file) do |progress_bar|
|
25
24
|
line_number = 0
|
26
25
|
CSV.foreach input_file, csv_read_options_for(@source) do |row|
|
27
26
|
next if 1 == (line_number += 1)
|
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'csv'
|
2
|
-
require 'cranium/extensions/file'
|
3
2
|
|
4
3
|
class Cranium::DataTransformer
|
5
4
|
|
@@ -30,7 +29,7 @@ class Cranium::DataTransformer
|
|
30
29
|
private
|
31
30
|
|
32
31
|
def transform_input_file(input_file, transformation_block)
|
33
|
-
Cranium::ProgressOutput.show_progress File.basename(input_file),
|
32
|
+
Cranium::ProgressOutput.show_progress File.basename(input_file), Cranium::FileUtils.line_count(input_file) do |progress_bar|
|
34
33
|
line_number = 0
|
35
34
|
CSV.foreach input_file, csv_read_options_for(@source) do |row|
|
36
35
|
next if 1 == (line_number += 1)
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
|
3
|
+
describe Cranium::FileUtils do
|
4
|
+
|
5
|
+
describe '#line_count' do
|
6
|
+
let(:number_of_lines) { 3 }
|
7
|
+
|
8
|
+
it 'returns the number of lines the file has' do
|
9
|
+
path = '/tmp/3_lines.txt'
|
10
|
+
create_test_file path, number_of_lines
|
11
|
+
|
12
|
+
expect(described_class.line_count(path)).to eq(number_of_lines)
|
13
|
+
File.delete path
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'handles () characters in path' do
|
17
|
+
path = '/tmp/such_copy_of_a_copy(2).txt'
|
18
|
+
create_test_file path, number_of_lines
|
19
|
+
|
20
|
+
expect { described_class.line_count(path) }.not_to raise_error
|
21
|
+
File.delete path
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
def create_test_file(path, number_of_lines)
|
28
|
+
File.open(path, 'w') do |file|
|
29
|
+
number_of_lines.times { |i| file.puts i }
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cranium
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Emarsys Technologies
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-06-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pg
|
@@ -213,7 +213,6 @@ files:
|
|
213
213
|
- lib/cranium/dsl/extract_definition.rb
|
214
214
|
- lib/cranium/dsl/import_definition.rb
|
215
215
|
- lib/cranium/dsl/source_definition.rb
|
216
|
-
- lib/cranium/extensions/file.rb
|
217
216
|
- lib/cranium/extensions/sequel_greenplum.rb
|
218
217
|
- lib/cranium/external_table.rb
|
219
218
|
- lib/cranium/extract.rb
|
@@ -223,6 +222,7 @@ files:
|
|
223
222
|
- lib/cranium/extract/strategy/base.rb
|
224
223
|
- lib/cranium/extract/strategy/incremental.rb
|
225
224
|
- lib/cranium/extract/strategy/simple.rb
|
225
|
+
- lib/cranium/file_utils.rb
|
226
226
|
- lib/cranium/import_strategy.rb
|
227
227
|
- lib/cranium/import_strategy/base.rb
|
228
228
|
- lib/cranium/import_strategy/delete_insert.rb
|
@@ -265,6 +265,7 @@ files:
|
|
265
265
|
- spec/cranium/dsl_spec.rb
|
266
266
|
- spec/cranium/external_table_spec.rb
|
267
267
|
- spec/cranium/extract/storage_spec.rb
|
268
|
+
- spec/cranium/file_utils_spec.rb
|
268
269
|
- spec/cranium/logging_spec.rb
|
269
270
|
- spec/cranium/sequel/hash_spec.rb
|
270
271
|
- spec/cranium/source_registry_spec.rb
|
@@ -296,7 +297,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
296
297
|
version: '0'
|
297
298
|
requirements: []
|
298
299
|
rubyforge_project:
|
299
|
-
rubygems_version: 2.
|
300
|
+
rubygems_version: 2.6.4
|
300
301
|
signing_key:
|
301
302
|
specification_version: 4
|
302
303
|
summary: Pure Ruby ETL framework
|
@@ -350,6 +351,7 @@ test_files:
|
|
350
351
|
- spec/cranium/dsl_spec.rb
|
351
352
|
- spec/cranium/external_table_spec.rb
|
352
353
|
- spec/cranium/extract/storage_spec.rb
|
354
|
+
- spec/cranium/file_utils_spec.rb
|
353
355
|
- spec/cranium/logging_spec.rb
|
354
356
|
- spec/cranium/sequel/hash_spec.rb
|
355
357
|
- spec/cranium/source_registry_spec.rb
|