stead 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -12,7 +12,6 @@ begin
12
12
  gem.authors = ["Jason Ronallo"]
13
13
  gem.add_dependency "nokogiri", ">= 1.4.1"
14
14
  gem.add_dependency "fastercsv", ">= 1.5.0"
15
- gem.add_dependency "activesupport", ">= 2.3.5"
16
15
  gem.add_dependency "trollop", ">= 1.16.2"
17
16
  gem.add_development_dependency "shoulda", ">= 0"
18
17
  gem.files = FileList["[A-Z]*", "{bin,examples,lib}/**/*"]
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.3
1
+ 0.0.4
data/lib/stead/ead.rb CHANGED
@@ -56,13 +56,14 @@ module Stead
56
56
  @component_parts.each do |cp|
57
57
  c = node(file_component_part_name)
58
58
  c['level'] = 'file'
59
- c['audience'] = 'internal' if !cp['internal only'].blank?
59
+ c['audience'] = 'internal' if !cp['internal only'].nil?
60
60
  did = node('did')
61
61
  c.add_child(did)
62
62
  add_did_nodes(cp, did)
63
63
  add_containers(cp, did)
64
64
  add_scopecontent(cp, did)
65
65
  add_accessrestrict(cp, did)
66
+ add_controlaccess(cp, c)
66
67
  add_file_component_part(cp, c)
67
68
  end
68
69
  begin
@@ -118,7 +119,7 @@ module Stead
118
119
  item = node('item')
119
120
  contents = []
120
121
  ser.each do |ser_part|
121
- contents << ser_part unless ser_part.blank?
122
+ contents << ser_part unless ser_part.nil? or ser_part.empty?
122
123
  end
123
124
  item.content = contents.join(', ')
124
125
  list.add_child(item)
@@ -151,7 +152,7 @@ module Stead
151
152
 
152
153
  def add_did_nodes(cp, did)
153
154
  field_map.each do |header, element|
154
- if !cp[header].blank?
155
+ if !cp[header].nil?
155
156
  if element.is_a? String
156
157
  node = node(element)
157
158
  node.content = cp[header]
@@ -171,7 +172,7 @@ module Stead
171
172
  ['1', '2', '3'].each do |container_number|
172
173
  container_type = cp['container ' + container_number + ' type']
173
174
  container_number = cp['container ' + container_number + ' number']
174
- if !container_type.blank? and !container_number.blank?
175
+ if !container_type.nil? and !container_number.nil?
175
176
  unless valid_container_type?(container_type)
176
177
  raise Stead::InvalidContainerType, container_type
177
178
  end
@@ -184,6 +185,25 @@ module Stead
184
185
  end
185
186
  end
186
187
 
188
+ def add_controlaccess(cp, component_part)
189
+ ['geogname', 'corpname', 'famname', 'name', 'persname', 'subject'].each do |controlaccess_type|
190
+ if cp[controlaccess_type]
191
+ controlaccess = component_part.xpath('controlaccess').first
192
+ # debugger
193
+ if !controlaccess
194
+ controlaccess = node('controlaccess')
195
+ end
196
+ controlaccess_element = node(controlaccess_type)
197
+ controlaccess_element.content = cp[controlaccess_type]
198
+ if !cp[controlaccess_type + '_source'].nil?
199
+ controlaccess_element['source'] = cp[controlaccess_type + '_source']
200
+ end
201
+ controlaccess.add_child(controlaccess_element)
202
+ component_part.add_child(controlaccess)
203
+ end
204
+ end
205
+ end
206
+
187
207
  def valid_container_type?(container_type)
188
208
  if Stead::CONTAINER_TYPES.include?(container_type)
189
209
  return true
@@ -193,7 +213,7 @@ module Stead
193
213
  end
194
214
 
195
215
  def add_scopecontent(cp, did)
196
- unless cp['scopecontent'].blank?
216
+ unless cp['scopecontent'].nil?
197
217
  scopecontent = node('scopecontent')
198
218
  p = node('p')
199
219
  p.content = cp['scopecontent']
@@ -203,7 +223,7 @@ module Stead
203
223
  end
204
224
 
205
225
  def add_accessrestrict(cp, did)
206
- unless cp['conditions governing access'].blank?
226
+ unless cp['conditions governing access'].nil?
207
227
  accessrestrict = node('accessrestrict')
208
228
  p = node('p')
209
229
  p.content = cp['conditions governing access']
@@ -266,7 +286,7 @@ module Stead
266
286
 
267
287
  def series_found?
268
288
  @component_parts.each do |row|
269
- return false if row['series number'].blank?
289
+ return false if row['series number'].nil?
270
290
  end
271
291
  end
272
292
 
data/lib/stead.rb CHANGED
@@ -49,7 +49,6 @@ require 'csv'
49
49
  if CSV.const_defined? :Reader
50
50
  require 'fastercsv'
51
51
  end
52
- require 'active_support'
53
52
 
54
53
  require 'pp'
55
54
 
data/test/helper.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require 'rubygems'
2
2
  require 'test/unit'
3
3
  require 'shoulda'
4
+ require 'ruby-debug'
4
5
 
5
6
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
7
  $LOAD_PATH.unshift(File.dirname(__FILE__))
@@ -13,7 +14,7 @@ module SteadTestHelpers
13
14
  def assert_main_elements_equal(did, example_did)
14
15
  ['unitid', 'unittitle', 'unitdate', 'extent', 'container'].each do |elem|
15
16
  #puts example_did.xpath('.//xmlns:' + elem)
16
- if !example_did.xpath('.//xmlns:' + elem).blank?
17
+ if !example_did.xpath('.//xmlns:' + elem).empty?
17
18
  did_content = did.xpath('.//xmlns:' + elem).first.content
18
19
  assert_not_nil did_content
19
20
  assert_equal example_did.xpath('.//xmlns:' + elem).first.content,
@@ -37,6 +37,24 @@ class TestSteadEadSeries < Test::Unit::TestCase
37
37
  end
38
38
  end
39
39
 
40
+ def test_has_controlaccess
41
+ assert_equal 1, @generated_ead.xpath('//xmlns:c02/xmlns:controlaccess').length
42
+ end
43
+
44
+ def test_has_controlaccess_geogname
45
+ geonames = @generated_ead.xpath('//xmlns:c02/xmlns:controlaccess/xmlns:geogname')
46
+ assert_equal 1, geonames.length
47
+ assert_equal 'Raleigh (N.C.)', geonames.first.content
48
+ assert_equal 'lcnaf', geonames.first['source']
49
+ end
50
+
51
+ def test_has_controlaccess_corpname
52
+ corpnames = @generated_ead.xpath('//xmlns:c02/xmlns:controlaccess/xmlns:corpname')
53
+ assert_equal 1, corpnames.length
54
+ assert_equal 'corpname', corpnames.first.content
55
+ assert_equal 'corpname_source', corpnames.first['source']
56
+ end
57
+
40
58
 
41
59
  end
42
60
 
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stead
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 23
4
5
  prerelease: false
5
6
  segments:
6
7
  - 0
7
8
  - 0
8
- - 3
9
- version: 0.0.3
9
+ - 4
10
+ version: 0.0.4
10
11
  platform: ruby
11
12
  authors:
12
13
  - Jason Ronallo
@@ -14,7 +15,7 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2010-08-22 00:00:00 -04:00
18
+ date: 2010-10-18 00:00:00 -04:00
18
19
  default_executable: csv2ead
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
@@ -25,6 +26,7 @@ dependencies:
25
26
  requirements:
26
27
  - - ">="
27
28
  - !ruby/object:Gem::Version
29
+ hash: 5
28
30
  segments:
29
31
  - 1
30
32
  - 4
@@ -40,6 +42,7 @@ dependencies:
40
42
  requirements:
41
43
  - - ">="
42
44
  - !ruby/object:Gem::Version
45
+ hash: 3
43
46
  segments:
44
47
  - 1
45
48
  - 5
@@ -47,49 +50,36 @@ dependencies:
47
50
  version: 1.5.0
48
51
  type: :runtime
49
52
  version_requirements: *id002
50
- - !ruby/object:Gem::Dependency
51
- name: activesupport
52
- prerelease: false
53
- requirement: &id003 !ruby/object:Gem::Requirement
54
- none: false
55
- requirements:
56
- - - ">="
57
- - !ruby/object:Gem::Version
58
- segments:
59
- - 2
60
- - 3
61
- - 5
62
- version: 2.3.5
63
- type: :runtime
64
- version_requirements: *id003
65
53
  - !ruby/object:Gem::Dependency
66
54
  name: trollop
67
55
  prerelease: false
68
- requirement: &id004 !ruby/object:Gem::Requirement
56
+ requirement: &id003 !ruby/object:Gem::Requirement
69
57
  none: false
70
58
  requirements:
71
59
  - - ">="
72
60
  - !ruby/object:Gem::Version
61
+ hash: 83
73
62
  segments:
74
63
  - 1
75
64
  - 16
76
65
  - 2
77
66
  version: 1.16.2
78
67
  type: :runtime
79
- version_requirements: *id004
68
+ version_requirements: *id003
80
69
  - !ruby/object:Gem::Dependency
81
70
  name: shoulda
82
71
  prerelease: false
83
- requirement: &id005 !ruby/object:Gem::Requirement
72
+ requirement: &id004 !ruby/object:Gem::Requirement
84
73
  none: false
85
74
  requirements:
86
75
  - - ">="
87
76
  - !ruby/object:Gem::Version
77
+ hash: 3
88
78
  segments:
89
79
  - 0
90
80
  version: "0"
91
81
  type: :development
92
- version_requirements: *id005
82
+ version_requirements: *id004
93
83
  description: Converts CSV files of a specific schema into EAD XML.
94
84
  email: jronallo@gmail.com
95
85
  executables:
@@ -113,11 +103,11 @@ files:
113
103
  - lib/stead/templates/ead.xml
114
104
  - lib/stead/templates/ead.xsd
115
105
  - lib/stead/templates/ncsu_ead.xml
106
+ - test/test_ead_no_series.rb
116
107
  - test/test_ead_bad_container_type.rb
108
+ - test/test_ead_series.rb
117
109
  - test/helper.rb
118
110
  - test/test_stead.rb
119
- - test/test_ead_no_series.rb
120
- - test/test_ead_series.rb
121
111
  has_rdoc: true
122
112
  homepage: http://github.com/jronallo/stead
123
113
  licenses: []
@@ -132,6 +122,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
132
122
  requirements:
133
123
  - - ">="
134
124
  - !ruby/object:Gem::Version
125
+ hash: 3
135
126
  segments:
136
127
  - 0
137
128
  version: "0"
@@ -140,6 +131,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
140
131
  requirements:
141
132
  - - ">="
142
133
  - !ruby/object:Gem::Version
134
+ hash: 3
143
135
  segments:
144
136
  - 0
145
137
  version: "0"
@@ -151,9 +143,9 @@ signing_key:
151
143
  specification_version: 3
152
144
  summary: Spreadsheets To Encoded Archival Description
153
145
  test_files:
146
+ - test/test_ead_no_series.rb
154
147
  - test/test_ead_bad_container_type.rb
148
+ - test/test_ead_series.rb
155
149
  - test/helper.rb
156
150
  - test/test_stead.rb
157
- - test/test_ead_no_series.rb
158
- - test/test_ead_series.rb
159
151
  - examples/ncsu.rb