talia_core 0.4.5 → 0.4.6
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION.yml +1 -1
- data/config/rdfstore.yml +1 -1
- data/generators/talia_base/talia_base_generator.rb +2 -1
- data/generators/talia_base/templates/config/talia_initializer.rb +4 -1
- data/generators/talia_base/templates/config/warble.rb +82 -0
- data/generators/talia_base/templates/script/configure_talia +24 -8
- data/lib/talia_core/data_types/data_loader.rb +2 -2
- data/lib/talia_core/data_types/data_record.rb +0 -2
- data/lib/talia_core/data_types/file_store.rb +1 -1
- data/lib/talia_core/data_types/mime_mapping.rb +92 -45
- data/lib/talia_util/import_job_helper.rb +30 -30
- data/test/talia_core/data_types/file_record_test.rb +0 -14
- data/test/talia_core/data_types/mime_mapping_test.rb +41 -0
- data/test/test_helper.rb +7 -0
- metadata +6 -3
data/VERSION.yml
CHANGED
data/config/rdfstore.yml
CHANGED
@@ -13,7 +13,8 @@ class TaliaBaseGenerator < Rails::Generator::Base
|
|
13
13
|
m.directory 'config/initializers'
|
14
14
|
m.file "config/talia_initializer.rb", "config/initializers/talia.rb"
|
15
15
|
m.file "config/routes.rb", "config/routes.rb", :collision => :ask
|
16
|
-
m.file "talia.sh", "talia.sh", :shebang => '/bin/sh', :chmod => 0755
|
16
|
+
m.file "talia.sh", "talia.sh", :shebang => '/bin/sh', :chmod => 0755=
|
17
|
+
m.file "config/warble.rb", "config/warble.rb"
|
17
18
|
|
18
19
|
# Install the scripts
|
19
20
|
m.directory 'script'
|
@@ -5,4 +5,7 @@ TLoad::setup_load_path
|
|
5
5
|
TaliaCore::Initializer.environment = ENV['RAILS_ENV']
|
6
6
|
TaliaCore::Initializer.run("talia_core")
|
7
7
|
|
8
|
-
TaliaCore::SITE_NAME = TaliaCore::CONFIG['site_name'] || '
|
8
|
+
TaliaCore::SITE_NAME = TaliaCore::CONFIG['site_name'] || 'Talia Digital Library System'
|
9
|
+
|
10
|
+
# You may add mapping for additional data types here.
|
11
|
+
# TaliaCore::DataTypes::MimeMapping.add_mapping(:jpeg, TaliaCore::DataTypes::ImageData, :create_iip)
|
@@ -0,0 +1,82 @@
|
|
1
|
+
# Warbler web application assembly configuration file
|
2
|
+
Warbler::Config.new do |config|
|
3
|
+
# Temporary directory where the application is staged
|
4
|
+
# config.staging_dir = "tmp/war"
|
5
|
+
|
6
|
+
# Application directories to be included in the webapp.
|
7
|
+
config.dirs = %w(app config lib vendor)
|
8
|
+
|
9
|
+
# Additional files/directories to include, above those in config.dirs
|
10
|
+
# config.includes = FileList["db"]
|
11
|
+
config.includes = FileList['ontologies/**']
|
12
|
+
|
13
|
+
# Additional files/directories to exclude
|
14
|
+
# config.excludes = FileList["lib/tasks/*"]
|
15
|
+
# ActiveScaffold needs to be exclude as there are circular symlinks inside...
|
16
|
+
config.excludes = FileList["vendor/jruby*", "vendor/plugins/active_scaffold/test/*"]
|
17
|
+
|
18
|
+
# Additional Java .jar files to include. Note that if .jar files are placed
|
19
|
+
# in lib (and not otherwise excluded) then they need not be mentioned here.
|
20
|
+
# JRuby and JRuby-Rack are pre-loaded in this list. Be sure to include your
|
21
|
+
# own versions if you directly set the value
|
22
|
+
# config.java_libs += FileList["lib/java/*.jar"]
|
23
|
+
|
24
|
+
# Loose Java classes and miscellaneous files to be placed in WEB-INF/classes.
|
25
|
+
# config.java_classes = FileList["target/classes/**.*"]
|
26
|
+
|
27
|
+
# One or more pathmaps defining how the java classes should be copied into
|
28
|
+
# WEB-INF/classes. The example pathmap below accompanies the java_classes
|
29
|
+
# configuration above. See http://rake.rubyforge.org/classes/String.html#M000017
|
30
|
+
# for details of how to specify a pathmap.
|
31
|
+
# config.pathmaps.java_classes << "%{target/classes/,}p"
|
32
|
+
|
33
|
+
# Gems to be included. You need to tell Warbler which gems your application needs
|
34
|
+
# so that they can be packaged in the war file.
|
35
|
+
# The Rails gems are included by default unless the vendor/rails directory is present."
|
36
|
+
%w(talia_core activerecord-jdbcmysql-adapter jruby-openssl jdbc-mysql oai).each do |gem|
|
37
|
+
config.gems << gem
|
38
|
+
end
|
39
|
+
# config.gems << "tzinfo"
|
40
|
+
|
41
|
+
# Uncomment this if you don't want to package rails gem.
|
42
|
+
# config.gems -= ["rails"]
|
43
|
+
|
44
|
+
# The most recent versions of gems are used.
|
45
|
+
# You can specify versions of gems by using a hash assignment:
|
46
|
+
# config.gems["rails"] = "2.0.5"
|
47
|
+
|
48
|
+
# Include gem dependencies not mentioned specifically
|
49
|
+
config.gem_dependencies = true
|
50
|
+
|
51
|
+
# Files to be included in the root of the webapp. Note that files in public
|
52
|
+
# will have the leading 'public/' part of the path stripped during staging.
|
53
|
+
# config.public_html = FileList["public/**/*", "doc/**/*"]
|
54
|
+
|
55
|
+
# Pathmaps for controlling how public HTML files are copied into the .war
|
56
|
+
# config.pathmaps.public_html = ["%{public/,}p"]
|
57
|
+
|
58
|
+
# Name of the war file (without the .war) -- defaults to the basename
|
59
|
+
# of RAILS_ROOT
|
60
|
+
# config.war_name = "mywar"
|
61
|
+
|
62
|
+
# Value of RAILS_ENV for the webapp
|
63
|
+
config.webxml.rails.env = 'production'
|
64
|
+
|
65
|
+
# Application booter to use, one of :rack, :rails, or :merb. (Default :rails)
|
66
|
+
# config.webxml.booter = :rails
|
67
|
+
|
68
|
+
# When using the :rack booter, "Rackup" script to use.
|
69
|
+
# The script is evaluated in a Rack::Builder to load the application.
|
70
|
+
# Examples:
|
71
|
+
# config.webxml.rackup = %{require './lib/demo'; run Rack::Adapter::Camping.new(Demo)}
|
72
|
+
# config.webxml.rackup = require 'cgi' && CGI::escapeHTML(File.read("config.ru"))
|
73
|
+
|
74
|
+
# Control the pool of Rails runtimes. Leaving unspecified means
|
75
|
+
# the pool will grow as needed to service requests. It is recommended
|
76
|
+
# that you fix these values when running a production server!
|
77
|
+
config.webxml.jruby.min.runtimes = 2
|
78
|
+
config.webxml.jruby.max.runtimes = 4
|
79
|
+
|
80
|
+
# JNDI data source name
|
81
|
+
# config.webxml.jndi = 'jdbc/rails'
|
82
|
+
end
|
@@ -129,6 +129,18 @@ print "Enter the URI for your site: "
|
|
129
129
|
site_url = readl(true)
|
130
130
|
|
131
131
|
if(read_yn('Do you want to use the IIP image server?'))
|
132
|
+
init_file = File.join(rails_dir, 'config', 'initializers', 'talia.rb')
|
133
|
+
if(File.exist?(init_file))
|
134
|
+
puts "Adding the creation handler to your talia_initializer. Note that you will need 'vips' installed."
|
135
|
+
File.open(init_file, 'a') do |io|
|
136
|
+
io.puts ''
|
137
|
+
io.puts '# IIP creation handlers, added automatically'
|
138
|
+
%w(jpeg tiff png gif bmp).each { |t| io.puts "TaliaCore::DataTypes::MimeMapping.add_mapping(:#{t}, TaliaCore::DataTypes::ImageData, :create_iip)" }
|
139
|
+
io.puts ''
|
140
|
+
end
|
141
|
+
else
|
142
|
+
puts "WARNING: Initializer file for Talia not found. You will need to add the image handler for the MIME types manually."
|
143
|
+
end
|
132
144
|
puts
|
133
145
|
print "Enter the URL of your IIP server, or the port number (for default URL on localhost): "
|
134
146
|
iip_url = readl
|
@@ -150,10 +162,14 @@ puts
|
|
150
162
|
puts "Configuring the Sesame RDF store (change the config by hand for stores other than Sesame)"
|
151
163
|
puts
|
152
164
|
backends = %w(native memory rdbms http)
|
153
|
-
print "Enter the sesame backend to use (#{backends.join('|')}): "
|
154
|
-
|
165
|
+
print "Enter the sesame backend to use (#{backends.join('|')}) (default: native): "
|
166
|
+
backend = readl
|
167
|
+
backend = 'native' if(backend.blank?)
|
168
|
+
while(!(backends.include?(backend)))
|
155
169
|
puts "#{backend} is not a valid backend"
|
156
170
|
print "Enter the backend (#{backends.join('|')}: )"
|
171
|
+
backend = readl
|
172
|
+
backend = 'native' if(backend.blank?)
|
157
173
|
end
|
158
174
|
|
159
175
|
%w(production test development).each do |env|
|
@@ -181,7 +197,7 @@ when 'rdbms':
|
|
181
197
|
print "Enter the password for the connection: "
|
182
198
|
pass = readl
|
183
199
|
end
|
184
|
-
%(production test development).each do |env|
|
200
|
+
%w(production test development).each do |env|
|
185
201
|
rdf_config[env]['driver'] = driver
|
186
202
|
rdf_config[env]['user'] = user
|
187
203
|
rdf_config[env]['pass'] = pass
|
@@ -196,10 +212,9 @@ when 'http':
|
|
196
212
|
print "Enter the password for the connection: "
|
197
213
|
pass = readl
|
198
214
|
end
|
199
|
-
%(production test development).each do |env|
|
200
|
-
rdf_config[env]['
|
201
|
-
rdf_config[env]['
|
202
|
-
rdf_config[env]['pass'] = pass
|
215
|
+
%w(production test development).each do |env|
|
216
|
+
rdf_config[env]['user'] = user unless(user.blank?)
|
217
|
+
rdf_config[env]['pass'] = pass unless(pass.blank?)
|
203
218
|
print "Enter the URL for the '#{env}' environment: "
|
204
219
|
rdf_config[env]['url'] = readl(true)
|
205
220
|
end
|
@@ -211,7 +226,8 @@ if(iip_directory != '')
|
|
211
226
|
talia_config.iip_root_directory_location = iip_directory
|
212
227
|
end
|
213
228
|
|
214
|
-
|
229
|
+
puts ''
|
230
|
+
print "Enter the path to store general data files (return for default): "
|
215
231
|
data_directory = readl
|
216
232
|
|
217
233
|
if(data_directory != '')
|
@@ -77,10 +77,10 @@ module TaliaCore
|
|
77
77
|
# in a different way. If it is a file, the file name will be passed in here. If it is
|
78
78
|
# a URL, the method will receive the io object of the open connection as the source
|
79
79
|
def open_and_create(mime_type, location, source, is_file)
|
80
|
-
data_type = loader_type_from(mime_type)
|
80
|
+
data_type = MimeMapping.loader_type_from(mime_type)
|
81
81
|
if(data_type.is_a?(Symbol))
|
82
82
|
raise(ArgumentError, "No handler found for loading: #{data_type}") unless(self.respond_to?(data_type))
|
83
|
-
|
83
|
+
MimeMapping.class_type_from(mime_type).send(data_type, mime_type, location, source, is_file)
|
84
84
|
else
|
85
85
|
raise(ArgumentError, "Registered handler for loading must be a method symbol or class. (#{data_type})") unless(data_type.is_a?(Class))
|
86
86
|
data_record = data_type.new
|
@@ -12,8 +12,6 @@ module TaliaCore
|
|
12
12
|
before_create :set_mime_type # Mime type must be saved before the record is written
|
13
13
|
|
14
14
|
# validates_presence_of :source
|
15
|
-
|
16
|
-
extend MimeMapping
|
17
15
|
|
18
16
|
# Declaration of main abstract methods ======================
|
19
17
|
# Some notes: every subclasses of DataRecord must implement
|
@@ -114,7 +114,7 @@ module TaliaCore
|
|
114
114
|
|
115
115
|
# Assign the STI subclass, perfoming a mime-type lookup.
|
116
116
|
def assign_type(content_type)
|
117
|
-
self.type =
|
117
|
+
self.type = MimeMapping.class_type_from(content_type).name
|
118
118
|
end
|
119
119
|
|
120
120
|
|
@@ -1,54 +1,101 @@
|
|
1
1
|
module TaliaCore
|
2
2
|
module DataTypes
|
3
|
-
|
3
|
+
|
4
4
|
# Mapping from Mime types to data classes and importing methods. Currently uses a fixed
|
5
5
|
# default mapping. If the mime type is not known, it will use a fallback default handler.
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
6
|
+
#
|
7
|
+
# The mapping can be configured in Rails' initializer files. Example:
|
8
|
+
#
|
9
|
+
# TaliaCore::DataTypes::MimeMapping(:tiff, :image_data, :create_iip)
|
10
|
+
class MimeMapping
|
11
|
+
|
12
|
+
class << self
|
13
|
+
|
14
|
+
# Gets the data class for the given mime type
|
15
|
+
def class_type_from(mime_type)
|
16
|
+
mapping_for(mime_type)[:type]
|
17
|
+
end
|
18
|
+
|
19
|
+
def loader_type_from(mime_type)
|
20
|
+
map = mapping_for(mime_type)
|
21
|
+
map[:loader] || map[:type]
|
22
|
+
end
|
13
23
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
:
|
40
|
-
|
41
|
-
:
|
42
|
-
:
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
24
|
+
# Set a new mapping for the given MIME type. If only a class is given, this
|
25
|
+
# will use the class to create new data records from. If a symbol is given
|
26
|
+
# for the class name, this will take the corresponding class from
|
27
|
+
# TaliaCore::DataTypes.
|
28
|
+
#
|
29
|
+
# The loader method can be a symbol, if given it must correspond to a *class*
|
30
|
+
# method that can be called on type_class and which accepts exactly 4 parameters,
|
31
|
+
# which will be passed in during record creation
|
32
|
+
#
|
33
|
+
# * Mime type of the record
|
34
|
+
# * 'location' field of the record
|
35
|
+
# * The record source - this is a descriptive string with either the url
|
36
|
+
# or the file name from which the data should be fetched
|
37
|
+
# * The is_file flag. This will be true if the source is the name of a
|
38
|
+
# regular file. Otherwise, the source field should be interpreted as
|
39
|
+
# a URL.
|
40
|
+
# == Example handler method
|
41
|
+
#
|
42
|
+
# def data_loader(mime_type, location, source, is_file)
|
43
|
+
def add_mapping(mime_type, data_class, handler = nil)
|
44
|
+
mapping = {}
|
45
|
+
if(!data_class.is_a?(Class))
|
46
|
+
data_class = TaliaCore::DataTypes.const_get(data_class.to_s.camelize)
|
47
|
+
end
|
48
|
+
|
49
|
+
raise("Error: #{data_class} is not a valid data class.") unless(data_class.is_a?(Class) && (data_class <= DataRecord))
|
50
|
+
|
51
|
+
mapping[:type] = data_class
|
52
|
+
mapping[:loader] = handler.to_sym if(handler)
|
53
|
+
mapping_hash[symbol_for(mime_type)] = mapping
|
54
|
+
true
|
55
|
+
end
|
56
|
+
|
57
|
+
private
|
58
|
+
|
59
|
+
def symbol_for(mime_type)
|
60
|
+
mime_type = Mime::Type.lookup(mime_type) unless(mime_type.is_a?(Mime::Type))
|
61
|
+
mime_type.to_sym
|
62
|
+
end
|
63
|
+
|
64
|
+
def mapping_for(mime_type)
|
65
|
+
mapping = mapping_hash[symbol_for(mime_type)]
|
66
|
+
TaliaCore.logger.warn { "No data class registered for mime type #{mime_type.inspect}, trying default handler." } unless(mapping)
|
67
|
+
mapping ||= mapping_hash[:default]
|
68
|
+
|
69
|
+
raise(ArgumentError, "No data class registered for type #{mime_type.inspect}") unless(mapping)
|
70
|
+
mapping
|
71
|
+
end
|
72
|
+
|
73
|
+
# Currently there is only the default mapping
|
74
|
+
def mapping_hash
|
75
|
+
@mapping ||= {
|
76
|
+
:xml => { :type => DataTypes::XmlData },
|
77
|
+
:html =>{ :type => DataTypes::XmlData },
|
78
|
+
:tei => { :type => DataTypes::XmlData },
|
79
|
+
:tei_p5 => { :type => DataTypes::XmlData },
|
80
|
+
:tei_p4 => { :type => DataTypes::XmlData },
|
81
|
+
:gml => { :type => DataTypes::XmlData },
|
82
|
+
:wittei => { :type => DataTypes::XmlData },
|
83
|
+
:hnml => { :type => DataTypes::XmlData },
|
84
|
+
:jpeg => { :type => DataTypes::ImageData },
|
85
|
+
:tiff => { :type => DataTypes::ImageData },
|
86
|
+
:png => { :type => DataTypes::ImageData },
|
87
|
+
:gif => { :type => DataTypes::ImageData },
|
88
|
+
:bmp => { :type => DataTypes::ImageData },
|
89
|
+
:pdf => { :type => DataTypes::PdfData },
|
90
|
+
:text => { :type => DataTypes::SimpleText },
|
91
|
+
# Default fallback handler
|
92
|
+
:default => { :type => FileRecord }
|
93
|
+
}
|
94
|
+
end
|
95
|
+
|
48
96
|
end
|
49
|
-
|
50
|
-
|
97
|
+
|
51
98
|
end
|
52
|
-
|
99
|
+
|
53
100
|
end
|
54
101
|
end
|
@@ -5,42 +5,42 @@ module TaliaUtil
|
|
5
5
|
# Helper methods that will be used during import job runs.
|
6
6
|
# The import jobs may use the following environment parameters:
|
7
7
|
#
|
8
|
-
#
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
14
|
-
#
|
15
|
-
#
|
16
|
-
#
|
8
|
+
# [*base_url*] The base URL or directory. This will be prefixed to all urls, or if it is
|
9
|
+
# a local directory, it will be made the current directory during the import
|
10
|
+
# [*index*] If given, the importer will try to read this document. While this will still
|
11
|
+
# support the old-style "hyper" format with sigla, it should usually contain a
|
12
|
+
# main element called "index" followed by "url" entries.
|
13
|
+
# [*xml*] URL of an XML file to import. This is incompatible with the "index" option.
|
14
|
+
# If neither "xml" nor "index" are given, the class will try to read the XML data from
|
15
|
+
# STDIN
|
16
|
+
# [*importer*] Name of the importer class to be used for the data. Uses the default class if not given
|
17
17
|
# [*reset_store*] - If this is set, the data store will be cleared before the import
|
18
18
|
# [*user*] Username for HTTP authentication, if required
|
19
19
|
# [*pass*] Password for HTTP authentication, if required
|
20
20
|
# [*callback*] Name of a class. If given, the import will call the #before_import and #after_import
|
21
|
-
#
|
22
|
-
#
|
23
|
-
#
|
21
|
+
# methods on an object of that class. The call will receive a block which may be
|
22
|
+
# yielded to for each progress step and which can receive the overall number of
|
23
|
+
# steps
|
24
24
|
# [*extension*] Only used with index files; file extension to use
|
25
25
|
# [*duplicates*] How to deal with elements that already exist in the datastore. This may be
|
26
|
-
#
|
27
|
-
#
|
28
|
-
#
|
29
|
-
#
|
30
|
-
#
|
31
|
-
#
|
32
|
-
#
|
33
|
-
#
|
34
|
-
#
|
35
|
-
#
|
36
|
-
#
|
37
|
-
#
|
38
|
-
#
|
39
|
-
#
|
40
|
-
#
|
41
|
-
#
|
42
|
-
#
|
43
|
-
#
|
26
|
+
# set to one of the following options (default: :skip):
|
27
|
+
# * :add - Database fields will be updated and the system will add semantic
|
28
|
+
# properties as additional values, without removing any of the existing
|
29
|
+
# semantic relations. Example: If the data store already
|
30
|
+
# contains a title for an element, and the import file contains another
|
31
|
+
# for that element, the element will have two titles after the import.
|
32
|
+
# The system will not check for duplicates. Files will always be imported
|
33
|
+
# in addition to the existing ones.
|
34
|
+
# * :update - Database fields will be updated, and semantic properties will
|
35
|
+
# be overwritten with the new value(s). Semantic properties that are not
|
36
|
+
# included in the import data will be left untouched. In the example above,
|
37
|
+
# the element would only contain the new title. If the element also contained
|
38
|
+
# author information, and no author information was in the import file, the
|
39
|
+
# existing author information will be untouched. Existing files are replaced
|
40
|
+
# if the import contains new files
|
41
|
+
# * :overwrite - Database fields will be updated. All semantic data will be
|
42
|
+
# deleted before the import. Files are always removed.
|
43
|
+
# * :skip - If an element already exists, the import will be skipped.
|
44
44
|
#
|
45
45
|
# [*trace*] Enable tracing output for errors. (By default, this takes the rake task's setting
|
46
46
|
# if possible)
|
@@ -153,20 +153,6 @@ module TaliaCore
|
|
153
153
|
new_rec = DataTypes::DataRecord.find(data_record.id)
|
154
154
|
assert_equal(expected_content, new_rec.content_string)
|
155
155
|
end
|
156
|
-
|
157
|
-
def test_class_type_from
|
158
|
-
['text/plain'].each do |mime|
|
159
|
-
assert_equal('SimpleText', DataTypes::FileRecord.class_type_from(mime))
|
160
|
-
end
|
161
|
-
|
162
|
-
@image_mime_types.each { |mime| assert_equal('ImageData', DataTypes::FileRecord.class_type_from(mime)) }
|
163
|
-
|
164
|
-
['text/xml', 'application/xml'].each do |mime|
|
165
|
-
assert_equal('XmlData', DataTypes::FileRecord.class_type_from(mime))
|
166
|
-
end
|
167
|
-
|
168
|
-
assert_equal('DataRecord', DataTypes::FileRecord.class_type_from('application/rtf'))
|
169
|
-
end
|
170
156
|
|
171
157
|
end
|
172
158
|
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
|
3
|
+
# Load the helper class
|
4
|
+
require File.join(File.dirname(__FILE__), '..', '..', 'test_helper')
|
5
|
+
|
6
|
+
module TaliaCore
|
7
|
+
|
8
|
+
# Test the DataRecord storage class
|
9
|
+
class MimeMappingTest < ActiveSupport::TestCase
|
10
|
+
|
11
|
+
def setup
|
12
|
+
@image_mime_types = ['image/gif', 'image/jpeg', 'image/png', 'image/tiff', 'image/bmp']
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_class_type_from
|
16
|
+
['text/plain'].each do |mime|
|
17
|
+
assert_equal(DataTypes::SimpleText, DataTypes::MimeMapping.class_type_from(mime))
|
18
|
+
end
|
19
|
+
|
20
|
+
@image_mime_types.each { |mime| assert_equal(DataTypes::ImageData, DataTypes::MimeMapping.class_type_from(mime), "Wrong type for #{mime} - #{DataTypes::MimeMapping.class_type_from(mime)}") }
|
21
|
+
|
22
|
+
['text/xml', 'application/xml'].each do |mime|
|
23
|
+
assert_equal(DataTypes::XmlData, DataTypes::MimeMapping.class_type_from(mime), "Wrong type for #{mime} - #{DataTypes::MimeMapping.class_type_from(mime)}")
|
24
|
+
end
|
25
|
+
|
26
|
+
assert_equal(DataTypes::FileRecord, DataTypes::MimeMapping.class_type_from('application/rtf'))
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_add_mime_mapping
|
30
|
+
DataTypes::MimeMapping.add_mapping(Mime::Type.new('foo'), DataTypes::ImageData)
|
31
|
+
assert_equal(DataTypes::ImageData, DataTypes::MimeMapping.class_type_from('foo'))
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_add_mime_loader
|
35
|
+
DataTypes::MimeMapping.add_mapping(Mime::Type.new('bar'), DataTypes::ImageData, :create_iip)
|
36
|
+
assert_equal(DataTypes::ImageData, DataTypes::MimeMapping.class_type_from(:bar))
|
37
|
+
assert_equal(:create_iip, DataTypes::MimeMapping.loader_type_from(:bar))
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
end
|
data/test/test_helper.rb
CHANGED
@@ -24,6 +24,13 @@ module TaliaCore
|
|
24
24
|
# Check if we have old (1.2.3-Rails) style ActiveRecord without fixture cache
|
25
25
|
@@new_ar = Fixtures.respond_to?(:reset_cache)
|
26
26
|
|
27
|
+
# The tests expect the system to be set to iip creation
|
28
|
+
TaliaCore::DataTypes::MimeMapping.add_mapping(:jpeg, DataTypes::ImageData, :create_iip)
|
29
|
+
TaliaCore::DataTypes::MimeMapping.add_mapping(:tiff, DataTypes::ImageData, :create_iip)
|
30
|
+
TaliaCore::DataTypes::MimeMapping.add_mapping(:png, DataTypes::ImageData, :create_iip)
|
31
|
+
TaliaCore::DataTypes::MimeMapping.add_mapping(:bmp, DataTypes::ImageData, :create_iip)
|
32
|
+
TaliaCore::DataTypes::MimeMapping.add_mapping(:gif, DataTypes::ImageData, :create_iip)
|
33
|
+
|
27
34
|
# connect the database
|
28
35
|
def self.startup
|
29
36
|
if(!TaliaCore::Initializer.initialized)
|
metadata
CHANGED
@@ -1,18 +1,19 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: talia_core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Danilo Giacomi
|
8
8
|
- Roberto Tofani
|
9
9
|
- Luca Guidi
|
10
|
+
- Michele Nucci
|
10
11
|
- Daniel Hahn
|
11
12
|
autorequire:
|
12
13
|
bindir: bin
|
13
14
|
cert_chain: []
|
14
15
|
|
15
|
-
date: 2009-12-
|
16
|
+
date: 2009-12-15 00:00:00 +01:00
|
16
17
|
default_executable: talia
|
17
18
|
dependencies:
|
18
19
|
- !ruby/object:Gem::Dependency
|
@@ -66,7 +67,7 @@ dependencies:
|
|
66
67
|
version: 2.0.6
|
67
68
|
version:
|
68
69
|
- !ruby/object:Gem::Dependency
|
69
|
-
name:
|
70
|
+
name: bjj
|
70
71
|
type: :runtime
|
71
72
|
version_requirement:
|
72
73
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -232,6 +233,7 @@ files:
|
|
232
233
|
- generators/talia_base/templates/app/views/types/show.html.erb
|
233
234
|
- generators/talia_base/templates/config/routes.rb
|
234
235
|
- generators/talia_base/templates/config/talia_initializer.rb
|
236
|
+
- generators/talia_base/templates/config/warble.rb
|
235
237
|
- generators/talia_base/templates/migrations/bj_migration.rb
|
236
238
|
- generators/talia_base/templates/migrations/constraint_migration.rb
|
237
239
|
- generators/talia_base/templates/migrations/create_active_sources.rb
|
@@ -403,6 +405,7 @@ test_files:
|
|
403
405
|
- test/talia_core/data_types/file_record_test.rb
|
404
406
|
- test/talia_core/data_types/iip_data_test.rb
|
405
407
|
- test/talia_core/data_types/image_data_test.rb
|
408
|
+
- test/talia_core/data_types/mime_mapping_test.rb
|
406
409
|
- test/talia_core/data_types/pdf_data_test.rb
|
407
410
|
- test/talia_core/data_types/xml_data_test.rb
|
408
411
|
- test/talia_core/workflow/publication_workflow_test.rb
|