lib/datacite/mapping.rb in datacite-mapping-0.1.17.2 vs lib/datacite/mapping.rb in datacite-mapping-0.2.0
- old
+ new
@@ -1,38 +1,23 @@
require 'logger'
+require 'rexml/formatters/transitive' # unaccountably, xml/mapping doesn't do this
+require 'xml/mapping_extensions'
-# Module for working with the [DataCite metadata schema](https://schema.datacite.org/meta/kernel-3/index.html)
+# Module for working with the [DataCite metadata schema](https://schema.datacite.org/)
module Datacite
# Maps DataCite XML to Ruby objects
module Mapping
- Dir.glob(File.expand_path('../mapping/*.rb', __FILE__)).sort.each(&method(:require))
+ DATACITE_3_NAMESPACE = XML::MappingExtensions::Namespace.new(
+ uri: 'http://datacite.org/schema/kernel-3',
+ schema_location: 'http://schema.datacite.org/meta/kernel-3/metadata.xsd'
+ )
- class << self
- attr_writer :log
- end
+ DATACITE_4_NAMESPACE = XML::MappingExtensions::Namespace.new(
+ uri: 'http://datacite.org/schema/kernel-4',
+ schema_location: 'http://schema.datacite.org/meta/kernel-4/metadata.xsd'
+ )
- # Gets the logger for the module. Default logger logs to `$stdout`.
- # @return [Logger] the logger
- def self.log
- self.log_device = $stdout unless @log
- @log
- end
+ Dir.glob(File.expand_path('../mapping/*.rb', __FILE__)).sort.each(&method(:require))
- # Sets the log device. Defaults to `$stdout`
- # @param value [IO] the log device
- def self.log_device=(value)
- @log = new_logger(logdev: value)
- end
-
- private
-
- def self.new_logger(logdev:, level: Logger::DEBUG, shift_age: 10, shift_size: 1024 * 1024)
- logger = Logger.new(logdev, shift_age, shift_size)
- logger.level = level
- logger.formatter = proc do |severity, datetime, progname, msg|
- "#{datetime.to_time.utc} #{severity} -#{progname}- #{msg}\n"
- end
- logger
- end
end
end