stash-wrapper 0.1.5 → 0.1.6

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: c68496253c2cb379be6134a3d5eeeac63a5a7069
4
- data.tar.gz: 5403fbe01b456bea4544e7c0d9713116d62d5f17
3
+ metadata.gz: b47fcabaef7739a10f5bfd3bfb6739ef6f5bf2c0
4
+ data.tar.gz: 505ea0b2ae8634662e3c4804370436c81b57563c
5
5
  SHA512:
6
- metadata.gz: e32da7b4c27e48c9e6924f0c54dec31de9e98b6212b3e5f1a3e3d80c55eb98a46319ef0fcdc222f0873b048d642c451b546c5d7448a62909268307b3f58e6fd4
7
- data.tar.gz: 658d96609a26073218fd05344a683dd5ea6879446eaa46f9875406238ceceb04443edfba9a49914a6ea971c232e80c207ff073637b501bb61f3f9ae03cc4c8b9
6
+ metadata.gz: 16dbdc7400afcb229bdd7f530227a9f8e705295550fd2a0952122f9fff46bc3b17d22cc5861e934b1de8d30b2917576a9c92f3c8cbc0c3028f5ef9bb7e76fb19
7
+ data.tar.gz: fbb69e10abfeb28e68d1425fd0ad5829cd24cd74ee16b13f02d6f5bbf58dd619de0b5013b77d2a1e975f3a1b84fb07edf7118f8511f4dc36a7cb7b4aa7a593c4
data/CHANGES.md CHANGED
@@ -1,6 +1,12 @@
1
+ # 0.1.6 (2 May 2016)
2
+
3
+ - Update to XML::MappingExtensions 0.3.6 and remove now-unnecessary namespace hacks
4
+ - Update to TypesafeEnum 0.1.7 for improved debug output
5
+
1
6
  # 0.1.5 (28 April 2016)
2
7
 
3
- - Update to XML::MappingExtensions 0.3.5
8
+ - Update to XML::MappingExtensions 0.3.5 to fix issues with `Date.xmlschema` misbehaving
9
+ in a Rails / ActiveSupport environment
4
10
 
5
11
  # 0.1.4 (25 April 2016)
6
12
 
@@ -5,7 +5,7 @@ module Stash
5
5
  NAME = 'stash-wrapper'
6
6
 
7
7
  # The version of this gem
8
- VERSION = '0.1.5'
8
+ VERSION = '0.1.6'
9
9
 
10
10
  # The copyright notice for this gem
11
11
  COPYRIGHT = 'Copyright (c) 2016 The Regents of the University of California'
@@ -10,11 +10,11 @@ module Stash
10
10
  class StashWrapper
11
11
  include ::XML::Mapping
12
12
 
13
- # The `stash_wrapper` namespace
14
- NAMESPACE = 'http://dash.cdlib.org/stash_wrapper/'
15
-
16
- # The `st` prefix for the `stash_wrapper` namespace
17
- NAMESPACE_PREFIX = 'st'
13
+ NAMESPACE = ::XML::MappingExtensions::Namespace.new(
14
+ prefix: 'st',
15
+ uri: 'http://dash.cdlib.org/stash_wrapper/',
16
+ schema_location: 'http://dash.cdlib.org/stash_wrapper/ http://dash.cdlib.org/stash_wrapper/stash_wrapper.xsd'
17
+ )
18
18
 
19
19
  root_element_name 'stash_wrapper'
20
20
 
@@ -44,6 +44,7 @@ module Stash
44
44
  inventory: inventory
45
45
  )
46
46
  self.stash_descriptive = descriptive_elements
47
+ self.namespace = NAMESPACE
47
48
  end
48
49
 
49
50
  def id_value
@@ -95,39 +96,34 @@ module Stash
95
96
  inv ? inv.files.map(&:pathname) : []
96
97
  end
97
98
 
98
- # Overrides `XML::Mapping#pre_save` to set the XML namespace and schema location.
99
- def pre_save(options = { mapping: :_default })
100
- xml = super(options)
101
- xml.add_namespace(NAMESPACE)
102
- xml.add_namespace('xsi', 'http://www.w3.org/2001/XMLSchema-instance')
103
- xml.add_attribute('xsi:schemaLocation', 'http://dash.cdlib.org/stash_wrapper/ http://dash.cdlib.org/stash_wrapper/stash_wrapper.xsd')
104
- xml
105
- end
106
-
107
- # Overrides `XML::Mapping#save_to_xml` to set the XML namespace prefix on all
108
- # `stash_wrapper` elements. (The elements in `descriptive_elements` should retain
109
- # their existing namespaces and prefixes, if any.)
110
- def save_to_xml(options = { mapping: :_default })
111
- elem = super(options)
112
- set_prefix(prefix: NAMESPACE_PREFIX, elem: elem)
113
- elem.add_namespace(nil) # clear the no-prefix namespace
114
- elem.add_namespace(NAMESPACE_PREFIX, NAMESPACE)
115
- elem
116
- end
117
-
118
- def self.parse_xml(xml_str)
119
- xml = REXML::Document.new(xml_str).root
120
- load_from_xml(xml)
121
- end
122
-
123
- private
124
-
125
- def set_prefix(prefix:, elem:)
126
- return unless elem.namespace == NAMESPACE
127
- # name= with a prefixed name sets namespace by side effect and is the only way to actually output the prefix
128
- elem.name = "#{prefix}:#{elem.name}"
129
- elem.each_element { |e| set_prefix(prefix: prefix, elem: e) }
130
- end
99
+ # # Overrides `XML::Mapping#pre_save` to set the XML namespace and schema location.
100
+ # def pre_save(options = { mapping: :_default })
101
+ # xml = super(options)
102
+ # xml.add_namespace(NAMESPACE)
103
+ # xml.add_namespace('xsi', 'http://www.w3.org/2001/XMLSchema-instance')
104
+ # xml.add_attribute('xsi:schemaLocation', 'http://dash.cdlib.org/stash_wrapper/ http://dash.cdlib.org/stash_wrapper/stash_wrapper.xsd')
105
+ # xml
106
+ # end
107
+ #
108
+ # # Overrides `XML::Mapping#save_to_xml` to set the XML namespace prefix on all
109
+ # # `stash_wrapper` elements. (The elements in `descriptive_elements` should retain
110
+ # # their existing namespaces and prefixes, if any.)
111
+ # def save_to_xml(options = { mapping: :_default })
112
+ # xml = super(options)
113
+ # set_prefix(prefix: NAMESPACE_PREFIX, elem: xml)
114
+ # xml.add_namespace(nil) # clear the no-prefix namespace
115
+ # xml.add_namespace(NAMESPACE_PREFIX, NAMESPACE)
116
+ # xml
117
+ # end
118
+ #
119
+ # private
120
+ #
121
+ # def set_prefix(prefix:, elem:)
122
+ # return unless elem.namespace == NAMESPACE
123
+ # # name= with a prefixed name sets namespace by side effect and is the only way to actually output the prefix
124
+ # elem.name = "#{prefix}:#{elem.name}"
125
+ # elem.each_element { |e| set_prefix(prefix: prefix, elem: e) }
126
+ # end
131
127
 
132
128
  end
133
129
 
@@ -207,7 +207,7 @@ module Stash
207
207
  it 'sets the correct namespace' do
208
208
  assert_st = lambda do |elem|
209
209
  actual = elem.namespace
210
- expected = StashWrapper::NAMESPACE
210
+ expected = 'http://dash.cdlib.org/stash_wrapper/'
211
211
  expect(actual).to eq(expected), "expected '#{expected}', got '#{actual}': #{elem}"
212
212
  elem.each_element { |e| assert_st.call(e) }
213
213
  end
@@ -217,7 +217,7 @@ module Stash
217
217
  it 'sets the correct namespace prefix' do
218
218
  assert_st = lambda do |elem|
219
219
  actual = elem.prefix
220
- expected = StashWrapper::NAMESPACE_PREFIX
220
+ expected = 'st'
221
221
  expect(actual).to eq(expected), "expected '#{expected}', got '#{actual}': #{elem}"
222
222
  elem.each_element { |e| assert_st.call(e) }
223
223
  end
@@ -226,8 +226,8 @@ module Stash
226
226
 
227
227
  it 'maps the namespace to the prefix' do
228
228
  assert_st = lambda do |elem|
229
- actual = elem.namespace(StashWrapper::NAMESPACE_PREFIX)
230
- expected = StashWrapper::NAMESPACE
229
+ actual = elem.namespace('st')
230
+ expected = 'http://dash.cdlib.org/stash_wrapper/'
231
231
  expect(actual).to eq(expected), "expected '#{expected}', got '#{actual}': #{elem}"
232
232
  elem.each_element { |e| assert_st.call(e) }
233
233
  end
@@ -236,7 +236,7 @@ module Stash
236
236
 
237
237
  it 'includes the prefix in the name' do
238
238
  assert_st = lambda do |elem|
239
- expect(elem.to_s).to start_with("<#{StashWrapper::NAMESPACE_PREFIX}:")
239
+ expect(elem.to_s).to start_with('<st:')
240
240
  elem.each_element { |e| assert_st.call(e) }
241
241
  end
242
242
  assert_st.call(@wrapper_xml.root)
@@ -24,8 +24,8 @@ Gem::Specification.new do |spec|
24
24
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
25
25
  spec.require_paths = ['lib']
26
26
 
27
- spec.add_dependency 'typesafe_enum', '~> 0.1', '>= 0.1.5'
28
- spec.add_dependency 'xml-mapping_extensions', '~> 0.3', '>= 0.3.5'
27
+ spec.add_dependency 'typesafe_enum', '~> 0.1', '>= 0.1.7'
28
+ spec.add_dependency 'xml-mapping_extensions', '~> 0.3', '>= 0.3.6'
29
29
 
30
30
  spec.add_development_dependency 'bundler', '~> 1.7'
31
31
  spec.add_development_dependency 'equivalent-xml', '~> 0.6.0'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stash-wrapper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Moles
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-28 00:00:00.000000000 Z
11
+ date: 2016-05-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: typesafe_enum
@@ -19,7 +19,7 @@ dependencies:
19
19
  version: '0.1'
20
20
  - - ">="
21
21
  - !ruby/object:Gem::Version
22
- version: 0.1.5
22
+ version: 0.1.7
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,7 +29,7 @@ dependencies:
29
29
  version: '0.1'
30
30
  - - ">="
31
31
  - !ruby/object:Gem::Version
32
- version: 0.1.5
32
+ version: 0.1.7
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: xml-mapping_extensions
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -39,7 +39,7 @@ dependencies:
39
39
  version: '0.3'
40
40
  - - ">="
41
41
  - !ruby/object:Gem::Version
42
- version: 0.3.5
42
+ version: 0.3.6
43
43
  type: :runtime
44
44
  prerelease: false
45
45
  version_requirements: !ruby/object:Gem::Requirement
@@ -49,7 +49,7 @@ dependencies:
49
49
  version: '0.3'
50
50
  - - ">="
51
51
  - !ruby/object:Gem::Version
52
- version: 0.3.5
52
+ version: 0.3.6
53
53
  - !ruby/object:Gem::Dependency
54
54
  name: bundler
55
55
  requirement: !ruby/object:Gem::Requirement