bulk_ops 0.1.22 → 0.1.23

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d0b68ae5923dae38908ff5382d52aba0fa514d0cf9e714eefcfb46013ec9ce02
4
- data.tar.gz: 175b647ebf14fb4e432861c0185d9bf142d666e4df29129631d064517f55f588
3
+ metadata.gz: 3653b9554a93348ce398063d0b5fb98d01e075ac70efaee09b3081f49fa036e1
4
+ data.tar.gz: 01eb0bdb7084fb3e0d37b417d82b47772dc5d7734428f47f91168f81724c2139
5
5
  SHA512:
6
- metadata.gz: 4209b3080bd3e6b4e5df1ef727e1db943252b0d32169bb080db61e6ed01b4ba93fff56303a38d6e655eda22f82377e06a1d847c7d47df8d664f7af6e5bf49d75
7
- data.tar.gz: ac685fa72de08e26d4fe403b57143399602986aa3cf2600c00f2c55a86788bdefa5cfc0dc250d364a8b808ed1f856ea8f84c5e7dd8c88107859d21783b6ca55c
6
+ metadata.gz: 4d77355a39703eca5010a42b3bfcb0bcd872468e77b9b15e8f57bc68042dc684c2afe57d296c858cd5d6a68e60668c6bd2a11f4e3125e1d428dd5cd1e5dd1e2e
7
+ data.tar.gz: 6ee7e9c2d50231d555a9adde17a6c27b6f52041533e86a9727bb9d9caf2eafb9f8ba18e6cae76f8ef010980d3b09981e9c7e794ed54dd1b8dbab776060e923bc
@@ -2,7 +2,7 @@ require "octokit"
2
2
  require "socket"
3
3
  require "securerandom"
4
4
  require 'base64'
5
-
5
+ require 'erb'
6
6
  class BulkOps::GithubAccess
7
7
 
8
8
  attr_accessor :name
@@ -272,8 +272,6 @@ class BulkOps::GithubAccess
272
272
  end
273
273
 
274
274
  def github_config
275
- @github_config ||= YAML.load_file("#{Rails.root.to_s}/config/github.yml")[Rails.env]
275
+ @github_config ||= YAML.load(ERB.new(File.read("#{Rails.root}/config/github.yml")).result)[Rails.env]
276
276
  end
277
-
278
-
279
277
  end
@@ -1,3 +1,4 @@
1
+
1
2
  class BulkOps::Parser
2
3
  require 'uri'
3
4
 
@@ -8,7 +9,7 @@ class BulkOps::Parser
8
9
  def self.is_file_set? metadata, row_number
9
10
  return false unless metadata[row_number].present?
10
11
  # If the work type is explicitly specified, use that
11
- if (type_key = metadata[row_number].to_h.keys.find{|key| key.downcase.gsub(/[_\-\s]/,"").include?("worktype") })
12
+ if (type_key = metadata[row_number].to_h.keys.find{|key| key.to_s.downcase.gsub(/[_\-\s]/,"").include?("worktype") })
12
13
  return true if metadata[row_number][type_key].downcase == "fileset"
13
14
  return false if metadata[row_number][type_key].present?
14
15
  end
@@ -57,6 +58,7 @@ class BulkOps::Parser
57
58
  (0...@raw_row.length).each do |i|
58
59
  header = @raw_row.headers[i]
59
60
  value = @raw_row[i]
61
+ next unless value.present?
60
62
  # separate values in identical columns using the separator
61
63
  row[header] = (Array(row[header]) << value).join(BulkOps::SEPARATOR)
62
64
  end
@@ -65,9 +67,9 @@ class BulkOps::Parser
65
67
 
66
68
  def connect_existing_work
67
69
  return unless (column_name = operation.options["update_identifier"])
68
- return unless (key = @raw_row.keys.find{|key| key.to_s.parameterize.downcase.gsub("_","") == column_name.to_s.parameterize.downcase.gsub("_","")})
69
- return unless (value = @raw_row[key])
70
- return unless (work_id = find_work_id_from_unique_metadata(key, value))
70
+ return unless (key = @raw_row.to_h.keys.find{|key| key.to_s.parameterize.downcase.gsub("_","") == column_name.to_s.parameterize.downcase.gsub("_","")})
71
+ return unless (value = @raw_row[key]).present?
72
+ return unless (work_id = find_work_id_from_unique_metadata(key, value))
71
73
  proxy.update(work_id: work_id)
72
74
  end
73
75
 
@@ -76,7 +78,7 @@ class BulkOps::Parser
76
78
  query = "_query_:\"{!dismax qf=#{field_solr_name}}#{value}\""
77
79
  response = ActiveFedora::SolrService.instance.conn.get(ActiveFedora::SolrService.select_path, params: { fq: query, rows: 1, start: 0})["response"]
78
80
  if response["numFound"] > 1
79
- report_error( :id_not_unique , "", row_number: row_number, object_id: @proxy.id, options_name: field_name, option_values: value ) unless label
81
+ report_error( :id_not_unique , "", row_number: row_number, object_id: @proxy.id, options_name: field_name, option_values: value )
80
82
  end
81
83
  return response["docs"][0]["id"]
82
84
  end
@@ -1,3 +1,3 @@
1
1
  module BulkOps
2
- VERSION = "0.1.22"
2
+ VERSION = "0.1.23"
3
3
  end
@@ -76,7 +76,7 @@ class BulkOps::WorkJob < ActiveJob::Base
76
76
  end
77
77
  else
78
78
  @work = workClass.capitalize.constantize.new
79
- return :ingest
79
+ return :create
80
80
  end
81
81
  end
82
82
 
@@ -105,9 +105,4 @@ class BulkOps::WorkJob < ActiveJob::Base
105
105
  @work_proxy.update(atts)
106
106
  end
107
107
 
108
- def define_work(workClass)
109
- #override this unless you want a simple ingest
110
- @work = workClass.capitalize.constantize.new
111
- end
112
-
113
108
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bulk_ops
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.22
4
+ version: 0.1.23
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ned Henry, UCSC Library Digital Initiatives
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-12-03 00:00:00.000000000 Z
11
+ date: 2020-01-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails