darlingtonia 0.2.0 → 0.3.0
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 +4 -4
- data/.gitignore +1 -0
- data/CHANGELOG.md +11 -0
- data/lib/darlingtonia/input_record.rb +10 -0
- data/lib/darlingtonia/parsers/csv_parser.rb +2 -0
- data/lib/darlingtonia/version.rb +1 -1
- data/spec/darlingtonia/csv_parser_spec.rb +17 -7
- data/spec/darlingtonia/input_record_spec.rb +26 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: de3308c4bc712e18cdca102c0dd860638aad4ffc
|
4
|
+
data.tar.gz: 2ee3c0231d0ee94f69c9b95bf8f07b84d67c42e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b0057d871e574a744e6b9d2c53f9fef71e93b5b6cc3259a8a5f212469123e57595eba3ee93ab9bd9764c9dede09459c4171fb5e3301b493cf11daf3c9c5f22f7
|
7
|
+
data.tar.gz: d7907d65a9c6a97067ee12f1c5a0732b0305858bb8d49bd7e5440415e7f0f307f30024ddf727fd48b8a5ae131adc4a78f4232e135f52909e0dbaea46c351449f
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
0.3.0 - Fri Jan 19, 2018
|
2
|
+
------------------------
|
3
|
+
|
4
|
+
Representative files.
|
5
|
+
|
6
|
+
- `ImportRecord` now passes through a `#representative_file` to its mapper,
|
7
|
+
returning `nil` if the mapper does not provide such a method.
|
8
|
+
- `CsvParser#records` now returns an empty record collection if it is given
|
9
|
+
invalid CSV input. This allows cleaner handling in other validations and
|
10
|
+
imports.
|
11
|
+
|
1
12
|
0.2.0 - Wed Jan 17, 2018
|
2
13
|
------------------------
|
3
14
|
|
@@ -29,6 +29,16 @@ module Darlingtonia
|
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
+
##
|
33
|
+
# @return [String, nil] an identifier for the representative file; nil if
|
34
|
+
# none is given.
|
35
|
+
def representative_file
|
36
|
+
return mapper.representative_file if
|
37
|
+
mapper.respond_to?(:representative_file)
|
38
|
+
|
39
|
+
nil
|
40
|
+
end
|
41
|
+
|
32
42
|
##
|
33
43
|
# Respond to methods matching mapper fields
|
34
44
|
def method_missing(method_name, *args, &block)
|
data/lib/darlingtonia/version.rb
CHANGED
@@ -34,16 +34,26 @@ EOS
|
|
34
34
|
end
|
35
35
|
|
36
36
|
describe '#records' do
|
37
|
-
|
37
|
+
context 'with valid content' do
|
38
|
+
include_context 'with content'
|
39
|
+
|
40
|
+
it 'has the correct titles' do
|
41
|
+
expect(parser.records.map(&:title))
|
42
|
+
.to contain_exactly(['The Moomins and the Great Flood'],
|
43
|
+
['Comet in Moominland'])
|
44
|
+
end
|
38
45
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
['Comet in Moominland'])
|
46
|
+
it 'has correct other fields' do
|
47
|
+
expect(parser.records.map(&:date)).to contain_exactly(['1945'], ['1946'])
|
48
|
+
end
|
43
49
|
end
|
44
50
|
|
45
|
-
|
46
|
-
|
51
|
+
context 'with invalid file' do
|
52
|
+
let(:file) { File.open('spec/fixtures/bad_example.csv') }
|
53
|
+
|
54
|
+
it 'is empty' do
|
55
|
+
expect(parser.records.to_a).to be_empty
|
56
|
+
end
|
47
57
|
end
|
48
58
|
end
|
49
59
|
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'spec_helper'
|
4
|
+
|
3
5
|
describe Darlingtonia::InputRecord do
|
4
6
|
subject(:record) { described_class.from(metadata: metadata) }
|
5
7
|
|
@@ -17,6 +19,30 @@ describe Darlingtonia::InputRecord do
|
|
17
19
|
it 'handles basic text fields' do
|
18
20
|
expect(record.attributes).to include(:title, :description)
|
19
21
|
end
|
22
|
+
|
23
|
+
it 'does not include representative_file' do
|
24
|
+
expect(record.attributes).not_to include(:representative_file)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe '#representative_file' do
|
29
|
+
it 'is nil if mapper does not provide a representative file' do
|
30
|
+
expect(record.representative_file).to be_nil
|
31
|
+
end
|
32
|
+
|
33
|
+
context 'when mapper provides representative_file' do
|
34
|
+
let(:representative_file) { :A_DUMMY_FILE }
|
35
|
+
|
36
|
+
before do
|
37
|
+
allow(record.mapper)
|
38
|
+
.to receive(:representative_file)
|
39
|
+
.and_return(representative_file)
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'is the file from the mapper' do
|
43
|
+
expect(record.representative_file).to eql representative_file
|
44
|
+
end
|
45
|
+
end
|
20
46
|
end
|
21
47
|
|
22
48
|
describe 'mapped fields' do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: darlingtonia
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tom Johnson
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2018-01-
|
12
|
+
date: 2018-01-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: active-fedora
|