zizia 3.0.0.alpha.01 → 3.1.0.alpha.01
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/.rubocop.yml +2 -0
- data/app/models/zizia/csv_import_detail.rb +13 -0
- data/app/models/zizia/pre_ingest_file.rb +6 -0
- data/app/models/zizia/pre_ingest_work.rb +6 -0
- data/app/uploaders/zizia/csv_manifest_uploader.rb +14 -2
- data/db/migrate/20190911133657_create_zizia_pre_ingest_files.rb +12 -0
- data/db/migrate/20190911134002_create_zizia_pre_ingest_works.rb +9 -0
- data/db/migrate/20190911142616_create_zizia_csv_import_details.rb +8 -0
- data/lib/zizia/version.rb +1 -1
- data/spec/dummy/app/models/user.rb +2 -0
- data/spec/dummy/db/migrate/20190911165049_create_users.rb +8 -0
- data/spec/dummy/db/schema.rb +32 -1
- data/spec/dummy/test/fixtures/users.yml +11 -0
- data/spec/dummy/test/models/user_test.rb +7 -0
- data/spec/integration/csv_import_detail_spec.rb +48 -0
- data/spec/spec_helper.rb +5 -3
- metadata +14 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a24728641684b8789177ad48a5a3053089f58b10258dc17d2ff580d09da8ca3a
|
|
4
|
+
data.tar.gz: 0eda7cd8f1446c5565bb4720ac8d633babc30653ef242fdf61e65fae1dd924ee
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2aa309d328946d8bf4bcaeeb46a0445388941105107ff5b9d079bd15138b8ad3785bc210a1b11f7ea24c52a7ba5817becf41b0897640e32ee95ddb8be4e69b31
|
|
7
|
+
data.tar.gz: 2166ccfb776ea3ffd52a63fca25e5066ea3d867698f29bf02be4a51f33b7f4c360acb2da9d9e1588e3774b35e3d30d900d2584a82ef0065b65718c194c6308d3
|
data/.rubocop.yml
CHANGED
|
@@ -64,6 +64,7 @@ RSpec/ExampleLength:
|
|
|
64
64
|
Exclude:
|
|
65
65
|
- 'spec/zizia/hyrax_basic_metadata_mapper_spec.rb'
|
|
66
66
|
- 'spec/integration/import_hyrax_csv.rb'
|
|
67
|
+
- 'spec/integration/csv_import_detail_spec.rb'
|
|
67
68
|
|
|
68
69
|
RSpec/MessageSpies:
|
|
69
70
|
Exclude:
|
|
@@ -74,6 +75,7 @@ RSpec/MultipleExpectations:
|
|
|
74
75
|
- 'spec/zizia/hyrax_basic_metadata_mapper_spec.rb'
|
|
75
76
|
- 'spec/integration/import_hyrax_csv.rb'
|
|
76
77
|
- 'spec/controllers/importer_documentation_controller_spec.rb'
|
|
78
|
+
- 'spec/integration/csv_import_detail_spec.rb'
|
|
77
79
|
|
|
78
80
|
Style/StructInheritance:
|
|
79
81
|
Enabled: false
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
module Zizia
|
|
3
|
+
class CsvImportDetail < ApplicationRecord
|
|
4
|
+
belongs_to :csv_import
|
|
5
|
+
has_many :pre_ingest_works
|
|
6
|
+
has_many :pre_ingest_files, through: :pre_ingest_works
|
|
7
|
+
|
|
8
|
+
def total_size
|
|
9
|
+
return 0 if pre_ingest_files.empty?
|
|
10
|
+
pre_ingest_files.map(&:size).sum
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -12,11 +12,11 @@ module Zizia
|
|
|
12
12
|
|
|
13
13
|
# The directory where the csv manifest will be stored.
|
|
14
14
|
def store_dir
|
|
15
|
-
Rails.root.join('tmp', 'csv_uploads')
|
|
15
|
+
manifests_path || Rails.root.join('tmp', 'csv_uploads')
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
def cache_dir
|
|
19
|
-
Rails.root.join('tmp', 'csv_uploads_cache')
|
|
19
|
+
manifests_cache_path || Rails.root.join('tmp', 'csv_uploads_cache')
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
# Add a white list of extensions which are allowed to be uploaded.
|
|
@@ -42,6 +42,18 @@ module Zizia
|
|
|
42
42
|
|
|
43
43
|
private
|
|
44
44
|
|
|
45
|
+
def manifests_path
|
|
46
|
+
return false if ENV['CSV_MANIFESTS_PATH'].nil?
|
|
47
|
+
return false unless File.directory?(ENV['CSV_MANIFESTS_PATH'])
|
|
48
|
+
ENV['CSV_MANIFESTS_PATH']
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def manifests_cache_path
|
|
52
|
+
return false if ENV['CSV_MANIFESTS_CACHE_PATH'].nil?
|
|
53
|
+
return false unless File.directory?(ENV['CSV_MANIFESTS_CACHE_PATH'])
|
|
54
|
+
ENV['CSV_MANIFESTS_CACHE_PATH']
|
|
55
|
+
end
|
|
56
|
+
|
|
45
57
|
def validate_csv
|
|
46
58
|
@validator = CsvManifestValidator.new(self)
|
|
47
59
|
@validator.validate
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
class CreateZiziaPreIngestFiles < ActiveRecord::Migration[5.1]
|
|
2
|
+
def change
|
|
3
|
+
create_table :zizia_pre_ingest_files do |t|
|
|
4
|
+
t.integer :size
|
|
5
|
+
t.text :row
|
|
6
|
+
t.integer :row_number
|
|
7
|
+
t.string :filename
|
|
8
|
+
t.belongs_to :pre_ingest_work
|
|
9
|
+
t.timestamps
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
data/lib/zizia/version.rb
CHANGED
data/spec/dummy/db/schema.rb
CHANGED
|
@@ -10,7 +10,19 @@
|
|
|
10
10
|
#
|
|
11
11
|
# It's strongly recommended that you check this file into your version control system.
|
|
12
12
|
|
|
13
|
-
ActiveRecord::Schema.define(version:
|
|
13
|
+
ActiveRecord::Schema.define(version: 201901241536541) do
|
|
14
|
+
|
|
15
|
+
create_table "users", force: :cascade do |t|
|
|
16
|
+
t.datetime "created_at", null: false
|
|
17
|
+
t.datetime "updated_at", null: false
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
create_table "zizia_csv_import_details", force: :cascade do |t|
|
|
21
|
+
t.integer "csv_import_id"
|
|
22
|
+
t.datetime "created_at", null: false
|
|
23
|
+
t.datetime "updated_at", null: false
|
|
24
|
+
t.index ["csv_import_id"], name: "index_zizia_csv_import_details_on_csv_import_id"
|
|
25
|
+
end
|
|
14
26
|
|
|
15
27
|
create_table "zizia_csv_imports", force: :cascade do |t|
|
|
16
28
|
t.integer "user_id"
|
|
@@ -21,4 +33,23 @@ ActiveRecord::Schema.define(version: 20190124153654) do
|
|
|
21
33
|
t.index ["user_id"], name: "index_zizia_csv_imports_on_user_id"
|
|
22
34
|
end
|
|
23
35
|
|
|
36
|
+
create_table "zizia_pre_ingest_files", force: :cascade do |t|
|
|
37
|
+
t.integer "size"
|
|
38
|
+
t.text "row"
|
|
39
|
+
t.integer "row_number"
|
|
40
|
+
t.string "filename"
|
|
41
|
+
t.integer "pre_ingest_work_id"
|
|
42
|
+
t.datetime "created_at", null: false
|
|
43
|
+
t.datetime "updated_at", null: false
|
|
44
|
+
t.index ["pre_ingest_work_id"], name: "index_zizia_pre_ingest_files_on_pre_ingest_work_id"
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
create_table "zizia_pre_ingest_works", force: :cascade do |t|
|
|
48
|
+
t.integer "parent_object"
|
|
49
|
+
t.integer "csv_import_detail_id"
|
|
50
|
+
t.datetime "created_at", null: false
|
|
51
|
+
t.datetime "updated_at", null: false
|
|
52
|
+
t.index ["csv_import_detail_id"], name: "index_zizia_pre_ingest_works_on_csv_import_detail_id"
|
|
53
|
+
end
|
|
54
|
+
|
|
24
55
|
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
|
2
|
+
|
|
3
|
+
# This model initially had no columns defined. If you add columns to the
|
|
4
|
+
# model remove the '{}' from the fixture names and add the columns immediately
|
|
5
|
+
# below each fixture, per the syntax in the comments below
|
|
6
|
+
#
|
|
7
|
+
one: {}
|
|
8
|
+
# column: value
|
|
9
|
+
#
|
|
10
|
+
two: {}
|
|
11
|
+
# column: value
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
RSpec.describe 'Using the CsvImportDetail models' do
|
|
6
|
+
let(:user) { User.new }
|
|
7
|
+
let(:csv_import) { Zizia::CsvImport.new }
|
|
8
|
+
let(:csv_import_detail) { Zizia::CsvImportDetail.new }
|
|
9
|
+
let(:pre_ingest_work_one) { Zizia::PreIngestWork.new }
|
|
10
|
+
let(:pre_ingest_work_two) { Zizia::PreIngestWork.new }
|
|
11
|
+
let(:pre_ingest_file_one) do
|
|
12
|
+
Zizia::PreIngestFile.new(row: 'some,row',
|
|
13
|
+
row_number: 1,
|
|
14
|
+
size: 1000)
|
|
15
|
+
end
|
|
16
|
+
let(:pre_ingest_file_two) do
|
|
17
|
+
Zizia::PreIngestFile.new(row: 'another,row',
|
|
18
|
+
row_number: 2,
|
|
19
|
+
size: 2000)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
it 'allows you to create PreIngestFiles that are associated with PreIngestWorks' do
|
|
23
|
+
pre_ingest_work_one.save
|
|
24
|
+
|
|
25
|
+
pre_ingest_work_one.pre_ingest_files << pre_ingest_file_one
|
|
26
|
+
pre_ingest_work_one.pre_ingest_files << pre_ingest_file_two
|
|
27
|
+
|
|
28
|
+
expect(pre_ingest_work_one.pre_ingest_files.length).to eq(2)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it 'allows you to associate PreIngestWorks & Files with a CsvImportDetail' do
|
|
32
|
+
user.save
|
|
33
|
+
csv_import.user = user
|
|
34
|
+
csv_import.save!
|
|
35
|
+
csv_import_detail.csv_import = csv_import
|
|
36
|
+
csv_import_detail.save!
|
|
37
|
+
|
|
38
|
+
pre_ingest_work_one.pre_ingest_files << pre_ingest_file_one
|
|
39
|
+
pre_ingest_work_one.pre_ingest_files << pre_ingest_file_two
|
|
40
|
+
csv_import_detail.pre_ingest_works << pre_ingest_work_one
|
|
41
|
+
csv_import_detail.pre_ingest_works << pre_ingest_work_two
|
|
42
|
+
|
|
43
|
+
expect(csv_import_detail.pre_ingest_files.length).to eq(2)
|
|
44
|
+
expect(csv_import_detail.pre_ingest_works.length).to eq(2)
|
|
45
|
+
|
|
46
|
+
expect(csv_import_detail.total_size).to eq(3000)
|
|
47
|
+
end
|
|
48
|
+
end
|
data/spec/spec_helper.rb
CHANGED
|
@@ -6,11 +6,13 @@ require 'pry' unless ENV['CI']
|
|
|
6
6
|
ENV['environment'] ||= 'test'
|
|
7
7
|
# Configure Rails Envinronment
|
|
8
8
|
ENV['RAILS_ENV'] = 'test'
|
|
9
|
-
require File.expand_path('../../spec/dummy/config/environment', __FILE__)
|
|
10
|
-
require 'rails/all'
|
|
11
|
-
require 'rspec/rails'
|
|
12
9
|
|
|
10
|
+
require File.expand_path("../dummy/config/environment", __FILE__)
|
|
13
11
|
ENGINE_RAILS_ROOT = File.join(File.dirname(__FILE__), '../')
|
|
12
|
+
Dir[File.join(ENGINE_RAILS_ROOT, "spec/support/**/*.rb")].each { |f| require f }
|
|
13
|
+
|
|
14
|
+
require 'rails/all'
|
|
15
|
+
require 'rspec/rails'
|
|
14
16
|
|
|
15
17
|
ActiveJob::Base.queue_adapter = :test
|
|
16
18
|
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: zizia
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.
|
|
4
|
+
version: 3.1.0.alpha.01
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Data Curation Experts
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2019-
|
|
11
|
+
date: 2019-09-12 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: active-fedora
|
|
@@ -296,6 +296,9 @@ files:
|
|
|
296
296
|
- app/jobs/zizia/start_csv_import_job.rb
|
|
297
297
|
- app/models/zizia/application_record.rb
|
|
298
298
|
- app/models/zizia/csv_import.rb
|
|
299
|
+
- app/models/zizia/csv_import_detail.rb
|
|
300
|
+
- app/models/zizia/pre_ingest_file.rb
|
|
301
|
+
- app/models/zizia/pre_ingest_work.rb
|
|
299
302
|
- app/uploaders/zizia/csv_manifest_uploader.rb
|
|
300
303
|
- app/uploaders/zizia/csv_manifest_validator.rb
|
|
301
304
|
- app/views/layouts/zizia/application.html.erb
|
|
@@ -317,6 +320,9 @@ files:
|
|
|
317
320
|
- db/migrate/201901162141281_create_zizia_csv_imports.rb
|
|
318
321
|
- db/migrate/201901162203121_add_manifest_to_zizia_csv_imports.rb
|
|
319
322
|
- db/migrate/201901241536541_add_fedora_collection_id_to_zizia_csv_imports.rb
|
|
323
|
+
- db/migrate/20190911133657_create_zizia_pre_ingest_files.rb
|
|
324
|
+
- db/migrate/20190911134002_create_zizia_pre_ingest_works.rb
|
|
325
|
+
- db/migrate/20190911142616_create_zizia_csv_import_details.rb
|
|
320
326
|
- docs/_config.yml
|
|
321
327
|
- docs/customizing_metadata.md
|
|
322
328
|
- docs/index.md
|
|
@@ -383,6 +389,7 @@ files:
|
|
|
383
389
|
- spec/dummy/app/mailers/application_mailer.rb
|
|
384
390
|
- spec/dummy/app/models/application_record.rb
|
|
385
391
|
- spec/dummy/app/models/concerns/.keep
|
|
392
|
+
- spec/dummy/app/models/user.rb
|
|
386
393
|
- spec/dummy/app/views/layouts/application.html.erb
|
|
387
394
|
- spec/dummy/app/views/layouts/mailer.html.erb
|
|
388
395
|
- spec/dummy/app/views/layouts/mailer.text.erb
|
|
@@ -415,6 +422,7 @@ files:
|
|
|
415
422
|
- spec/dummy/config/routes.rb
|
|
416
423
|
- spec/dummy/config/secrets.yml
|
|
417
424
|
- spec/dummy/config/spring.rb
|
|
425
|
+
- spec/dummy/db/migrate/20190911165049_create_users.rb
|
|
418
426
|
- spec/dummy/db/schema.rb
|
|
419
427
|
- spec/dummy/db/seeds.rb
|
|
420
428
|
- spec/dummy/lib/assets/.keep
|
|
@@ -432,10 +440,12 @@ files:
|
|
|
432
440
|
- spec/dummy/test/controllers/.keep
|
|
433
441
|
- spec/dummy/test/fixtures/.keep
|
|
434
442
|
- spec/dummy/test/fixtures/files/.keep
|
|
443
|
+
- spec/dummy/test/fixtures/users.yml
|
|
435
444
|
- spec/dummy/test/helpers/.keep
|
|
436
445
|
- spec/dummy/test/integration/.keep
|
|
437
446
|
- spec/dummy/test/mailers/.keep
|
|
438
447
|
- spec/dummy/test/models/.keep
|
|
448
|
+
- spec/dummy/test/models/user_test.rb
|
|
439
449
|
- spec/dummy/test/system/.keep
|
|
440
450
|
- spec/dummy/test/test_helper.rb
|
|
441
451
|
- spec/dummy/vendor/.keep
|
|
@@ -446,6 +456,7 @@ files:
|
|
|
446
456
|
- spec/fixtures/images/animals/cat.png
|
|
447
457
|
- spec/fixtures/images/zizia.png
|
|
448
458
|
- spec/fixtures/zizia.png
|
|
459
|
+
- spec/integration/csv_import_detail_spec.rb
|
|
449
460
|
- spec/integration/import_csv_spec.rb
|
|
450
461
|
- spec/integration/import_hyrax_csv.rb
|
|
451
462
|
- spec/models/csv_import_spec.rb
|
|
@@ -488,7 +499,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
488
499
|
- !ruby/object:Gem::Version
|
|
489
500
|
version: 1.3.1
|
|
490
501
|
requirements: []
|
|
491
|
-
rubygems_version: 3.0.
|
|
502
|
+
rubygems_version: 3.0.3
|
|
492
503
|
signing_key:
|
|
493
504
|
specification_version: 4
|
|
494
505
|
summary: Hyrax importers.
|