cranium 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 95d417150867a455805bdc4b21372050ee81f8cc
4
- data.tar.gz: 6a1ee615b84a1a6eefd83e4590d947e408fb1244
3
+ metadata.gz: b443b2b93e702139014a95256215bf7a8b22c1cc
4
+ data.tar.gz: 9c19653223b7958efe0ed35243a5308823c4849a
5
5
  SHA512:
6
- metadata.gz: 6ee2e4a162601873d76cc96b1d88b02b4e6348019f04a899d68ba6c1723a9d1f678f51314bdc748e30357f7d04d8026330c1d428761c7c65506d46483bc45e3e
7
- data.tar.gz: 114072465d737d6d8fd18ea884d7ed3c1f5b26bfc4dbdf3c2da2e6c6fb0994d5922b75502de2c0cbe75bb60042d3a1c90f788258403a580098175e9e7f108c23
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.0'
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'
@@ -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), File.line_count(input_file) do |progress_bar|
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), File.line_count(input_file) do |progress_bar|
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,7 @@
1
+ module Cranium::FileUtils
2
+
3
+ def self.line_count(file_path)
4
+ File.read(file_path).each_line.count
5
+ end
6
+
7
+ end
@@ -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.0
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-04-27 00:00:00.000000000 Z
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.5.1
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
@@ -1,7 +0,0 @@
1
- class File
2
-
3
- def self.line_count(file_path)
4
- (`wc -l #{file_path}`.match /^\s*(?<line_count>\d+).*/)["line_count"].to_i
5
- end
6
-
7
- end