assembly-objectfile 1.6.7 → 1.6.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +6 -3
- data/assembly-objectfile.gemspec +3 -4
- data/lib/assembly-objectfile/content_metadata.rb +5 -7
- data/lib/assembly-objectfile/object_fileable.rb +4 -0
- data/lib/assembly-objectfile/version.rb +1 -1
- data/spec/content_metadata_spec.rb +381 -381
- data/spec/object_file_spec.rb +81 -63
- data/spec/spec_helper.rb +4 -0
- metadata +8 -9
data/spec/object_file_spec.rb
CHANGED
@@ -4,137 +4,155 @@ describe Assembly::ObjectFile do
|
|
4
4
|
|
5
5
|
it "should not run if no input file is passed in" do
|
6
6
|
@ai=Assembly::ObjectFile.new('')
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
expect{@ai.filesize}.to raise_error(RuntimeError,'input file does not exist')
|
8
|
+
expect{@ai.sha1}.to raise_error(RuntimeError,'input file does not exist')
|
9
|
+
expect{@ai.md5}.to raise_error(RuntimeError,'input file does not exist')
|
10
10
|
end
|
11
11
|
|
12
12
|
it "should return the common directory of a set of filenames passed into it, where the common part does not terminate on a directory" do
|
13
|
-
Assembly::ObjectFile.common_path(['/Users/peter/00/test.tif','/Users/peter/05/test.jp2']).
|
13
|
+
expect(Assembly::ObjectFile.common_path(['/Users/peter/00/test.tif','/Users/peter/05/test.jp2'])).to eq("/Users/peter/")
|
14
14
|
end
|
15
15
|
|
16
16
|
it "should return the common directory of a set of filenames passed into it, where the common part does not terminate on a directory" do
|
17
|
-
Assembly::ObjectFile.common_path(['/Users/peter/00/test.tif','/Users/peter/00/test.jp2']).
|
17
|
+
expect(Assembly::ObjectFile.common_path(['/Users/peter/00/test.tif','/Users/peter/00/test.jp2'])).to eq("/Users/peter/00/")
|
18
18
|
end
|
19
19
|
|
20
20
|
it "should tell us if an input file is an image" do
|
21
|
-
File.exists?(TEST_TIF_INPUT_FILE).
|
21
|
+
expect(File.exists?(TEST_TIF_INPUT_FILE)).to be true
|
22
22
|
@ai = Assembly::ObjectFile.new(TEST_TIF_INPUT_FILE)
|
23
|
-
@ai.image
|
24
|
-
@ai.exif.
|
25
|
-
@ai.mimetype.
|
26
|
-
@ai.file_mimetype.
|
27
|
-
@ai.object_type.
|
28
|
-
@ai.valid_image
|
29
|
-
@ai.jp2able
|
23
|
+
expect(@ai.image?).to eq(true)
|
24
|
+
expect(@ai.exif).not_to be nil
|
25
|
+
expect(@ai.mimetype).to eq('image/tiff')
|
26
|
+
expect(@ai.file_mimetype).to eq('image/tiff')
|
27
|
+
expect(@ai.object_type).to eq(:image)
|
28
|
+
expect(@ai.valid_image?).to eq(true)
|
29
|
+
expect(@ai.jp2able?).to eq(true)
|
30
30
|
end
|
31
31
|
|
32
32
|
it "should tell us information about the input file" do
|
33
33
|
@ai = Assembly::ObjectFile.new(TEST_TIF_INPUT_FILE)
|
34
|
-
@ai.filename.
|
35
|
-
@ai.ext.
|
36
|
-
@ai.filename_without_ext.
|
37
|
-
@ai.dirname.
|
34
|
+
expect(@ai.filename).to eq("test.tif")
|
35
|
+
expect(@ai.ext).to eq(".tif")
|
36
|
+
expect(@ai.filename_without_ext).to eq("test")
|
37
|
+
expect(@ai.dirname).to eq(File.dirname(TEST_TIF_INPUT_FILE))
|
38
38
|
end
|
39
39
|
|
40
40
|
it "should give us the mimetype of a file even if the exif information is damaged" do
|
41
41
|
@ai = Assembly::ObjectFile.new(TEST_FILE_NO_EXIF)
|
42
|
-
@ai.filename.
|
43
|
-
@ai.ext.
|
44
|
-
['text/html','application/xml'].include?(@ai.mimetype).
|
42
|
+
expect(@ai.filename).to eq("file_with_no_exif.xml")
|
43
|
+
expect(@ai.ext).to eq(".xml")
|
44
|
+
expect(['text/html','application/xml'].include?(@ai.mimetype)).to be true # we could get either of these mimetypes depending on the OS
|
45
45
|
end
|
46
46
|
|
47
47
|
it "should give us the DPG base name for a file" do
|
48
48
|
test_file=File.join(TEST_INPUT_DIR,'oo000oo0001_00_001.tif')
|
49
49
|
@ai = Assembly::ObjectFile.new(test_file)
|
50
|
-
@ai.dpg_basename.
|
50
|
+
expect(@ai.dpg_basename).to eq("oo000oo0001_001")
|
51
51
|
end
|
52
52
|
|
53
53
|
it "should give us the DPG subfolder name for a file" do
|
54
54
|
test_file=File.join(TEST_INPUT_DIR,'oo000oo0001_05_001.tif')
|
55
55
|
@ai = Assembly::ObjectFile.new(test_file)
|
56
|
-
@ai.dpg_folder.
|
56
|
+
expect(@ai.dpg_folder).to eq("05")
|
57
57
|
end
|
58
58
|
|
59
59
|
it "should tell us that a jp2 file is not jp2able but does have a color profile" do
|
60
|
-
File.exists?(TEST_JP2_INPUT_FILE).
|
60
|
+
expect(File.exists?(TEST_JP2_INPUT_FILE)).to be true
|
61
61
|
@ai = Assembly::ObjectFile.new(TEST_JP2_INPUT_FILE)
|
62
|
-
@ai.image
|
63
|
-
@ai.object_type.
|
64
|
-
@ai.valid_image
|
65
|
-
@ai.jp2able
|
66
|
-
@ai.has_color_profile
|
62
|
+
expect(@ai.image?).to eq(true)
|
63
|
+
expect(@ai.object_type).to eq(:image)
|
64
|
+
expect(@ai.valid_image?).to eq(true)
|
65
|
+
expect(@ai.jp2able?).to eq(false)
|
66
|
+
expect(@ai.has_color_profile?).to eq(true)
|
67
67
|
end
|
68
68
|
|
69
69
|
it "should tell us that a tiff file is jp2able and has a color profile" do
|
70
|
-
File.exists?(TEST_RES1_TIF1).
|
70
|
+
expect(File.exists?(TEST_RES1_TIF1)).to be true
|
71
71
|
@ai = Assembly::ObjectFile.new(TEST_RES1_TIF1)
|
72
|
-
@ai.image
|
73
|
-
@ai.object_type.
|
74
|
-
@ai.valid_image
|
75
|
-
@ai.jp2able
|
76
|
-
@ai.has_color_profile
|
72
|
+
expect(@ai.image?).to eq(true)
|
73
|
+
expect(@ai.object_type).to eq(:image)
|
74
|
+
expect(@ai.valid_image?).to eq(true)
|
75
|
+
expect(@ai.jp2able?).to eq(true)
|
76
|
+
expect(@ai.has_color_profile?).to eq(true)
|
77
77
|
end
|
78
78
|
|
79
79
|
it "should tell us that a tiff file is not jp2able and is not valid since it has no profile" do
|
80
|
-
File.exists?(TEST_TIFF_NO_COLOR_FILE).
|
80
|
+
expect(File.exists?(TEST_TIFF_NO_COLOR_FILE)).to be true
|
81
81
|
@ai = Assembly::ObjectFile.new(TEST_TIFF_NO_COLOR_FILE)
|
82
|
-
@ai.image
|
83
|
-
@ai.object_type.
|
84
|
-
@ai.valid_image
|
85
|
-
@ai.jp2able
|
86
|
-
@ai.has_color_profile
|
82
|
+
expect(@ai.image?).to eq(true)
|
83
|
+
expect(@ai.object_type).to eq(:image)
|
84
|
+
expect(@ai.valid_image?).to eq(true)
|
85
|
+
expect(@ai.jp2able?).to eq(true)
|
86
|
+
expect(@ai.has_color_profile?).to eq(false)
|
87
87
|
end
|
88
88
|
|
89
89
|
it "should compute checksums for an image file" do
|
90
|
-
File.exists?(TEST_TIF_INPUT_FILE).
|
90
|
+
expect(File.exists?(TEST_TIF_INPUT_FILE)).to be true
|
91
91
|
@ai = Assembly::ObjectFile.new(TEST_TIF_INPUT_FILE)
|
92
|
-
@ai.md5.
|
93
|
-
@ai.sha1.
|
92
|
+
expect(@ai.md5).to eq('a2400500acf21e43f5440d93be894101')
|
93
|
+
expect(@ai.sha1).to eq('8d11fab63089a24c8b17063d29a4b0eac359fb41')
|
94
94
|
end
|
95
95
|
|
96
96
|
it "should indicate that the file is not found when a valid directory is supplied instead of a file or when an invalid file path is specified" do
|
97
97
|
path=Assembly::PATH_TO_GEM
|
98
98
|
@ai = Assembly::ObjectFile.new(path)
|
99
|
-
File.exists?(path).
|
100
|
-
File.directory?(path).
|
101
|
-
@ai.file_exists
|
99
|
+
expect(File.exists?(path)).to be true
|
100
|
+
expect(File.directory?(path)).to be true
|
101
|
+
expect(@ai.file_exists?).to be false
|
102
102
|
|
103
103
|
path=File.join(Assembly::PATH_TO_GEM,'bogus.txt')
|
104
104
|
@ai = Assembly::ObjectFile.new(path)
|
105
|
-
File.exists?(path).
|
106
|
-
File.directory?(path).
|
107
|
-
@ai.file_exists
|
105
|
+
expect(File.exists?(path)).to be false
|
106
|
+
expect(File.directory?(path)).to be false
|
107
|
+
expect(@ai.file_exists?).to be false
|
108
|
+
end
|
109
|
+
|
110
|
+
it "should set attributes correctly when initializing" do
|
111
|
+
@ai = Assembly::ObjectFile.new('/some/file.txt')
|
112
|
+
expect(@ai.path).to eq('/some/file.txt')
|
113
|
+
expect(@ai.label).to be_nil
|
114
|
+
expect(@ai.file_attributes).to be_nil
|
115
|
+
expect(@ai.provider_sha1).to be_nil
|
116
|
+
expect(@ai.provider_md5).to be_nil
|
117
|
+
expect(@ai.relative_path).to be_nil
|
118
|
+
|
119
|
+
@ai = Assembly::ObjectFile.new('/some/file.txt',:label=>'some label',:file_attributes=>{'shelve'=>'yes','publish'=>'yes','preserve'=>'no'},:relative_path=>'/tmp')
|
120
|
+
expect(@ai.path).to eq('/some/file.txt')
|
121
|
+
expect(@ai.label).to eq('some label')
|
122
|
+
expect(@ai.file_attributes).to eq({'shelve'=>'yes','publish'=>'yes','preserve'=>'no'})
|
123
|
+
expect(@ai.provider_sha1).to be_nil
|
124
|
+
expect(@ai.provider_md5).to be_nil
|
125
|
+
expect(@ai.relative_path).to eq('/tmp')
|
108
126
|
end
|
109
127
|
|
110
128
|
it "should tell us if an input file is not an image" do
|
111
129
|
non_image_file=File.join(Assembly::PATH_TO_GEM,'spec/object_file_spec.rb')
|
112
|
-
File.exists?(non_image_file).
|
130
|
+
expect(File.exists?(non_image_file)).to be true
|
113
131
|
@ai = Assembly::ObjectFile.new(non_image_file)
|
114
|
-
@ai.image
|
115
|
-
@ai.object_type.
|
116
|
-
@ai.valid_image
|
132
|
+
expect(@ai.image?).to eq(false)
|
133
|
+
expect(@ai.object_type).not_to eq(:image)
|
134
|
+
expect(@ai.valid_image?).to eq(false)
|
117
135
|
|
118
136
|
non_image_file=File.join(Assembly::PATH_TO_GEM,'README.rdoc')
|
119
|
-
File.exists?(non_image_file).
|
137
|
+
expect(File.exists?(non_image_file)).to be true
|
120
138
|
@ai = Assembly::ObjectFile.new(non_image_file)
|
121
|
-
@ai.image
|
122
|
-
@ai.object_type.
|
123
|
-
@ai.valid_image
|
139
|
+
expect(@ai.image?).to eq(false)
|
140
|
+
expect(@ai.object_type).to eq(:other)
|
141
|
+
expect(@ai.valid_image?).to eq(false)
|
124
142
|
end
|
125
143
|
|
126
144
|
it "should tell us the size of an input file" do
|
127
|
-
File.exists?(TEST_TIF_INPUT_FILE).
|
145
|
+
expect(File.exists?(TEST_TIF_INPUT_FILE)).to be true
|
128
146
|
@ai = Assembly::ObjectFile.new(TEST_TIF_INPUT_FILE)
|
129
|
-
@ai.filesize.
|
147
|
+
expect(@ai.filesize).to eq(63542)
|
130
148
|
end
|
131
149
|
|
132
150
|
it "should tell us the mimetype and encoding of an input file" do
|
133
|
-
File.exists?(TEST_TIF_INPUT_FILE).
|
151
|
+
expect(File.exists?(TEST_TIF_INPUT_FILE)).to be true
|
134
152
|
@ai = Assembly::ObjectFile.new(TEST_TIF_INPUT_FILE)
|
135
|
-
@ai.mimetype.
|
136
|
-
@ai.file_mimetype.
|
137
|
-
@ai.encoding.
|
153
|
+
expect(@ai.mimetype).to eq('image/tiff')
|
154
|
+
expect(@ai.file_mimetype).to eq('image/tiff')
|
155
|
+
expect(@ai.encoding).to eq('binary')
|
138
156
|
end
|
139
157
|
|
140
158
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
bootfile = File.expand_path(File.dirname(__FILE__) + '/../config/boot')
|
2
2
|
require bootfile
|
3
3
|
|
4
|
+
RSpec.configure do |config|
|
5
|
+
config.order = 'random'
|
6
|
+
end
|
7
|
+
|
4
8
|
TEST_DATA_DIR = File.join(Assembly::PATH_TO_GEM,'spec','test_data')
|
5
9
|
TEST_INPUT_DIR = File.join(TEST_DATA_DIR,'input')
|
6
10
|
TEST_OUTPUT_DIR = File.join(TEST_DATA_DIR,'output')
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: assembly-objectfile
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.6.
|
4
|
+
version: 1.6.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Mangiafico
|
@@ -9,9 +9,9 @@ authors:
|
|
9
9
|
- Monty Hindman
|
10
10
|
- Tony Calavano
|
11
11
|
autorequire:
|
12
|
-
bindir:
|
12
|
+
bindir: exe
|
13
13
|
cert_chain: []
|
14
|
-
date: 2016-
|
14
|
+
date: 2016-11-11 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: mini_exiftool
|
@@ -89,14 +89,14 @@ dependencies:
|
|
89
89
|
requirements:
|
90
90
|
- - "~>"
|
91
91
|
- !ruby/object:Gem::Version
|
92
|
-
version: '
|
92
|
+
version: '3.0'
|
93
93
|
type: :development
|
94
94
|
prerelease: false
|
95
95
|
version_requirements: !ruby/object:Gem::Requirement
|
96
96
|
requirements:
|
97
97
|
- - "~>"
|
98
98
|
- !ruby/object:Gem::Version
|
99
|
-
version: '
|
99
|
+
version: '3.0'
|
100
100
|
- !ruby/object:Gem::Dependency
|
101
101
|
name: yard
|
102
102
|
requirement: !ruby/object:Gem::Requirement
|
@@ -114,9 +114,7 @@ dependencies:
|
|
114
114
|
description: Get exif data, file sizes and more.
|
115
115
|
email:
|
116
116
|
- pmangiafico@stanford.edu
|
117
|
-
executables:
|
118
|
-
- console
|
119
|
-
- run_all_tests
|
117
|
+
executables: []
|
120
118
|
extensions: []
|
121
119
|
extra_rdoc_files: []
|
122
120
|
files:
|
@@ -195,7 +193,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
195
193
|
version: '0'
|
196
194
|
requirements: []
|
197
195
|
rubyforge_project: assembly-objectfile
|
198
|
-
rubygems_version: 2.
|
196
|
+
rubygems_version: 2.6.7
|
199
197
|
signing_key:
|
200
198
|
specification_version: 4
|
201
199
|
summary: Ruby immplementation of file services needed to prepare objects to be accessioned
|
@@ -237,3 +235,4 @@ test_files:
|
|
237
235
|
- spec/test_data/input/test2.jp2
|
238
236
|
- spec/test_data/input/test2.tif
|
239
237
|
- spec/test_data/input/test_no_color_profile.tif
|
238
|
+
has_rdoc:
|