ndr_import 5.0.0 → 5.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/code_safety.yml +14 -6
- data/lib/ndr_import.rb +1 -0
- data/lib/ndr_import/fixed_width/table.rb +25 -0
- data/lib/ndr_import/version.rb +1 -1
- data/ndr_import.gemspec +2 -0
- data/test/fixed_width/table_test.rb +35 -0
- metadata +6 -4
- data/.travis.yml +0 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 411899f19141a2e2da38b712d76d4de02b00bda7
|
4
|
+
data.tar.gz: 9feaaf50a3bb840974a0ce38ef66fee5ab32c19e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4d10e6a1d6370dd513364cf6332daf14ab6fe75e9b320906fa6a93e4e08422e54ebe16755bfbbd966e05c130bf53eab329e84ef2b5e766acd600e7059fd939f6
|
7
|
+
data.tar.gz: c824e74a89cfe9c9ded3f4a95b42f1be7bc31ae475b503264aa10e14621223691eb936dcd550792592ce7104c6eb278f7cb43059dacba916a26fc0f9ce4b8f6c
|
data/code_safety.yml
CHANGED
@@ -58,8 +58,8 @@ file safety:
|
|
58
58
|
safe_revision: c158dc783b84cab31380708e76e3812544cc1c2f
|
59
59
|
lib/ndr_import.rb:
|
60
60
|
comments:
|
61
|
-
reviewed_by:
|
62
|
-
safe_revision:
|
61
|
+
reviewed_by: ollie.tulloch
|
62
|
+
safe_revision: dfc958d44b6c58355445fa395db08a62213ee709
|
63
63
|
lib/ndr_import/csv_library.rb:
|
64
64
|
comments:
|
65
65
|
reviewed_by: josh.pencheon
|
@@ -100,6 +100,10 @@ file safety:
|
|
100
100
|
comments:
|
101
101
|
reviewed_by: timgentry
|
102
102
|
safe_revision: c88000b32401b5ae9ef7f5878a9b630506ab5a94
|
103
|
+
lib/ndr_import/fixed_width/table.rb:
|
104
|
+
comments:
|
105
|
+
reviewed_by: ollie.tulloch
|
106
|
+
safe_revision: dfc958d44b6c58355445fa395db08a62213ee709
|
103
107
|
lib/ndr_import/helpers/file/delimited.rb:
|
104
108
|
comments:
|
105
109
|
reviewed_by: josh.pencheon
|
@@ -170,12 +174,12 @@ file safety:
|
|
170
174
|
safe_revision: 36143ff4f48e0433a7b04b63143ef6d6d2481fec
|
171
175
|
lib/ndr_import/version.rb:
|
172
176
|
comments: another check?
|
173
|
-
reviewed_by:
|
174
|
-
safe_revision:
|
177
|
+
reviewed_by: ollie.tulloch
|
178
|
+
safe_revision: fa21aae027f436337eb0de481e390cdbab348123
|
175
179
|
ndr_import.gemspec:
|
176
180
|
comments:
|
177
|
-
reviewed_by:
|
178
|
-
safe_revision:
|
181
|
+
reviewed_by: ollie.tulloch
|
182
|
+
safe_revision: a76d7fd03894158417411d0c9620ea4c1d5a03d6
|
179
183
|
test/file/base_test.rb:
|
180
184
|
comments:
|
181
185
|
reviewed_by: timgentry
|
@@ -208,6 +212,10 @@ file safety:
|
|
208
212
|
comments:
|
209
213
|
reviewed_by: timgentry
|
210
214
|
safe_revision: c88000b32401b5ae9ef7f5878a9b630506ab5a94
|
215
|
+
test/fixed_width/table_test.rb:
|
216
|
+
comments:
|
217
|
+
reviewed_by: ollie.tulloch
|
218
|
+
safe_revision: dfc958d44b6c58355445fa395db08a62213ee709
|
211
219
|
test/helpers/file/delimited_test.rb:
|
212
220
|
comments:
|
213
221
|
reviewed_by: joshpencheon
|
data/lib/ndr_import.rb
CHANGED
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'ndr_import/table'
|
2
|
+
|
3
|
+
module NdrImport
|
4
|
+
module FixedWidth
|
5
|
+
# This class maintains the state of a fixed width table mapping and encapsulates
|
6
|
+
# the logic required to transform a table of data into "records". Particular
|
7
|
+
# attention has been made to use enumerables throughout to help with the
|
8
|
+
# transformation of large quantities of data.
|
9
|
+
class Table < ::NdrImport::Table
|
10
|
+
# This method transforms an incoming line of fixed wwidrh data by applying
|
11
|
+
# each of the klass masked mappings to the line and yielding the klass
|
12
|
+
# and fields for each mapped klass.
|
13
|
+
def transform_line(line, index)
|
14
|
+
return enum_for(:transform_line, line, index) unless block_given?
|
15
|
+
|
16
|
+
masked_mappings.each do |klass, klass_mappings|
|
17
|
+
line = fixed_width_columns(line, klass_mappings)
|
18
|
+
fields = mapped_line(line, klass_mappings)
|
19
|
+
next if fields[:skip].to_s == 'true'.freeze
|
20
|
+
yield(klass, fields, index)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/ndr_import/version.rb
CHANGED
data/ndr_import.gemspec
CHANGED
@@ -15,6 +15,8 @@ Gem::Specification.new do |spec|
|
|
15
15
|
|
16
16
|
# Exclude older versions of this gem from the package.
|
17
17
|
spec.files = `git ls-files -z`.split("\x0").reject { |s| s =~ %r{^pkg/} }
|
18
|
+
# SECURE BNS 2018-08-06: Minimise sharing of (public-key encrypted) slack secrets in .travis.yml
|
19
|
+
spec.files -= %w[.travis.yml] # Not needed in the gem
|
18
20
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
19
21
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
20
22
|
spec.require_paths = ['lib']
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
# This tests the NdrImport::FixedWidth::Table mapping class
|
4
|
+
module FixedWidth
|
5
|
+
class TableTest < ActiveSupport::TestCase
|
6
|
+
def test_transform_fixed_width_line
|
7
|
+
table = NdrImport::FixedWidth::Table.new(header_lines: 2,
|
8
|
+
footer_lines: 1,
|
9
|
+
klass: 'SomeTestKlass',
|
10
|
+
columns: fixed_width_column_mapping)
|
11
|
+
|
12
|
+
enum = table.transform_line('123 abcdexyz', 2)
|
13
|
+
assert_instance_of Enumerator, enum
|
14
|
+
output = []
|
15
|
+
enum.each do |klass, fields, index|
|
16
|
+
output << [klass, fields, index]
|
17
|
+
end
|
18
|
+
|
19
|
+
expected_output = [
|
20
|
+
['SomeTestKlass', { rawtext: { 'one' => '123 ', 'two' => 'abcde', 'three' => 'xyz' } }, 2]
|
21
|
+
]
|
22
|
+
assert_equal expected_output.sort, output.sort
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def fixed_width_column_mapping
|
28
|
+
[
|
29
|
+
{ 'column' => 'one', 'unpack_pattern' => 'a5' },
|
30
|
+
{ 'column' => 'two', 'unpack_pattern' => 'a5' },
|
31
|
+
{ 'column' => 'three', 'unpack_pattern' => 'a3' }
|
32
|
+
]
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ndr_import
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.
|
4
|
+
version: 5.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- NCRS Development Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-08-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -309,7 +309,6 @@ files:
|
|
309
309
|
- ".gitignore"
|
310
310
|
- ".hound.yml"
|
311
311
|
- ".rubocop.yml"
|
312
|
-
- ".travis.yml"
|
313
312
|
- CODE_OF_CONDUCT.md
|
314
313
|
- Gemfile
|
315
314
|
- Guardfile
|
@@ -332,6 +331,7 @@ files:
|
|
332
331
|
- lib/ndr_import/file/text.rb
|
333
332
|
- lib/ndr_import/file/word.rb
|
334
333
|
- lib/ndr_import/file/zip.rb
|
334
|
+
- lib/ndr_import/fixed_width/table.rb
|
335
335
|
- lib/ndr_import/helpers/file/delimited.rb
|
336
336
|
- lib/ndr_import/helpers/file/excel.rb
|
337
337
|
- lib/ndr_import/helpers/file/pdf.rb
|
@@ -359,6 +359,7 @@ files:
|
|
359
359
|
- test/file/text_test.rb
|
360
360
|
- test/file/word_test.rb
|
361
361
|
- test/file/zip_test.rb
|
362
|
+
- test/fixed_width/table_test.rb
|
362
363
|
- test/helpers/file/delimited_test.rb
|
363
364
|
- test/helpers/file/excel_test.rb
|
364
365
|
- test/helpers/file/pdf_test.rb
|
@@ -430,7 +431,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
430
431
|
version: '0'
|
431
432
|
requirements: []
|
432
433
|
rubyforge_project:
|
433
|
-
rubygems_version: 2.
|
434
|
+
rubygems_version: 2.5.2.3
|
434
435
|
signing_key:
|
435
436
|
specification_version: 4
|
436
437
|
summary: NDR Import
|
@@ -443,6 +444,7 @@ test_files:
|
|
443
444
|
- test/file/text_test.rb
|
444
445
|
- test/file/word_test.rb
|
445
446
|
- test/file/zip_test.rb
|
447
|
+
- test/fixed_width/table_test.rb
|
446
448
|
- test/helpers/file/delimited_test.rb
|
447
449
|
- test/helpers/file/excel_test.rb
|
448
450
|
- test/helpers/file/pdf_test.rb
|
data/.travis.yml
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
language: ruby
|
2
|
-
rvm:
|
3
|
-
- 2.3
|
4
|
-
- 2.4
|
5
|
-
- 2.5
|
6
|
-
gemfile:
|
7
|
-
- gemfiles/Gemfile.rails42
|
8
|
-
- gemfiles/Gemfile.rails50
|
9
|
-
- gemfiles/Gemfile.rails51
|
10
|
-
- gemfiles/Gemfile.rails52
|
11
|
-
sudo: false
|
12
|
-
cache: bundler
|
13
|
-
before_script: bundle update
|
14
|
-
script: bundle exec rake test
|
15
|
-
notifications:
|
16
|
-
slack:
|
17
|
-
on_pull_requests: false
|
18
|
-
on_success: always
|
19
|
-
on_failure: always
|
20
|
-
rooms:
|
21
|
-
secure: NMd9N/jNbECT/fCUBxPDKy4IMpUnRdMhobwa+9kDRaWYbRAwIkHLd8sI1l63qx7O03SlDpsHLLckjayMKS35gO/wRmgC7T8k9ppW75Xs5D4jR/j3FdTFawnXF+wVx0ddQrpH0K8oftPX1euPEllIh7+bJUYct/Siv0UX5eP+qyHT0gKtbDlI2CMKOcOHE8Q/zwjx0mLVSj/0U+HRx5+sMEDcwPupzhCYLdIAtenHsZ2Zmo2uSqOzK9Ruf3UsIh3gVSKXWGvXQzG8bIxogIJbEbwIk/gQyMr7UXwgNzhltPz1CqOrrTmSonrd3HbLVajJvDWPMBPGDZrUyipiW/MOUKpXgd8CsL46o4icYIZIAYEWLsn/AJkrA+UQZ8S5poR06jNH8xrI0eUQsu6maWhJ/rPfzwb6x2hCCyk2iQsGtO+SPCUrWnT1T3ir8H0HStD+AZ4/yz4cdWlClchko2ZfqS0q3Yv5jF3K4iVOF4GOUo01Ft+LDU3sPC7Ngq51bejoaLTzexiOfEaF0kKvB8XNXYYjV5ATNJ8XWQR7ISJ+na4FCwt4KaKtC864TWWDTxaz6lfr0B3Wf0lZLH22+BhpzrfPWFo3YGyMsOcgPU0rPHrtAzks55rqCTQEOaKTw4rfEmuMEFJK/y80GYS2jTPu0nCnJo4NdV1fVuSSD8iUFAM=
|