stead 0.0.14 → 0.0.15

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
  SHA1:
3
- metadata.gz: 889acd97bcc24083e99e8a6c21f778fce0a65ebd
4
- data.tar.gz: 8b5a7aab6f008f796fab79f53bd04d692dcdc860
3
+ metadata.gz: 612f8e899a5d1487b510b0944743fcd6b04a7f10
4
+ data.tar.gz: 5e5cad07f6262a3c2c5b4b579cd2ebf78b7ba7c9
5
5
  SHA512:
6
- metadata.gz: 341cc20ac10238371315f22ab2b1c9316dfab9d941053c1a1f51586c5350ea282b9a49d6feb381c3038324c72705db4f303db932aae366dd76cc79a855118567
7
- data.tar.gz: 4013cfcae73788184505206ef101086cec4a52dad96292ad080b99ba72f5fe3828a3e793c4c64ec250c790cce7d78af1d3e9de9609c0768867cabe22c9b0a5ae
6
+ metadata.gz: a53db52e1a837a8d245e91c15e5e9a2cb4c2b3f1fd5f03c6a32f0907989fc6d9bb42a981694543efc5b658d9167013646bb2fb3898f0921d91aa1fd7ddf3cb07
7
+ data.tar.gz: 8df260dedfa4aac0100d1dfdcd374594b559bbd51a14c431885ae2de482c19403992596456a15671eaa290fd35beb4533d7ec4f00d50529b0c3f229437499c7e
data/bin/csv2ead CHANGED
@@ -25,6 +25,7 @@ EOS
25
25
  opt :output, 'Save the file by specifying the filename', :type => String
26
26
  opt :pretty, 'If --output is specified this will pretty indent the container list.'
27
27
  opt :stdout, 'Output full EAD to terminal'
28
+ opt :idcontainers, 'Add id attributes to containers to show parent child relationships among containers in same component part.'
28
29
  end
29
30
 
30
31
  # unless opts[:output] or opts[:stdout]
@@ -45,6 +46,7 @@ ead_options = {}
45
46
  basename = File.basename(opts[:csv], '.csv')
46
47
  ead_options[:eadid] = basename.sub(/_container_list.*$/, '')
47
48
  ead_options[:base_url] = opts[:baseurl] if opts[:baseurl]
49
+ ead_options[:idcontainers] = true if opts[:idcontainers]
48
50
  [:template, :url].each do |key|
49
51
  ead_options[key] = opts[key] if opts[key]
50
52
  end
data/lib/stead/ead.rb CHANGED
@@ -10,6 +10,7 @@ module Stead
10
10
  @base_url = opts[:base_url] if opts[:base_url]
11
11
  # component_parts are the rows in the csv file
12
12
  @component_parts = csv_to_a
13
+ @idcontainers = opts[:idcontainers]
13
14
  end
14
15
 
15
16
  def pick_template(opts)
@@ -218,6 +219,7 @@ module Stead
218
219
  end
219
220
 
220
221
  def add_containers(cp, did)
222
+ identifier = nil
221
223
  ['1', '2', '3'].each do |container_number|
222
224
  container_type = cp['container ' + container_number + ' type']
223
225
  container_number = cp['container ' + container_number + ' number']
@@ -234,6 +236,16 @@ module Stead
234
236
  container['type'] = container_type
235
237
  container['label'] = cp['instance type'] if cp['instance type']
236
238
  container.content = container_number
239
+
240
+ if @idcontainers
241
+ # if there is already an identifier then apply it as a parent attribute
242
+ if identifier
243
+ container['parent'] = identifier
244
+ end
245
+ identifier = stead_uuid
246
+ container['id'] = identifier
247
+ end
248
+
237
249
  did.add_child(container)
238
250
  end
239
251
  end
@@ -353,6 +365,14 @@ module Stead
353
365
  end
354
366
  end
355
367
 
368
+ private
369
+
370
+ def stead_uuid
371
+ uuid = SecureRandom.uuid
372
+ cleaned_uuid = uuid.gsub('-', '')
373
+ "stead_#{cleaned_uuid}"
374
+ end
375
+
356
376
  end
357
377
  end
358
378
 
data/lib/stead.rb CHANGED
@@ -46,6 +46,7 @@ end
46
46
  require 'rubygems'
47
47
  require 'nokogiri'
48
48
  require 'csv'
49
+ require 'securerandom'
49
50
 
50
51
  require 'pp'
51
52
 
data/stead.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "stead"
8
- s.version = "0.0.14"
8
+ s.version = "0.0.15"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Jason Ronallo"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stead
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.14
4
+ version: 0.0.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Ronallo
@@ -181,7 +181,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
181
181
  version: '0'
182
182
  requirements: []
183
183
  rubyforge_project:
184
- rubygems_version: 2.2.2
184
+ rubygems_version: 2.4.3
185
185
  signing_key:
186
186
  specification_version: 3
187
187
  summary: Spreadsheets To Encoded Archival Description