Class: Libis::Format::Identifier
- Inherits:
-
Object
- Object
- 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.
37 38 39 |
# File 'lib/libis/format/identifier.rb', line 37 def xml_validations @xml_validations end |
Class Method Details
.add_xml_validation(mimetype, xsd_file) ⇒ Object
25 26 27 |
# File 'lib/libis/format/identifier.rb', line 25 def self.add_xml_validation(mimetype, xsd_file) instance.xml_validations[mimetype] = xsd_file end |
.get(file, options = {}) ⇒ Object
33 34 35 |
# File 'lib/libis/format/identifier.rb', line 33 def self.get(file, = {}) instance.get file, end |
.xml_validations ⇒ Object
29 30 31 |
# File 'lib/libis/format/identifier.rb', line 29 def self.xml_validations instance.xml_validations end |
Instance Method Details
#get(file, options = {}) ⇒ Object
39 40 41 42 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 |
# File 'lib/libis/format/identifier.rb', line 39 def get(file, = {}) [:droid] = true unless .keys.include?(:droid) || ([:tool] && ([:tool] != :droid)) [:fido] = true unless .keys.include?(:fido) || ([:tool] && ([:tool] != :fido)) [:file] = true unless .keys.include?(:file) || ([:tool] && ([:tool] != :file)) [:xml_validation] = true if [:xml_validation].nil? result = { messages: [], output: {}, formats: {} } begin get_droid_identification(file, result, ) if [:droid] rescue StandardError => e log_msg(result, :error, "Error running Droid: #{e.message} @ #{e.backtrace.first}") end begin get_fido_identification(file, result, ) if [:fido] rescue StandardError => e log_msg(result, :error, "Error running Fido: #{e.message} @ #{e.backtrace.first}") end begin get_file_identification(file, result, ) if [:file] rescue StandardError => e log_msg(result, :error, "Error running File: #{e.message} @ #{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 StandardError => e log_msg(result, :error, "Error validating XML files: #{e.message} @ #{e.backtrace.first}") end process_results(result, ![:keep_output]) result end |