Class: Libis::Format::Identifier
- Includes:
- Tools::Logger, Singleton
- Defined in:
- lib/libis/format/identifier.rb
Instance Attribute Summary collapse
-
#xml_validations ⇒ Object
readonly
Returns the value of attribute xml_validations.
Class Method Summary collapse
- .add_xml_validation(mimetype, xsd_file) ⇒ Object
- .get(file, options = {}) ⇒ Object
- .xml_validations ⇒ Object
Instance Method Summary collapse
Instance Attribute Details
#xml_validations ⇒ Object (readonly)
Returns the value of attribute xml_validations.
41 42 43 |
# File 'lib/libis/format/identifier.rb', line 41 def xml_validations @xml_validations end |
Class Method Details
.add_xml_validation(mimetype, xsd_file) ⇒ Object
29 30 31 |
# File 'lib/libis/format/identifier.rb', line 29 def self.add_xml_validation(mimetype, xsd_file) instance.xml_validations[mimetype] = xsd_file end |
.get(file, options = {}) ⇒ Object
37 38 39 |
# File 'lib/libis/format/identifier.rb', line 37 def self.get(file, = {}) instance.get file, end |
.xml_validations ⇒ Object
33 34 35 |
# File 'lib/libis/format/identifier.rb', line 33 def self.xml_validations instance.xml_validations end |
Instance Method Details
#get(file, options = {}) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/libis/format/identifier.rb', line 43 def get(file, = {}) [:droid] = true unless .keys.include?(:droid) or ([:tool] and [:tool] != :droid) [:fido] = true unless .keys.include?(:fido) or ([:tool] and [:tool] != :fido) [:file] = true unless .keys.include?(:file) or ([:tool] and [:tool] != :file) [:xml_validation] = true if [:xml_validation].nil? result = {messages: [], output: {}, formats: {}} begin get_droid_identification(file, result, ) if [:droid] rescue => e log_msg(result, :error, "Error running Droid: #{e.} @ #{e.backtrace.first}") end begin get_fido_identification(file, result, ) if [:fido] rescue => e log_msg(result, :error, "Error running Fido: #{e.} @ #{e.backtrace.first}") end begin get_file_identification(file, result, ) if [:file] rescue => e log_msg(result, :error, "Error running File: #{e.} @ #{e.backtrace.first}") end # Let's not waiste time on this. If not standard, it will fail in Rosetta anyway. # get_extension_identification(file, options[:recursive], result) # determine XML type. Add custom types at runtime with # Libis::Tools::Format::Identifier.add_xml_validation('my_type', '/path/to/my_type.xsd') begin validate_against_xml_schema(result, [:base_dir]) if [:xml_validation] rescue => e log_msg(result, :error, "Error validating XML files: #{e.} @ #{e.backtrace.first}") end process_results(result, ![:keep_output]) result end |