Class: Harvestdor::Client
- Inherits:
-
Object
- Object
- Harvestdor::Client
- Defined in:
- lib/harvestdor/client.rb
Overview
convenience methods for getting Nokogiri::XML::Document objects for pieces of the purl public xml, and errors when pieces are missing
Class Method Summary collapse
-
.default_config ⇒ Object
Set default values for the construction of Harvestdor::Client objects.
-
.logger(log_dir, log_name) ⇒ Object
Global, memoized, lazy initialized instance of a logger.
Instance Method Summary collapse
- #config ⇒ Object
-
#content_metadata(object) ⇒ Nokogiri::XML::Document
the contentMetadata for this fedora object, from the purl xml.
-
#dc(object) ⇒ Nokogiri::XML::Document
the Dublin Core for this fedora object, from the purl xml.
-
#identity_metadata(object) ⇒ Nokogiri::XML::Document
the identityMetadata for this fedora object, from the purl xml.
-
#initialize(options = {}) {|config| ... } ⇒ Client
constructor
Initialize a new instance of Harvestdor::Client.
- #logger ⇒ Object
-
#mods(druid) ⇒ Nokogiri::XML::Document
the public xml for this fedora object, from the purl server.
-
#public_xml(druid) ⇒ Nokogiri::XML::Document
the public xml for this fedora object, from the purl xml.
-
#rdf(object) ⇒ Nokogiri::XML::Document
the RDF for this fedora object, from the purl xml.
-
#rights_metadata(object) ⇒ Nokogiri::XML::Document
the rightsMetadata for this fedora object, from the purl xml.
Constructor Details
#initialize(options = {}) {|config| ... } ⇒ Client
Initialize a new instance of Harvestdor::Client
34 35 36 37 38 |
# File 'lib/harvestdor/client.rb', line 34 def initialize = {} config.configure(YAML.load_file([:config_yml_path])) if [:config_yml_path] config.configure yield(config) if block_given? end |
Class Method Details
.default_config ⇒ Object
Set default values for the construction of Harvestdor::Client objects
7 8 9 10 11 12 13 14 |
# File 'lib/harvestdor/client.rb', line 7 def self.default_config @class_config ||= Confstruct::Configuration.new( { :log_dir => LOG_DIR_DEFAULT, :log_name => LOG_NAME_DEFAULT, :purl => PURL_DEFAULT }) end |
.logger(log_dir, log_name) ⇒ Object
Global, memoized, lazy initialized instance of a logger
19 20 21 22 |
# File 'lib/harvestdor/client.rb', line 19 def self.logger(log_dir, log_name) Dir.mkdir(log_dir) unless File.directory?(log_dir) @logger ||= Logger.new(File.join(log_dir, log_name), 'daily') end |
Instance Method Details
#config ⇒ Object
40 41 42 |
# File 'lib/harvestdor/client.rb', line 40 def config @config ||= Confstruct::Configuration.new(self.class.default_config) end |
#content_metadata(object) ⇒ Nokogiri::XML::Document
the contentMetadata for this fedora object, from the purl xml
66 67 68 |
# File 'lib/harvestdor/client.rb', line 66 def object Harvestdor.(object, config.purl) end |
#dc(object) ⇒ Nokogiri::XML::Document
the Dublin Core for this fedora object, from the purl xml
98 99 100 |
# File 'lib/harvestdor/client.rb', line 98 def dc object Harvestdor.dc(object, config.purl) end |
#identity_metadata(object) ⇒ Nokogiri::XML::Document
the identityMetadata for this fedora object, from the purl xml
74 75 76 |
# File 'lib/harvestdor/client.rb', line 74 def object Harvestdor.(object, config.purl) end |
#logger ⇒ Object
44 45 46 |
# File 'lib/harvestdor/client.rb', line 44 def logger @logger ||= self.class.logger(config.log_dir, config.log_name) end |
#mods(druid) ⇒ Nokogiri::XML::Document
the public xml for this fedora object, from the purl server
51 52 53 |
# File 'lib/harvestdor/client.rb', line 51 def mods druid Harvestdor.mods(druid, config.purl) end |
#public_xml(druid) ⇒ Nokogiri::XML::Document
the public xml for this fedora object, from the purl xml
58 59 60 |
# File 'lib/harvestdor/client.rb', line 58 def public_xml druid Harvestdor.public_xml(druid, config.purl) end |
#rdf(object) ⇒ Nokogiri::XML::Document
the RDF for this fedora object, from the purl xml
90 91 92 |
# File 'lib/harvestdor/client.rb', line 90 def rdf object Harvestdor.rdf(object, config.purl) end |
#rights_metadata(object) ⇒ Nokogiri::XML::Document
the rightsMetadata for this fedora object, from the purl xml
82 83 84 |
# File 'lib/harvestdor/client.rb', line 82 def object Harvestdor.(object, config.purl) end |