format_parser 0.5.1 → 0.5.2
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 +4 -4
- data/lib/audio.rb +3 -4
- data/lib/format_parser/version.rb +1 -1
- data/lib/parsers/jpeg_parser.rb +3 -0
- data/spec/esoteric_formats_spec.rb +6 -0
- data/spec/parsers/jpeg_parser_spec.rb +7 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 90c91543dad4ef03fec136ae3b8fd3385ee518e5bbbebbba867a75142a1780f0
|
4
|
+
data.tar.gz: 5e7d286eefc1170391b6ff896d20e24f39682d2e5e4dc8a7c0b4c67df82eac92
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 864c0a272275c3d877ecf6fac7b2d7a080876074ee8e7b5858270da1418737cca3b8abc7290649a41f662209c2cf953f714334dc1adb6dabd68187fa3e2fcd25
|
7
|
+
data.tar.gz: cb04914d011588f6b53976fa5123f13b6ef9f5eb10c40bae1ea4e7c13ba51f382f10721d865164a4f8460554cb28881db7c8f4ff2217d4b1d0a115dbe5fbdf5e
|
data/lib/audio.rb
CHANGED
@@ -11,12 +11,11 @@ module FormatParser
|
|
11
11
|
# and for video files with embedded sound
|
12
12
|
attr_accessor :num_audio_channels
|
13
13
|
|
14
|
-
#
|
15
|
-
# and for video files with embedded sound
|
14
|
+
# The sample rate of the audio file in hertz, as an Integer
|
16
15
|
attr_accessor :audio_sample_rate_hz
|
17
16
|
|
18
|
-
# Duration of the media object (be it audio or video)
|
19
|
-
# as a Float
|
17
|
+
# Duration of the media object (be it audio or video)
|
18
|
+
# in seconds, as a Float
|
20
19
|
attr_accessor :media_duration_seconds
|
21
20
|
|
22
21
|
# Duration of the media object in addressable frames or samples,
|
data/lib/parsers/jpeg_parser.rb
CHANGED
@@ -98,6 +98,9 @@ class FormatParser::JPEGParser
|
|
98
98
|
@height = scanner.height
|
99
99
|
end
|
100
100
|
end
|
101
|
+
rescue EXIFR::MalformedJPEG
|
102
|
+
# Not a JPEG or the Exif headers contain invalid data, or
|
103
|
+
# an APP1 marker was detected in a file that is not a JPEG
|
101
104
|
end
|
102
105
|
|
103
106
|
def read_frame
|
@@ -7,4 +7,10 @@ describe 'Parsing esoteric files and files causing ambiguous detection' do
|
|
7
7
|
expect(result).not_to be_nil
|
8
8
|
expect(result.nature).to eq(:document)
|
9
9
|
end
|
10
|
+
|
11
|
+
it 'does not return a result for a Keynote file when it mistakes it for a JPEG, and does not raise any errors' do
|
12
|
+
jpeg_path = fixtures_dir + '/JPEG/keynote_recognized_as_jpeg.key'
|
13
|
+
result = FormatParser.parse(File.open(jpeg_path, 'rb'))
|
14
|
+
expect(result).to be_nil
|
15
|
+
end
|
10
16
|
end
|
@@ -48,4 +48,11 @@ describe FormatParser::JPEGParser do
|
|
48
48
|
expect(result.height_px).to eq(1280)
|
49
49
|
expect(result.intrinsics).to eq(exif_pixel_x_dimension: 8214, exif_pixel_y_dimension: 5476)
|
50
50
|
end
|
51
|
+
|
52
|
+
it 'fails correctly (with the right exception being raised) on a Keynote file' do
|
53
|
+
jpeg_path = fixtures_dir + '/JPEG/keynote_recognized_as_jpeg.key'
|
54
|
+
expect {
|
55
|
+
subject.call(File.open(jpeg_path, 'rb'))
|
56
|
+
}.to raise_error(FormatParser::IOUtils::InvalidRead)
|
57
|
+
end
|
51
58
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: format_parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Noah Berman
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2018-04-
|
12
|
+
date: 2018-04-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: ks
|