openurl 0.5.0 → 0.6.0

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.
@@ -12,6 +12,8 @@ require 'openurl/context_object'
12
12
  require 'openurl/context_object_entity'
13
13
  require 'openurl/transport'
14
14
 
15
+ require 'scrub_rb'
16
+
15
17
  Dir.open(File.dirname(File.expand_path(__FILE__))+'/openurl/metadata_formats').each do | file |
16
18
  next if file.match(/^\./)
17
19
  class_name = file.sub(/\.rb$/,'')
@@ -1,6 +1,6 @@
1
1
  # encoding: UTF-8
2
2
 
3
- require 'ensure_valid_encoding'
3
+ require 'scrub_rb' # backfill of String#scrub to ruby 1.9.3 and 2.0
4
4
 
5
5
  module OpenURL
6
6
 
@@ -35,9 +35,7 @@ module OpenURL
35
35
  # == Serialize a ContextObject to kev or XML :
36
36
  # ctx.kev
37
37
  # ctx.xml
38
- class ContextObject
39
- include EnsureValidEncoding
40
-
38
+ class ContextObject
41
39
  attr_reader :admin, :referent, :referringEntity, :requestor, :referrer,
42
40
  :serviceType, :resolver
43
41
  attr_accessor :foreign_keys, :openurl_ver
@@ -241,7 +239,7 @@ module OpenURL
241
239
  def import_xml(xml)
242
240
  if xml.is_a?(String)
243
241
  xml.force_encoding("UTF-8") if xml.respond_to? :force_encoding
244
- ensure_valid_encoding!(xml, :invalid => :replace)
242
+ xml.scrub!
245
243
  doc = REXML::Document.new xml.gsub(/>[\s\t]*\n*[\s\t]*</, '><').strip
246
244
  elsif xml.is_a?(REXML::Document)
247
245
  doc = xml
@@ -305,7 +303,7 @@ module OpenURL
305
303
  [values].flatten.compact.each do | v |
306
304
  v.force_encoding(source_encoding)
307
305
  if source_encoding == "UTF-8"
308
- ensure_valid_encoding!(v, :invalid => :replace )
306
+ v.scrub!
309
307
  else
310
308
  # transcode, replacing any bad chars.
311
309
  v.encode!("UTF-8", :invalid => :replace, :undef => :replace )
@@ -32,7 +32,7 @@ module OpenURL
32
32
  end
33
33
  end
34
34
 
35
- def respond_to?(message)
35
+ def respond_to?(message, include_all=false)
36
36
  # make it match method_messing
37
37
  key = message.to_s.sub(/=$/,'')
38
38
  super || (@author_keys+@metadata_keys).index(key)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openurl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2014-05-27 00:00:00.000000000 Z
13
+ date: 2014-07-15 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: marc
@@ -29,7 +29,7 @@ dependencies:
29
29
  - !ruby/object:Gem::Version
30
30
  version: '0'
31
31
  - !ruby/object:Gem::Dependency
32
- name: ensure_valid_encoding
32
+ name: scrub_rb
33
33
  requirement: !ruby/object:Gem::Requirement
34
34
  none: false
35
35
  requirements: