hydra-works 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +17 -8
  3. data/README.md +9 -9
  4. data/hydra-works.gemspec +3 -4
  5. data/lib/hydra/works.rb +22 -13
  6. data/lib/hydra/works/characterization.rb +31 -0
  7. data/lib/hydra/works/characterization/schema/audio_schema.rb +12 -0
  8. data/lib/hydra/works/characterization/schema/base_schema.rb +17 -0
  9. data/lib/hydra/works/characterization/schema/document_schema.rb +18 -0
  10. data/lib/hydra/works/characterization/schema/image_schema.rb +22 -0
  11. data/lib/hydra/works/characterization/schema/video_schema.rb +9 -0
  12. data/lib/hydra/works/models/characterization/already_there_strategy.rb +12 -0
  13. data/lib/hydra/works/models/characterization/fits_datastream.rb +162 -0
  14. data/lib/hydra/works/models/concerns/collection_behavior.rb +42 -34
  15. data/lib/hydra/works/models/concerns/file_set/characterization/audio.rb +14 -0
  16. data/lib/hydra/works/models/concerns/file_set/characterization/base.rb +23 -0
  17. data/lib/hydra/works/models/concerns/file_set/characterization/document.rb +10 -0
  18. data/lib/hydra/works/models/concerns/file_set/characterization/image.rb +10 -0
  19. data/lib/hydra/works/models/concerns/file_set/characterization/video.rb +17 -0
  20. data/lib/hydra/works/models/concerns/{generic_file → file_set}/contained_files.rb +1 -1
  21. data/lib/hydra/works/models/concerns/file_set/derivatives.rb +27 -0
  22. data/lib/hydra/works/models/concerns/{generic_file → file_set}/mime_types.rb +1 -1
  23. data/lib/hydra/works/models/concerns/{generic_file → file_set}/versioned_content.rb +2 -2
  24. data/lib/hydra/works/models/concerns/{generic_file → file_set}/virus_check.rb +1 -1
  25. data/lib/hydra/works/models/concerns/file_set_behavior.rb +67 -0
  26. data/lib/hydra/works/models/concerns/generic_file_behavior.rb +4 -50
  27. data/lib/hydra/works/models/concerns/generic_work_behavior.rb +5 -77
  28. data/lib/hydra/works/models/concerns/work_behavior.rb +118 -0
  29. data/lib/hydra/works/models/file_set.rb +7 -0
  30. data/lib/hydra/works/models/generic_file.rb +8 -8
  31. data/lib/hydra/works/models/generic_work.rb +15 -4
  32. data/lib/hydra/works/models/work.rb +6 -0
  33. data/lib/hydra/works/services/{generic_file/add_file_to_generic_file.rb → add_file_to_file_set.rb} +20 -20
  34. data/lib/hydra/works/services/add_file_to_generic_file.rb +8 -0
  35. data/lib/hydra/works/services/characterization_service.rb +118 -0
  36. data/lib/hydra/works/services/persist_derivative.rb +35 -0
  37. data/lib/hydra/works/services/{generic_file/upload_file_to_generic_file.rb → upload_file_to_file_set.rb} +3 -3
  38. data/lib/hydra/works/services/upload_file_to_generic_file.rb +8 -0
  39. data/lib/hydra/works/version.rb +1 -1
  40. data/lib/hydra/works/vocab/works_terms.rb +2 -2
  41. data/spec/fixtures/fits_0.6.2_avi.xml +29 -0
  42. data/spec/fixtures/fits_0.6.2_jp2.xml +36 -0
  43. data/spec/fixtures/fits_0.6.2_jpg.xml +43 -0
  44. data/spec/fixtures/fits_0.6.2_pdf.xml +42 -0
  45. data/spec/fixtures/fits_0.8.5_avi.xml +50 -0
  46. data/spec/fixtures/fits_0.8.5_docx.xml +41 -0
  47. data/spec/fixtures/fits_0.8.5_jp2.xml +51 -0
  48. data/spec/fixtures/fits_0.8.5_mp3.xml +47 -0
  49. data/spec/fixtures/fits_0.8.5_mp4.xml +47 -0
  50. data/spec/fixtures/fits_0.8.5_pdf.xml +54 -0
  51. data/spec/fixtures/pdf_fits.xml +54 -0
  52. data/spec/hydra/works/models/collection_spec.rb +58 -326
  53. data/spec/hydra/works/models/concerns/{generic_file → file_set}/contained_files_spec.rb +16 -16
  54. data/spec/hydra/works/models/concerns/{generic_file → file_set}/mime_types_spec.rb +2 -2
  55. data/spec/hydra/works/models/concerns/file_set/versioned_content_spec.rb +32 -0
  56. data/spec/hydra/works/models/concerns/{generic_file → file_set}/virus_check_spec.rb +3 -3
  57. data/spec/hydra/works/models/concerns/file_set_behavior_spec.rb +12 -0
  58. data/spec/hydra/works/models/generic_file_spec.rb +16 -13
  59. data/spec/hydra/works/models/generic_work_spec.rb +148 -318
  60. data/spec/hydra/works/services/{generic_file/add_file_to_generic_file_spec.rb → add_file_to_file_set_spec.rb} +4 -4
  61. data/spec/hydra/works/services/characterization_service_spec.rb +199 -0
  62. data/spec/hydra/works/services/persist_derivatives_spec.rb +57 -29
  63. data/spec/hydra/works/services/{generic_file/upload_file_spec.rb → upload_file_spec.rb} +7 -17
  64. data/spec/hydra/works_spec.rb +23 -59
  65. data/spec/spec_helper.rb +4 -2
  66. data/spec/support/file_set_helper.rb +14 -0
  67. metadata +84 -55
  68. data/lib/hydra/works/errors/full_text_extraction_error.rb +0 -5
  69. data/lib/hydra/works/models/concerns/block_child_objects.rb +0 -22
  70. data/lib/hydra/works/models/concerns/generic_file/derivatives.rb +0 -26
  71. data/lib/hydra/works/services/generic_file/full_text_extraction_service.rb +0 -57
  72. data/lib/hydra/works/services/generic_file/generate_thumbnail.rb +0 -13
  73. data/lib/hydra/works/services/generic_file/persist_derivative.rb +0 -20
  74. data/spec/hydra/works/models/concerns/block_child_objects_spec.rb +0 -17
  75. data/spec/hydra/works/models/concerns/generic_file/versioned_content_spec.rb +0 -32
  76. data/spec/hydra/works/models/concerns/generic_file_behavior_spec.rb +0 -12
  77. data/spec/hydra/works/services/full_text_extraction_service_spec.rb +0 -89
  78. data/spec/hydra/works/services/generic_file/generate/thumbnail_spec.rb +0 -19
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 28a2824769ab44dca4138961476455d25db0d016
4
- data.tar.gz: 7e0c7dae7cc6873680eb07bf882a1cc1b008e13e
3
+ metadata.gz: 1f59d9e4057f3221480712f84c8c1eca414d64c1
4
+ data.tar.gz: 9aaa3a1afbcb5e27e5998822959d988f34d01101
5
5
  SHA512:
6
- metadata.gz: 0ea7c389ceaeffe31367dffe19490162932afa1abeb5f5016ea2842003c7f36cc00bbe25a7b6160766f684fcb6009817074532d0bfc936928c6b0f570f9767be
7
- data.tar.gz: cc6825f4d60eed260531714eb646d512debcdb004feba0c81f80b253c7ba935289a614202efa225966f178d677ea99898b135cd8619f911d7401aaf0f9b802e0
6
+ metadata.gz: 539c2c4c03e59c2e4d1ee667ad087bf0aa28551b7862acf32df477d42a137e03f1024b7f94fad1bb1fc12bbab6a82338f443b568762470c0f092c8d6c86934bf
7
+ data.tar.gz: 43ae1663d7070c525b6be37a1cb03ded81c4a7fa135ecb243d8fe639806414325ff4401c5d5fcde35415a153479daa7a3c6185b55281328dc705ad6f4fe32b42
data/.rubocop.yml CHANGED
@@ -15,23 +15,28 @@ Metrics/LineLength:
15
15
 
16
16
  Metrics/CyclomaticComplexity:
17
17
  Exclude:
18
- - lib/hydra/works/services/generic_file/add_file_to_generic_file.rb
18
+ - lib/hydra/works/services/add_file_to_file_set.rb
19
19
 
20
20
  Metrics/PerceivedComplexity:
21
21
  Exclude:
22
- - lib/hydra/works/services/generic_file/add_file_to_generic_file.rb
22
+ - lib/hydra/works/services/add_file_to_file_set.rb
23
23
 
24
24
  Metrics/MethodLength:
25
25
  Exclude:
26
- - lib/hydra/works/services/generic_file/add_file_to_generic_file.rb
27
- - lib/hydra/works/models/concerns/generic_file/virus_check.rb
26
+ - lib/hydra/works/services/add_file_to_file_set.rb
27
+ - lib/hydra/works/models/concerns/file_set/virus_check.rb
28
+ - lib/hydra/works/models/characterization/fits_datastream.rb
29
+
30
+ Metrics/ClassLength:
31
+ Exclude:
32
+ - lib/hydra/works/models/characterization/fits_datastream.rb
28
33
 
29
34
  Metrics/AbcSize:
30
35
  Exclude:
31
- - lib/hydra/works/services/generic_file/add_file_to_generic_file.rb
32
- - lib/hydra/works/services/generic_file/full_text_extraction_service.rb
33
- - lib/hydra/works/models/concerns/generic_file/mime_types.rb
34
- - lib/hydra/works/models/concerns/generic_file/virus_check.rb
36
+ - lib/hydra/works/services/add_file_to_file_set.rb
37
+ - lib/hydra/works/services/full_text_extraction_service.rb
38
+ - lib/hydra/works/models/concerns/file_set/mime_types.rb
39
+ - lib/hydra/works/models/concerns/file_set/virus_check.rb
35
40
 
36
41
  Style/CollectionMethods:
37
42
  PreferredMethods:
@@ -70,3 +75,7 @@ RSpec/FilePath:
70
75
 
71
76
  RSpec/InstanceVariable:
72
77
  Enabled: false
78
+
79
+ RSpec/DescribedClass:
80
+ Exclude:
81
+ - spec/hydra/works/models/concerns/generic_file/characterization_spec.rb
data/README.md CHANGED
@@ -11,9 +11,9 @@
11
11
 
12
12
  The Hydra::Works gem provides a set of [Portland Common Data Model](https://github.com/duraspace/pcdm/wiki)-compliant ActiveFedora models and associated behaviors around the broad concept of multi-file "works", the need for which was expressed by a variety of [community use cases](https://github.com/projecthydra-labs/hydra-works/tree/master/use-cases). The Hydra::Works domain model includes:
13
13
 
14
- * **GenericFile**: a *Hydra::PCDM::Object* that encapsulates one or more directly related *Hydra::PCDM::File*s, such as a PDF document, its derivatives, and extracted full-text
15
- * **GenericWork**: a *Hydra::PCDM::Object* that holds zero or more **GenericFile**s and zero or more **GenericWork**s
16
- * **Collection**: a *Hydra::PCDM::Collection* that indirectly contains zero or more **GenericWork**s and zero or more **Collection**s
14
+ * **FileSet**: a *Hydra::PCDM::Object* that encapsulates one or more directly related *Hydra::PCDM::File*s, such as a PDF document, its derivatives, and extracted full-text
15
+ * **GenericWork**: a *Hydra::PCDM::Object* that holds zero or more **FileSets**s and zero or more **Work**s (often you won't use GenericWork, but instead write your own Work class)
16
+ * **Collection**: a *Hydra::PCDM::Collection* that indirectly contains zero or more **Work**s and zero or more **Collection**s
17
17
 
18
18
  View [a diagram of the domain model](https://docs.google.com/drawings/d/1-NkkRPpGpZGoTimEpYTaGM1uUPRaT0SamuWDITvtG_8/edit).
19
19
 
@@ -43,18 +43,18 @@ class Collection < ActiveFedora::Base
43
43
  end
44
44
 
45
45
  class Book < ActiveFedora::Base
46
- include Hydra::Works::GenericWorkBehavior
46
+ include Hydra::Works::WorkBehavior
47
47
  end
48
48
 
49
49
  class Page < ActiveFedora::Base
50
- include Hydra::Works::GenericFileBehavior
50
+ include Hydra::Works::FileSetBehavior
51
51
  end
52
52
 
53
53
  collection = Collection.create
54
54
  book = BookWork.create
55
55
  page = Page.create
56
56
 
57
- collection.generic_works << book
57
+ collection.works << book
58
58
  collection.save
59
59
  book.generic_files << page
60
60
  book.save
@@ -70,12 +70,12 @@ To turn on virus detection, install clamav on your system and add the `clamav` g
70
70
 
71
71
  gem 'clamav'
72
72
 
73
- Then include the `VirusCheck` module in your `GenericFile` class:
73
+ Then include the `VirusCheck` module in your `FileSet` class:
74
74
 
75
75
  ```ruby
76
76
  class BookFiles < ActiveFedora::Base
77
- include Hydra::Works::GenericFileBehavior
78
- include Hydra::Works::GenericFile::VirusCheck
77
+ include Hydra::Works::FileSetBehavior
78
+ include Hydra::Works::VirusCheck
79
79
  end
80
80
  ```
81
81
 
data/hydra-works.gemspec CHANGED
@@ -18,10 +18,9 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ['lib']
20
20
 
21
- spec.add_dependency 'hydra-pcdm', '~> 0.2'
22
- spec.add_dependency 'hydra-derivatives', '~> 2.0'
23
- spec.add_dependency 'active-fedora', '>= 9.4.1'
24
- spec.add_dependency 'activefedora-aggregation', '~> 0.4'
21
+ spec.add_dependency 'hydra-pcdm', '~> 0.3'
22
+ spec.add_dependency 'hydra-derivatives', '~> 3.0'
23
+ spec.add_dependency 'hydra-file_characterization', '~> 0.3', '>= 0.3.3'
25
24
 
26
25
  spec.add_development_dependency 'bundler', '~> 1.7'
27
26
  spec.add_development_dependency 'rake', '~> 10.0'
data/lib/hydra/works.rb CHANGED
@@ -14,29 +14,38 @@ module Hydra
14
14
  end
15
15
  end
16
16
 
17
+ autoload_under 'models/concerns/file_set' do
18
+ autoload :Derivatives
19
+ autoload :MimeTypes
20
+ autoload :ContainedFiles
21
+ autoload :VersionedContent
22
+ autoload :VirusCheck
23
+ end
24
+
25
+ autoload :Characterization
26
+
17
27
  autoload_under 'models' do
18
28
  autoload :Collection
29
+ autoload :FileSet
19
30
  autoload :GenericWork
20
- autoload :GenericFile
31
+ autoload :GenericFile # Deprecated. Remove in 0.4.0
21
32
  end
22
33
 
23
34
  autoload_under 'models/concerns' do
24
35
  autoload :CollectionBehavior
25
- autoload :GenericWorkBehavior
26
- autoload :GenericFileBehavior
27
- autoload :BlockChildObjects
36
+ autoload :FileSetBehavior
37
+ autoload :GenericWorkBehavior # Deprecated. Remove in 0.4.0
38
+ autoload :GenericFileBehavior # Deprecated. Remove in 0.4.0
39
+ autoload :WorkBehavior
28
40
  end
29
41
 
30
- autoload_under 'services/generic_file' do
31
- autoload :AddFileToGenericFile
32
- autoload :GenerateThumbnail
33
- autoload :UploadFileToGenericFile
42
+ autoload_under 'services' do
43
+ autoload :AddFileToFileSet
44
+ autoload :AddFileToGenericFile # Deprecated. Remove in 0.4.0
45
+ autoload :UploadFileToFileSet
46
+ autoload :UploadFileToGenericFile # Deprecated. Remove in 0.4.0
34
47
  autoload :PersistDerivative
35
- autoload :FullTextExtractionService
36
- end
37
-
38
- autoload_under 'errors' do
39
- autoload :FullTextExtractionError
48
+ autoload :CharacterizationService
40
49
  end
41
50
  end
42
51
  end
@@ -0,0 +1,31 @@
1
+ module Hydra::Works
2
+ module Characterization
3
+ extend ActiveSupport::Concern
4
+ extend ActiveSupport::Autoload
5
+
6
+ autoload :FitsDatastream, 'hydra/works/models/characterization/fits_datastream.rb'
7
+ autoload :AlreadyThereStrategy, 'hydra/works/models/characterization/already_there_strategy.rb'
8
+
9
+ autoload_under 'schema' do
10
+ autoload :AudioSchema
11
+ autoload :BaseSchema
12
+ autoload :DocumentSchema
13
+ autoload :ImageSchema
14
+ autoload :VideoSchema
15
+ end
16
+
17
+ autoload :Base, 'hydra/works/models/concerns/file_set/characterization/base.rb'
18
+ autoload :Image, 'hydra/works/models/concerns/file_set/characterization/image.rb'
19
+ autoload :Document, 'hydra/works/models/concerns/file_set/characterization/document.rb'
20
+ autoload :Video, 'hydra/works/models/concerns/file_set/characterization/video.rb'
21
+ autoload :Audio, 'hydra/works/models/concerns/file_set/characterization/audio.rb'
22
+
23
+ included do
24
+ include Base
25
+ include Image
26
+ include Audio
27
+ include Video
28
+ include Document
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,12 @@
1
+ module Hydra::Works::Characterization
2
+ class AudioSchema < ActiveTriples::Schema
3
+ property :bit_depth, predicate: RDF::Vocab::NFO.bitDepth
4
+ property :channels, predicate: RDF::Vocab::NFO.channels
5
+ property :data_format, predicate: RDF::Vocab::EBUCore.hasDataFormat
6
+ property :frame_rate, predicate: RDF::Vocab::NFO.frameRate
7
+ property :duration, predicate: RDF::Vocab::NFO.duration
8
+ property :sample_rate, predicate: RDF::Vocab::EBUCore.sampleRate
9
+ # properties without cannonical URIs
10
+ property :offset, predicate: RDF::URI('http://projecthydra.org/ns/audio/offset')
11
+ end
12
+ end
@@ -0,0 +1,17 @@
1
+ module Hydra::Works::Characterization
2
+ class BaseSchema < ActiveTriples::Schema
3
+ property :filename, predicate: RDF::Vocab::EBUCore.filename, multiple: false
4
+ property :format_label, predicate: RDF::Vocab::PREMIS.hasFormatName
5
+ property :file_size, predicate: RDF::Vocab::EBUCore.fileSize
6
+ property :well_formed, predicate: RDF::URI.new("http://projecthydra.org/ns/fits/wellFormed")
7
+ property :valid, predicate: RDF::URI.new("http://projecthydra.org/ns/fits/valid")
8
+ property :date_created, predicate: RDF::Vocab::EBUCore.dateCreated
9
+ property :last_modified, predicate: RDF::Vocab::EBUCore.dateModified
10
+ property :fits_version, predicate: RDF::Vocab::PREMIS.hasCreatingApplicationVersion
11
+ property :exif_version, predicate: RDF::Vocab::EXIF.exifVersion
12
+ property :original_checksum, predicate: RDF::Vocab::NFO.hashValue
13
+ property :mime_type, predicate: RDF::Vocab::EBUCore.hasMimeType, multiple: false do |index|
14
+ index.as :stored_searchable
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,18 @@
1
+ module Hydra::Works::Characterization
2
+ class DocumentSchema < ActiveTriples::Schema
3
+ property :file_title, predicate: RDF::DC11.title
4
+ property :file_author, predicate: RDF::DC11.creator
5
+ property :page_count, predicate: RDF::Vocab::NFO.pageCount
6
+ property :file_language, predicate: RDF::DC11.language
7
+ property :word_count, predicate: RDF::Vocab::NFO.wordCount
8
+ property :character_count, predicate: RDF::Vocab::NFO.characterCount
9
+ property :line_count, predicate: RDF::Vocab::NFO.lineCount
10
+ property :character_set, predicate: RDF::URI.new("http://www.w3.org/2011/content#characterEncoding")
11
+ property :markup_basis, predicate: RDF::URI.new("http://www.w3.org/2011/content#doctypeName")
12
+ property :markup_language, predicate: RDF::URI.new("http://www.w3.org/2011/content#systemId")
13
+ # properties without canonical URIs
14
+ property :paragraph_count, predicate: RDF::URI.new("http://projecthydra.org/ns/odf/paragraphCount")
15
+ property :table_count, predicate: RDF::URI.new("http://projecthydra.org/ns/odf/tableCount")
16
+ property :graphics_count, predicate: RDF::URI.new("http://projecthydra.org/ns/odf/graphicsCount")
17
+ end
18
+ end
@@ -0,0 +1,22 @@
1
+ module Hydra::Works::Characterization
2
+ class ImageSchema < ActiveTriples::Schema
3
+ property :byte_order, predicate: RDF::URI('http://sweet.jpl.nasa.gov/2.2/reprDataFormat.owl#byteOrder'), multiple: false
4
+ property :compression, predicate: RDF::URI('http://projecthydra.org/ns/mix/compressionScheme'), multiple: false
5
+ property :height, predicate: RDF::Vocab::EBUCore.height
6
+ property :width, predicate: RDF::Vocab::EBUCore.width
7
+ # property :width, predicate: RDF::Vocab::EXIF.imageWidth, multiple: false
8
+ # property :height, predicate: RDF::Vocab::EXIF.imageLength, multiple: false
9
+ property :color_space, predicate: RDF::Vocab::EXIF.colorSpace, multiple: false
10
+ property :profile_name, predicate: RDF::URI('http://projecthydra.org/ns/mix/colorProfileName')
11
+ property :profile_version, predicate: RDF::URI('http://projecthydra.org/ns/mix/colorProfileVersion')
12
+ property :orientation, predicate: RDF::Vocab::EXIF.orientation, multiple: false
13
+ property :color_map, predicate: RDF::URI('http://projecthydra.org/ns/mix/colorMap')
14
+ property :image_producer, predicate: RDF::Vocab::MARCRelators.pht
15
+ property :capture_device, predicate: RDF::Vocab::EXIF.model
16
+ property :scanning_software, predicate: RDF::Vocab::EXIF.software
17
+ # exif_version is in core set of tehcnical metadata
18
+ property :gps_timestamp, predicate: RDF::Vocab::EXIF.gpsTimeStamp
19
+ property :latitude, predicate: RDF::Vocab::EXIF.gpsLatitude
20
+ property :longitude, predicate: RDF::Vocab::EXIF.gpsLongitude
21
+ end
22
+ end
@@ -0,0 +1,9 @@
1
+ module Hydra::Works::Characterization
2
+ class VideoSchema < ActiveTriples::Schema
3
+ property :height, predicate: RDF::Vocab::EBUCore.height
4
+ property :width, predicate: RDF::Vocab::EBUCore.width
5
+ property :frame_rate, predicate: RDF::Vocab::NFO.frameRate
6
+ property :duration, predicate: RDF::Vocab::NFO.duration
7
+ property :sample_rate, predicate: RDF::Vocab::EBUCore.sampleRate
8
+ end
9
+ end
@@ -0,0 +1,12 @@
1
+ module Hydra::Works::Characterization
2
+ class AlreadyThereStrategy < ActiveTriples::ExtensionStrategy
3
+ # override apply method to check if property already exists or reciever already has predicate defined.
4
+ # Do not add property if the rdf_resource already responds to the property name
5
+ # Do not add property if the rdf_resource already has a property with the same predicate.
6
+ def self.apply(resource, property)
7
+ return if resource.respond_to?(property.name)
8
+ return if resource.properties.any? { |p| p[1].predicate == property.predicate }
9
+ resource.property property.name, property.to_h
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,162 @@
1
+ module Hydra::Works::Characterization
2
+ class FitsDatastream < ActiveFedora::OmDatastream
3
+ include OM::XML::Document
4
+
5
+ set_terminology do |t|
6
+ t.root(path: 'fits',
7
+ xmlns: 'http://hul.harvard.edu/ois/xml/ns/fits/fits_output',
8
+ schema: 'http://hul.harvard.edu/ois/xml/xsd/fits/fits_output.xsd')
9
+ t.fits_v(path: { attribute: 'version' })
10
+ t.identification do
11
+ t.identity do
12
+ t.format_label(path: { attribute: 'format' })
13
+ t.mime_type(path: { attribute: 'mimetype' })
14
+ t.tool(attributes: { toolname: "Exiftool" }) do
15
+ t.exif_tool_version(path: { attribute: 'toolversion' })
16
+ end
17
+ end
18
+ end
19
+ t.fileinfo do
20
+ t.file_size(path: 'size')
21
+ t.last_modified(path: 'lastmodified', attributes: { toolname: "Exiftool" })
22
+ t.filename(path: 'filename')
23
+ t.original_checksum(path: 'md5checksum')
24
+ t.date_created(path: 'created')
25
+ t.rights_basis(path: 'rightsBasis')
26
+ t.copyright_basis(path: 'copyrightBasis')
27
+ t.copyright_note(path: 'copyrightNote')
28
+ end
29
+ t.filestatus do
30
+ t.well_formed(path: 'well-formed')
31
+ t.valid(path: 'valid')
32
+ t.status_message(path: 'message')
33
+ end
34
+ t.metadata do
35
+ t.document do
36
+ t.file_title(path: 'title')
37
+ t.file_author(path: 'author')
38
+ t.file_language(path: 'language')
39
+ t.page_count(path: 'pageCount')
40
+ t.word_count(path: 'wordCount')
41
+ t.character_count(path: 'characterCount')
42
+ t.paragraph_count(path: 'paragraphCount')
43
+ t.line_count(path: 'lineCount')
44
+ t.table_count(path: 'tableCount')
45
+ t.graphics_count(path: 'graphicsCount')
46
+ end
47
+ t.image do
48
+ t.byte_order(path: 'byteOrder')
49
+ t.compression(path: 'compressionScheme')
50
+ t.width(path: 'imageWidth')
51
+ t.height(path: 'imageHeight')
52
+ t.color_space(path: 'colorSpace')
53
+ t.profile_name(path: 'iccProfileName')
54
+ t.profile_version(path: 'iccProfileVersion')
55
+ t.orientation(path: 'orientation')
56
+ t.color_map(path: 'colorMap')
57
+ t.image_producer(path: 'imageProducer')
58
+ t.capture_device(path: 'captureDevice')
59
+ t.scanning_software(path: 'scanningSoftwareName')
60
+ t.exif_version(path: 'exifVersion')
61
+ t.gps_timestamp(path: 'gpsTimeStamp')
62
+ t.latitude(path: 'gpsDestLatitude')
63
+ t.longitude(path: 'gpsDestLongitude')
64
+ end
65
+ t.text do
66
+ t.character_set(path: 'charset')
67
+ t.markup_basis(path: 'markupBasis')
68
+ t.markup_language(path: 'markupLanguage')
69
+ end
70
+ t.audio do
71
+ t.duration(path: 'duration')
72
+ t.bit_depth(path: 'bitDepth')
73
+ t.sample_rate(path: 'sampleRate')
74
+ t.channels(path: 'channels')
75
+ t.data_format(path: 'dataFormatType')
76
+ t.offset(path: 'offset')
77
+ end
78
+ t.video do
79
+ t.width(path: 'imageWidth')
80
+ t.height(path: 'imageHeight')
81
+ t.duration(path: 'duration')
82
+ t.sample_rate(path: 'sampleRate')
83
+ t.audio_sample_rate(path: 'audioSampleRate')
84
+ t.frame_rate(path: 'frameRate')
85
+ end
86
+ end
87
+ # fits_version needs a different name than it's target node since they're at the same level
88
+ t.fits_version(proxy: [:fits, :fits_v])
89
+ t.format_label(proxy: [:identification, :identity, :format_label])
90
+ # Can't use .mime_type because it's already defined for datastream so method missing won't work.
91
+ t.file_mime_type(proxy: [:identification, :identity, :mime_type])
92
+ t.exif_tool_version(proxy: [:identification, :identity, :tool, :exif_tool_version])
93
+ t.file_size(proxy: [:fileinfo, :file_size])
94
+ t.last_modified(proxy: [:fileinfo, :last_modified])
95
+ t.filename(proxy: [:fileinfo, :filename])
96
+ t.original_checksum(proxy: [:fileinfo, :original_checksum])
97
+ t.date_created(proxy: [:fileinfo, :date_created])
98
+ t.rights_basis(proxy: [:fileinfo, :rights_basis])
99
+ t.copyright_basis(proxy: [:fileinfo, :copyright_basis])
100
+ t.copyright_note(proxy: [:fileinfo, :copyright_note])
101
+ t.well_formed(proxy: [:filestatus, :well_formed])
102
+ t.valid(proxy: [:filestatus, :valid])
103
+ t.status_message(proxy: [:filestatus, :status_message])
104
+ t.file_title(proxy: [:metadata, :document, :file_title])
105
+ t.file_author(proxy: [:metadata, :document, :file_author])
106
+ t.page_count(proxy: [:metadata, :document, :page_count])
107
+ t.file_language(proxy: [:metadata, :document, :file_language])
108
+ t.word_count(proxy: [:metadata, :document, :word_count])
109
+ t.character_count(proxy: [:metadata, :document, :character_count])
110
+ t.paragraph_count(proxy: [:metadata, :document, :paragraph_count])
111
+ t.line_count(proxy: [:metadata, :document, :line_count])
112
+ t.table_count(proxy: [:metadata, :document, :table_count])
113
+ t.graphics_count(proxy: [:metadata, :document, :graphics_count])
114
+ t.byte_order(proxy: [:metadata, :image, :byte_order])
115
+ t.compression(proxy: [:metadata, :image, :compression])
116
+ t.width(proxy: [:metadata, :image, :width])
117
+ t.video_width(proxy: [:metadata, :video, :width])
118
+ t.height(proxy: [:metadata, :image, :height])
119
+ t.video_height(proxy: [:metadata, :video, :height])
120
+ t.color_space(proxy: [:metadata, :image, :color_space])
121
+ t.profile_name(proxy: [:metadata, :image, :profile_name])
122
+ t.profile_version(proxy: [:metadata, :image, :profile_version])
123
+ t.orientation(proxy: [:metadata, :image, :orientation])
124
+ t.color_map(proxy: [:metadata, :image, :color_map])
125
+ t.image_producer(proxy: [:metadata, :image, :image_producer])
126
+ t.capture_device(proxy: [:metadata, :image, :capture_device])
127
+ t.scanning_software(proxy: [:metadata, :image, :scanning_software])
128
+ t.exif_version(proxy: [:metadata, :image, :exif_version])
129
+ t.gps_timestamp(proxy: [:metadata, :image, :gps_timestamp])
130
+ t.latitude(proxy: [:metadata, :image, :latitude])
131
+ t.longitude(proxy: [:metadata, :image, :longitude])
132
+ t.character_set(proxy: [:metadata, :text, :character_set])
133
+ t.markup_basis(proxy: [:metadata, :text, :markup_basis])
134
+ t.markup_language(proxy: [:metadata, :text, :markup_language])
135
+ t.audio_duration(proxy: [:metadata, :audio, :duration])
136
+ t.video_duration(proxy: [:metadata, :video, :duration])
137
+ t.bit_depth(proxy: [:metadata, :audio, :bit_depth])
138
+ t.audio_sample_rate(proxy: [:metadata, :audio, :sample_rate])
139
+ t.video_sample_rate(proxy: [:metadata, :video, :sample_rate])
140
+ t.video_audio_sample_rate(proxy: [:metadata, :video, :audio_sample_rate])
141
+ t.channels(proxy: [:metadata, :audio, :channels])
142
+ t.data_format(proxy: [:metadata, :audio, :data_format])
143
+ t.offset(proxy: [:metadata, :audio, :offset])
144
+ t.frame_rate(proxy: [:metadata, :video, :frame_rate])
145
+ end
146
+
147
+ def self.xml_template
148
+ builder = Nokogiri::XML::Builder.new do |xml|
149
+ xml.fits(xmlns: 'http://hul.harvard.edu/ois/xml/ns/fits/fits_output',
150
+ 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
151
+ 'xsi:schemaLocation' =>
152
+ "http://hul.harvard.edu/ois/xml/ns/fits/fits_output
153
+ http://hul.harvard.edu/ois/xml/xsd/fits/fits_output.xsd",
154
+ version: '0.6.0',
155
+ timestamp: '1/25/12 11:04 AM') do
156
+ xml.identification { xml.identity(toolname: 'FITS') }
157
+ end
158
+ end
159
+ builder.doc
160
+ end
161
+ end
162
+ end