Skip to content
Browse files

making suggest changes

  • Loading branch information...
1 parent 8d4f7af commit af51fedab60d15e5882604dcf38c6db22ce16c58 @atomical atomical committed Mar 29, 2013
View
4 app/helpers/application_helper.rb
@@ -13,8 +13,8 @@ def image_for(item_id)
video_count = 0
audio_count = 0
media_object.parts.each do |part|
- video_count = video_count + 1 if "Moving image" == part.file_format
- audio_count = audio_count + 1 if "Sound" == part.file_format
+ video_count = video_count + 1 if MediaType::VIDEO == part.file_format
+ audio_count = audio_count + 1 if MediaType::SOUND == part.file_format
end
logger.debug "<< Object has #{video_count} videos and #{audio_count} audios >>"
View
8 app/models/master_file.rb
@@ -119,9 +119,9 @@ def process
"flavor" => "presenter/source",
"filename" => File.basename(file_location)}
- if file_format == 'Sound'
+ if file_format == MediaType::SOUND
args['workflow'] = "fullaudio"
- elsif file_format == 'Moving image'
+ elsif file_format == MediaType::VIDEO
args['workflow'] = "avalon"
end
@@ -326,9 +326,9 @@ def determine_format(file, content_type = nil)
# so a case statement should flow in the preferred order
upload_format = case
when media_format.video?
- 'Moving image'
+ MediaType::VIDEO
when media_format.audio?
- 'Sound'
+ MediaType::SOUND
else
'Unknown'
end
View
17 app/models/media_object.rb
@@ -342,23 +342,22 @@ def update_attribute_in_metadata(attribute, value = [], attributes = [])
end
def set_media_types!
- resource_type_names = {
- 'audio' => 'sound recording',
- 'video' => 'moving image'
- }
mime_types = parts.collect { |mf|
mf.file_location.nil? ? nil : Rack::Mime.mime_type(File.extname(mf.file_location))
}.compact.uniq
-
- master_file_media_type_map = {'Moving image' => 'moving image', 'Sound' => 'sound recording'}
- resource_types = self.parts.collect{|master_file| master_file_media_type_map[master_file.file_format] }.uniq
+
+ resource_type_to_formatted_text_map = { MediaType::VIDEO => MediaType::VIDEO, MediaType::SOUND => 'Sound recording'}
+ resource_types = self.parts.collect{|master_file| resource_type_to_formatted_text_map[master_file.file_format] }.uniq
mime_types = nil if mime_types.empty?
resource_types = nil if resource_types.empty?
- descMetadata.find_by_terms(:physical_description).remove
+ descMetadata.ensure_root_term_exists!(:physical_description)
+ descMetadata.ensure_root_term_exists!(:resource_type)
+
+ descMetadata.find_by_terms(:physical_description, :internet_media_type).remove
descMetadata.find_by_terms(:resource_type).remove
- descMetadata.ensure_physical_description_exists!
+
descMetadata.update_values([:physical_description, :internet_media_type] => mime_types, [:resource_type] => resource_types)
end
View
6 app/models/mods_behaviors.rb
@@ -89,9 +89,9 @@ def update_change_date!(t=Time.now.iso8601)
self.record_change_date = t
end
- def ensure_physical_description_exists!
- if find_by_terms(:physical_description).empty?
- ng_xml.root.add_child('<physicalDescription/>')
+ def ensure_root_term_exists!(term)
+ if find_by_terms(term).empty?
+ ng_xml.root.add_child("<#{term.to_s.camelcase(first_letter = :lower)}/>")
end
end
View
4 app/views/media_objects/_file_upload.html.erb
@@ -31,9 +31,9 @@
<td>&nbsp;</td>
<td>
<% case part.file_format
- when 'Sound' %>
+ when MediaType::SOUND %>
<i class="icon-volume-up"></i>
- <% when 'Moving image' %>
+ <% when MediaType::VIDEO %>
<i class="icon-film"></i>
<% else %>
<i class="icon-question-sign"></i>
View
4 app/views/media_objects/_structure.html.erb
@@ -21,9 +21,9 @@
</td>
<td>
<% case masterfile.file_format
- when 'Sound' %>
+ when MediaType::SOUND %>
<i class="icon-volume-up"></i>
- <% when 'Moving image' %>
+ <% when MediaType::VIDEO %>
<i class="icon-film"></i>
<% else %>
<i class="icon-question-sign"></i>
View
4 app/views/media_objects/mobile.html.erb
@@ -15,9 +15,9 @@
you are using a MP4 live stream instead of FLV. All of this needs to go
into a helper method so the view is not so messy. %>
<% format = case @currentStream.file_format
- when "Moving image"
+ when MediaType::VIDEO
'video'
- when "Sound"
+ when MediaType::SOUND
'audio'
else
'other'

0 comments on commit af51fed

Please sign in to comment.
Something went wrong with that request. Please try again.