assembly-objectfile 1.6.4 → 1.6.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ODY4NDJjOTlmMjZjYzIyMTMyNGRiODQ2MTU1MmU2NjZkNTM0YWYyMw==
5
+ data.tar.gz: !binary |-
6
+ YjJkNThkMTEwOTBmMWVkOTNiZGVkMjg4YTg1ZjIxMmM2NTQ1M2I1ZA==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ MGZhYmM4MjVhYmVlMDEzMjNlMTY1NzJhYWNiMzIxN2JhMTBmYmJkNDVjNTlj
10
+ NDEyMTNmOTA4MDY5NmZiYjE1MWFjODBlM2Y2ZjY4NGM5NjNkZmQ1Yzk3N2E0
11
+ Y2JmYTk1OTgxNmQwM2E5ZGZmMWM1NTIwNGExMDBkOTMzNmU4ZDA=
12
+ data.tar.gz: !binary |-
13
+ NGI1MTllMTUwYzdiNWNhM2I1YWFjMjRhY2ZhNGViNTMzMjVkYzk3NjJkZDNk
14
+ Mjg2NDFjYTUxYTRlOGE2ZDliNTQyYmI3ZWY3ZGJjZjY1ZTYxODNjZGMyMmU4
15
+ ZGIyZGUzOTRlYTZmOGEwZGJmMTE4NDQ1YjlkMmM5N2VhMWYzMTI=
data/README.rdoc CHANGED
@@ -66,6 +66,7 @@ content type specific operations (such as jp2 generation).
66
66
  - 1.6.2 Added APLv2 artifacts
67
67
  - 1.6.3 Integrate with TravisCI
68
68
  - 1.6.4 Try and solve UTF-8 encoding issues with exif data in images
69
+ - 1.6.5 Just use mime-types extension by default to compute mimetype to prevent calling to shell all the time (and avoid potential memory problems). A new method allows you to call out to shell if you really want to.
69
70
 
70
71
  ==Usage
71
72
 
@@ -81,7 +82,7 @@ The gem currently has methods for:
81
82
  ==Releasing the gem
82
83
 
83
84
  gem build assembly-objectfile.gemspec
84
- gem push assembly-objectfile-x.y.z.gem # replace x-y-z with the version number
85
+ gem push assembly-objectfile-x.y.z.gem # replace x-y-z with the version number, you'll need a ruby gems account to do this
85
86
 
86
87
  ==Generate documentation
87
88
  To generate documentation into the "doc" folder:
@@ -24,6 +24,7 @@ Gem::Specification.new do |s|
24
24
  s.add_dependency 'nokogiri'
25
25
  # s.add_dependency 'activesupport'
26
26
 
27
+ s.add_development_dependency 'rake'
27
28
  s.add_development_dependency 'json'
28
29
  s.add_development_dependency "rspec", "~> 2.6"
29
30
  # s.add_development_dependency "lyberteam-gems-devel", "> 1.0.0"
@@ -113,7 +113,7 @@ module Assembly
113
113
  def exif
114
114
  check_for_file unless @exif
115
115
  begin
116
- @exif ||= MiniExiftool.new(@path,:convert_encoding=>true)
116
+ @exif ||= MiniExiftool.new(@path,replace_invalid_chars: '?')
117
117
  rescue
118
118
  @exif = nil
119
119
  end
@@ -142,8 +142,8 @@ module Assembly
142
142
  check_for_file unless @sha1
143
143
  @sha1 ||= Digest::SHA1.file(path).hexdigest
144
144
  end
145
-
146
- # Returns mimetype information for the current file (only on unix based systems).
145
+
146
+ # Returns mimetype information for the current file based on file extension or exif data (if available)
147
147
  #
148
148
  # @return [string] mime type for supplied file
149
149
  #
@@ -151,14 +151,34 @@ module Assembly
151
151
  # source_file=Assembly::ObjectFile.new('/input/path_to_file.txt')
152
152
  # puts source_file.mimetype # gives 'text/plain'
153
153
  def mimetype
154
- check_for_file unless @mimetype
155
154
  if @mimetype.nil? # if we haven't computed it yet once for this object, try and get the mimetype
156
- @mimetype = `file --mime-type "#{@path}"`.gsub(/\n/,"").split(':')[1].strip # first try and get the mimetype from the unix file command
157
- @mimetype = exif.mimetype if (!Assembly::TRUSTED_MIMETYPES.include?(@mimetype) && !exif.nil? && !exif.mimetype.nil?) # if it's not a "trusted" mimetype and there is exif data; get the mimetype from the exif
155
+ if (!exif.nil? && !exif.mimetype.nil?) # try and get the mimetype from the exif data if it exists
156
+ @mimetype = exif.mimetype
157
+ else # otherwise get it from the mime-types gem (using the file extension) assuming we can find, if not, return blank
158
+ mimetype = MIME::Types.type_for(@path).first
159
+ @mimetype= mimetype ? mimetype.content_type : ''
160
+ end
158
161
  end
159
162
  return @mimetype
160
163
  end
161
164
 
165
+
166
+ # Returns mimetype information for the current file based on unix file system command or exif data (if available).
167
+ #
168
+ # @return [string] mime type for supplied file
169
+ #
170
+ # Example:
171
+ # source_file=Assembly::ObjectFile.new('/input/path_to_file.txt')
172
+ # puts source_file.file_mimetype # gives 'text/plain'
173
+ def file_mimetype
174
+ check_for_file unless @file_mimetype
175
+ if @file_mimetype.nil? # if we haven't computed it yet once for this object, try and get the mimetype
176
+ @file_mimetype = `file --mime-type "#{@path}"`.gsub(/\n/,"").split(':')[1].strip # first try and get the mimetype from the unix file command
177
+ @file_mimetype = exif.mimetype if (!Assembly::TRUSTED_MIMETYPES.include?(@file_mimetype) && !exif.nil? && !exif.mimetype.nil?) # if it's not a "trusted" mimetype and there is exif data; get the mimetype from the exif
178
+ end
179
+ return @file_mimetype
180
+ end
181
+
162
182
  # Returns encoding information for the current file (only on unix based systems).
163
183
  #
164
184
  # @return [string] encoding for supplied file
@@ -3,7 +3,7 @@ module Assembly
3
3
 
4
4
  class ObjectFile
5
5
  # Project version number
6
- VERSION = "1.6.4"
6
+ VERSION = "1.6.5"
7
7
  end
8
8
 
9
9
  end
@@ -23,11 +23,12 @@ describe Assembly::ObjectFile do
23
23
  @ai.image?.should == true
24
24
  @ai.exif.should_not be nil
25
25
  @ai.mimetype.should == 'image/tiff'
26
+ @ai.file_mimetype.should == 'image/tiff'
26
27
  @ai.object_type.should == :image
27
28
  @ai.valid_image?.should == true
28
29
  @ai.jp2able?.should == true
29
30
  end
30
-
31
+
31
32
  it "should tell us information about the input file" do
32
33
  @ai = Assembly::ObjectFile.new(TEST_TIF_INPUT_FILE)
33
34
  @ai.filename.should == "test.tif"
@@ -118,7 +119,7 @@ describe Assembly::ObjectFile do
118
119
  File.exists?(non_image_file).should be true
119
120
  @ai = Assembly::ObjectFile.new(non_image_file)
120
121
  @ai.image?.should == false
121
- @ai.object_type.should == :text
122
+ @ai.object_type.should == :other
122
123
  @ai.valid_image?.should == false
123
124
  end
124
125
 
@@ -132,6 +133,7 @@ describe Assembly::ObjectFile do
132
133
  File.exists?(TEST_TIF_INPUT_FILE).should be true
133
134
  @ai = Assembly::ObjectFile.new(TEST_TIF_INPUT_FILE)
134
135
  @ai.mimetype.should == 'image/tiff'
136
+ @ai.file_mimetype.should == 'image/tiff'
135
137
  @ai.encoding.should == 'binary'
136
138
  end
137
139
 
metadata CHANGED
@@ -1,8 +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
5
- prerelease:
4
+ version: 1.6.5
6
5
  platform: ruby
7
6
  authors:
8
7
  - Peter Mangiafico
@@ -12,12 +11,11 @@ authors:
12
11
  autorequire:
13
12
  bindir: bin
14
13
  cert_chain: []
15
- date: 2013-12-19 00:00:00.000000000 Z
14
+ date: 2015-04-13 00:00:00.000000000 Z
16
15
  dependencies:
17
16
  - !ruby/object:Gem::Dependency
18
17
  name: mini_exiftool
19
18
  requirement: !ruby/object:Gem::Requirement
20
- none: false
21
19
  requirements:
22
20
  - - ! '>='
23
21
  - !ruby/object:Gem::Version
@@ -25,7 +23,6 @@ dependencies:
25
23
  type: :runtime
26
24
  prerelease: false
27
25
  version_requirements: !ruby/object:Gem::Requirement
28
- none: false
29
26
  requirements:
30
27
  - - ! '>='
31
28
  - !ruby/object:Gem::Version
@@ -33,7 +30,6 @@ dependencies:
33
30
  - !ruby/object:Gem::Dependency
34
31
  name: mime-types
35
32
  requirement: !ruby/object:Gem::Requirement
36
- none: false
37
33
  requirements:
38
34
  - - ! '>='
39
35
  - !ruby/object:Gem::Version
@@ -41,7 +37,6 @@ dependencies:
41
37
  type: :runtime
42
38
  prerelease: false
43
39
  version_requirements: !ruby/object:Gem::Requirement
44
- none: false
45
40
  requirements:
46
41
  - - ! '>='
47
42
  - !ruby/object:Gem::Version
@@ -49,7 +44,6 @@ dependencies:
49
44
  - !ruby/object:Gem::Dependency
50
45
  name: nokogiri
51
46
  requirement: !ruby/object:Gem::Requirement
52
- none: false
53
47
  requirements:
54
48
  - - ! '>='
55
49
  - !ruby/object:Gem::Version
@@ -57,7 +51,20 @@ dependencies:
57
51
  type: :runtime
58
52
  prerelease: false
59
53
  version_requirements: !ruby/object:Gem::Requirement
60
- none: false
54
+ requirements:
55
+ - - ! '>='
56
+ - !ruby/object:Gem::Version
57
+ version: '0'
58
+ - !ruby/object:Gem::Dependency
59
+ name: rake
60
+ requirement: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - ! '>='
63
+ - !ruby/object:Gem::Version
64
+ version: '0'
65
+ type: :development
66
+ prerelease: false
67
+ version_requirements: !ruby/object:Gem::Requirement
61
68
  requirements:
62
69
  - - ! '>='
63
70
  - !ruby/object:Gem::Version
@@ -65,7 +72,6 @@ dependencies:
65
72
  - !ruby/object:Gem::Dependency
66
73
  name: json
67
74
  requirement: !ruby/object:Gem::Requirement
68
- none: false
69
75
  requirements:
70
76
  - - ! '>='
71
77
  - !ruby/object:Gem::Version
@@ -73,7 +79,6 @@ dependencies:
73
79
  type: :development
74
80
  prerelease: false
75
81
  version_requirements: !ruby/object:Gem::Requirement
76
- none: false
77
82
  requirements:
78
83
  - - ! '>='
79
84
  - !ruby/object:Gem::Version
@@ -81,7 +86,6 @@ dependencies:
81
86
  - !ruby/object:Gem::Dependency
82
87
  name: rspec
83
88
  requirement: !ruby/object:Gem::Requirement
84
- none: false
85
89
  requirements:
86
90
  - - ~>
87
91
  - !ruby/object:Gem::Version
@@ -89,7 +93,6 @@ dependencies:
89
93
  type: :development
90
94
  prerelease: false
91
95
  version_requirements: !ruby/object:Gem::Requirement
92
- none: false
93
96
  requirements:
94
97
  - - ~>
95
98
  - !ruby/object:Gem::Version
@@ -97,7 +100,6 @@ dependencies:
97
100
  - !ruby/object:Gem::Dependency
98
101
  name: yard
99
102
  requirement: !ruby/object:Gem::Requirement
100
- none: false
101
103
  requirements:
102
104
  - - ! '>='
103
105
  - !ruby/object:Gem::Version
@@ -105,7 +107,6 @@ dependencies:
105
107
  type: :development
106
108
  prerelease: false
107
109
  version_requirements: !ruby/object:Gem::Requirement
108
- none: false
109
110
  requirements:
110
111
  - - ! '>='
111
112
  - !ruby/object:Gem::Version
@@ -177,27 +178,26 @@ files:
177
178
  homepage: https://github.com/sul-dlss/assembly-objectfile
178
179
  licenses:
179
180
  - ALv2
181
+ metadata: {}
180
182
  post_install_message:
181
183
  rdoc_options: []
182
184
  require_paths:
183
185
  - lib
184
186
  required_ruby_version: !ruby/object:Gem::Requirement
185
- none: false
186
187
  requirements:
187
188
  - - ! '>='
188
189
  - !ruby/object:Gem::Version
189
190
  version: '0'
190
191
  required_rubygems_version: !ruby/object:Gem::Requirement
191
- none: false
192
192
  requirements:
193
193
  - - ! '>='
194
194
  - !ruby/object:Gem::Version
195
195
  version: '0'
196
196
  requirements: []
197
197
  rubyforge_project: assembly-objectfile
198
- rubygems_version: 1.8.28
198
+ rubygems_version: 2.4.2
199
199
  signing_key:
200
- specification_version: 3
200
+ specification_version: 4
201
201
  summary: Ruby immplementation of file services needed to prepare objects to be accessioned
202
202
  in SULAIR digital library
203
203
  test_files: