Sha256: 10be6752f17cde72502ba56a171fb145370562e0bbd9f4444400d196b4ffc4c8

Contents?: true

Size: 1.43 KB

Versions: 37

Compression:

Stored size: 1.43 KB

Contents

module Fog
  module Storage
    module IAAttributes
		  # you can add other x-archive-metadata-* values, but these are standard
		  IA_STANDARD_METADATA_FIELDS = %q[hidden, title, collection, creator, mediatype, description, date, subject, licenseurl, pick, noindex, notes, rights, contributor, language, coverage, credits]

		  # for x-archive-metadata-mediatype, these are the valid values
		  IA_VALID_MEDIA_TYPES = %q[audio, data, etree, image, movies, software, texts, web]

			module ClassMethods
			  def ia_metadata_attribute(name)
			    attribute(name, :aliases=>['amz','archive'].map{|p|"x-#{p}-#{name.to_s.tr('_','-')}"})
			  end
			end

			module InstanceMethods
				# set_metadata_array_headers(:collections, options)
				def set_metadata_array_headers(array_attribute, options={})
				  attr_values = Array(self.send(array_attribute))
				  opt_values = options.map do |key,value|
				    options.delete(key) if (key.to_s =~ /^x-(amz||archive)-meta(\d*)-#{array_attribute.to_s[0..-2]}/)
				  end
				  values = (attr_values + opt_values).compact.sort.uniq
				  # got the values, now add them back to the options
				  if values.size == 1
				    options["x-archive-meta-#{array_attribute.to_s[0..-2]}"] = values.first
				  elsif values.size > 1
				    values[0,99].each_with_index do |value, i|
				      options["x-archive-meta#{format("%02d", i+1)}-#{array_attribute.to_s[0..-2]}"] = value
				    end
				  end
				end
			end
		end
	end
end

Version data entries

37 entries across 35 versions & 6 rubygems

Version Path
fog-internet-archive-0.0.2 lib/fog/storage/internet_archive/models/ia_attributes.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.5.0/gems/fog-internet-archive-0.0.1/lib/fog/internet_archive/models/storage/ia_attributes.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/fog-internet-archive-0.0.1/lib/fog/internet_archive/models/storage/ia_attributes.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/gems/fog-internet-archive-0.0.1/lib/fog/internet_archive/models/storage/ia_attributes.rb
fog-1.40.0 lib/fog/internet_archive/models/storage/ia_attributes.rb
fog-1.39.0 lib/fog/internet_archive/models/storage/ia_attributes.rb
fog-internet-archive-0.0.1 lib/fog/internet_archive/models/storage/ia_attributes.rb
fog-1.38.0 lib/fog/internet_archive/models/storage/ia_attributes.rb
fog-1.37.0 lib/fog/internet_archive/models/storage/ia_attributes.rb
fog-1.36.0 lib/fog/internet_archive/models/storage/ia_attributes.rb
fog-1.35.0 lib/fog/internet_archive/models/storage/ia_attributes.rb
fog-2.0.0.pre.0 lib/fog/internet_archive/models/storage/ia_attributes.rb
vagrant-cloudstack-1.2.0 vendor/bundle/gems/fog-1.32.0/lib/fog/internet_archive/models/storage/ia_attributes.rb
fog-1.34.0 lib/fog/internet_archive/models/storage/ia_attributes.rb
fog-1.33.0 lib/fog/internet_archive/models/storage/ia_attributes.rb
fog-1.32.0 lib/fog/internet_archive/models/storage/ia_attributes.rb
fog-1.31.0 lib/fog/internet_archive/models/storage/ia_attributes.rb
vagrant-cloudstack-1.1.0 vendor/bundle/gems/fog-1.22.1/lib/fog/internet_archive/models/storage/ia_attributes.rb
fog-1.30.0 lib/fog/internet_archive/models/storage/ia_attributes.rb
fog-1.29.0 lib/fog/internet_archive/models/storage/ia_attributes.rb