format_parser 0.1.7 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,12 +4,12 @@ describe FormatParser::GIFParser do
4
4
  describe 'is able to parse all the examples from FastImage' do
5
5
  Dir.glob(fixtures_dir + '/*.gif').each do |gif_path|
6
6
  it "is able to parse #{File.basename(gif_path)}" do
7
- parsed = subject.information_from_io(File.open(gif_path, 'rb'))
7
+ parsed = subject.call(File.open(gif_path, 'rb'))
8
8
 
9
9
  expect(parsed).not_to be_nil
10
10
 
11
- expect(parsed.file_nature).to eq(:image)
12
- expect(parsed.file_type).to eq(:gif)
11
+ expect(parsed.nature).to eq(:image)
12
+ expect(parsed.format).to eq(:gif)
13
13
  expect(parsed.color_mode).to eq(:indexed)
14
14
 
15
15
  expect(parsed.width_px).to be_kind_of(Integer)
@@ -25,7 +25,7 @@ describe FormatParser::GIFParser do
25
25
  it 'is able to parse the animated GIF' do
26
26
  gif_path = fixtures_dir + "GIF/anim.gif"
27
27
 
28
- parsed = subject.information_from_io(File.open(gif_path, 'rb'))
28
+ parsed = subject.call(File.open(gif_path, 'rb'))
29
29
  expect(parsed).not_to be_nil
30
30
 
31
31
  expect(parsed.width_px).to eq(320)
@@ -4,10 +4,10 @@ describe FormatParser::JPEGParser do
4
4
  describe 'is able to parse all the examples from FastImage' do
5
5
  Dir.glob(fixtures_dir + '/*.jpg').each do |jpeg_path|
6
6
  it "is able to parse #{File.basename(jpeg_path)}" do
7
- parsed = subject.information_from_io(File.open(jpeg_path, 'rb'))
7
+ parsed = subject.call(File.open(jpeg_path, 'rb'))
8
8
  expect(parsed).not_to be_nil
9
- expect(parsed.file_nature).to eq(:image)
10
- expect(parsed.file_type).to eq(:jpg)
9
+ expect(parsed.nature).to eq(:image)
10
+ expect(parsed.format).to eq(:jpg)
11
11
 
12
12
  expect(parsed.width_px).to be_kind_of(Integer)
13
13
  expect(parsed.width_px).to be > 0
@@ -21,7 +21,7 @@ describe FormatParser::JPEGParser do
21
21
  describe 'is able to parse all the JPEG exif examples from FastImage' do
22
22
  Dir.glob(fixtures_dir + '/exif-orientation-testimages/jpg/*.jpg').each do |jpeg_path|
23
23
  it "is able to parse #{File.basename(jpeg_path)}" do
24
- parsed = subject.information_from_io(File.open(jpeg_path, 'rb'))
24
+ parsed = subject.call(File.open(jpeg_path, 'rb'))
25
25
  expect(parsed).not_to be_nil
26
26
 
27
27
  expect(parsed.orientation).to be_kind_of(Symbol)
@@ -1,3 +1,4 @@
1
+ # coding: utf-8
1
2
  require 'spec_helper'
2
3
 
3
4
  describe FormatParser::MOOVParser do
@@ -31,10 +32,10 @@ describe FormatParser::MOOVParser do
31
32
 
32
33
  Dir.glob(fixtures_dir + '/MOOV/**/*.*').sort.each do |moov_path|
33
34
  it "is able to parse #{File.basename(moov_path)}" do
34
- result = subject.information_from_io(File.open(moov_path, 'rb'))
35
+ result = subject.call(File.open(moov_path, 'rb'))
35
36
 
36
37
  expect(result).not_to be_nil
37
- expect(result.file_nature).to eq(:video)
38
+ expect(result.nature).to eq(:video)
38
39
  expect(result.width_px).to be > 0
39
40
  expect(result.height_px).to be > 0
40
41
  expect(result.media_duration_seconds).to be_kind_of(Float)
@@ -49,11 +50,11 @@ describe FormatParser::MOOVParser do
49
50
  it 'parses a MOV file and provides the necessary metadata' do
50
51
  mov_path = fixtures_dir + '/MOOV/MOV/Test_Circular_ProRes422.mov'
51
52
 
52
- result = subject.information_from_io(File.open(mov_path, 'rb'))
53
+ result = subject.call(File.open(mov_path, 'rb'))
53
54
 
54
55
  expect(result).not_to be_nil
55
- expect(result.file_nature).to eq(:video)
56
- expect(result.file_type).to eq(:mov)
56
+ expect(result.nature).to eq(:video)
57
+ expect(result.format).to eq(:mov)
57
58
  expect(result.width_px).to eq(1920)
58
59
  expect(result.height_px).to eq(1080)
59
60
  end
@@ -61,11 +62,11 @@ describe FormatParser::MOOVParser do
61
62
  it 'parses an MP4 video file and provides the necessary metadata' do
62
63
  mov_path = fixtures_dir + '/MOOV/MP4/bmff.mp4'
63
64
 
64
- result = subject.information_from_io(File.open(mov_path, 'rb'))
65
+ result = subject.call(File.open(mov_path, 'rb'))
65
66
 
66
67
  expect(result).not_to be_nil
67
- expect(result.file_nature).to eq(:video)
68
- expect(result.file_type).to eq(:mov)
68
+ expect(result.nature).to eq(:video)
69
+ expect(result.format).to eq(:mov)
69
70
  expect(result.width_px).to eq(160)
70
71
  expect(result.height_px).to eq(90)
71
72
  end
@@ -3,12 +3,12 @@ require 'spec_helper'
3
3
  describe FormatParser::MP3Parser do
4
4
  it 'decodes and estimates duration for a VBR MP3' do
5
5
  fpath = fixtures_dir + '/MP3/atc_fixture_vbr.mp3'
6
- parsed = subject.information_from_io(File.open(fpath, 'rb'))
6
+ parsed = subject.call(File.open(fpath, 'rb'))
7
7
 
8
8
  expect(parsed).not_to be_nil
9
9
 
10
- expect(parsed.file_nature).to eq(:audio)
11
- expect(parsed.file_type).to eq(:mp3)
10
+ expect(parsed.nature).to eq(:audio)
11
+ expect(parsed.format).to eq(:mp3)
12
12
  expect(parsed.num_audio_channels).to eq(2)
13
13
  expect(parsed.audio_sample_rate_hz).to eq(44100)
14
14
  expect(parsed.intrinsics).not_to be_nil
@@ -17,12 +17,12 @@ describe FormatParser::MP3Parser do
17
17
 
18
18
  it 'decodes and estimates duration for a CBR MP3' do
19
19
  fpath = fixtures_dir + '/MP3/atc_fixture_cbr.mp3'
20
- parsed = subject.information_from_io(File.open(fpath, 'rb'))
20
+ parsed = subject.call(File.open(fpath, 'rb'))
21
21
 
22
22
  expect(parsed).not_to be_nil
23
23
 
24
- expect(parsed.file_nature).to eq(:audio)
25
- expect(parsed.file_type).to eq(:mp3)
24
+ expect(parsed.nature).to eq(:audio)
25
+ expect(parsed.format).to eq(:mp3)
26
26
  expect(parsed.num_audio_channels).to eq(2)
27
27
  expect(parsed.audio_sample_rate_hz).to eq(44100)
28
28
  expect(parsed.intrinsics).not_to be_nil
@@ -31,12 +31,12 @@ describe FormatParser::MP3Parser do
31
31
 
32
32
  it 'parses the Cassy MP3' do
33
33
  fpath = fixtures_dir + '/MP3/Cassy.mp3'
34
- parsed = subject.information_from_io(File.open(fpath, 'rb'))
34
+ parsed = subject.call(File.open(fpath, 'rb'))
35
35
 
36
36
  expect(parsed).not_to be_nil
37
37
 
38
- expect(parsed.file_nature).to eq(:audio)
39
- expect(parsed.file_type).to eq(:mp3)
38
+ expect(parsed.nature).to eq(:audio)
39
+ expect(parsed.format).to eq(:mp3)
40
40
  expect(parsed.num_audio_channels).to eq(2)
41
41
  expect(parsed.audio_sample_rate_hz).to eq(44100)
42
42
  expect(parsed.intrinsics).not_to be_nil
@@ -4,10 +4,10 @@ describe FormatParser::PNGParser do
4
4
  describe 'is able to parse all the examples from FastImage' do
5
5
  Dir.glob(fixtures_dir + '/*.png').each do |png_path|
6
6
  it "is able to parse #{File.basename(png_path)}" do
7
- parsed = subject.information_from_io(File.open(png_path, 'rb'))
7
+ parsed = subject.call(File.open(png_path, 'rb'))
8
8
  expect(parsed).not_to be_nil
9
- expect(parsed.file_nature).to eq(:image)
10
- expect(parsed.file_type).to eq(:png)
9
+ expect(parsed.nature).to eq(:image)
10
+ expect(parsed.format).to eq(:png)
11
11
  expect(parsed.color_mode).to eq(:indexed)
12
12
 
13
13
  expect(parsed.width_px).to be_kind_of(Integer)
@@ -22,7 +22,7 @@ describe FormatParser::PNGParser do
22
22
  it 'is able to parse an animated PNG' do
23
23
  gif_path = fixtures_dir + "PNG/anim.png"
24
24
 
25
- parsed = subject.information_from_io(File.open(gif_path, 'rb'))
25
+ parsed = subject.call(File.open(gif_path, 'rb'))
26
26
  expect(parsed).not_to be_nil
27
27
 
28
28
  expect(parsed.width_px).to eq(320)
@@ -4,11 +4,11 @@ describe FormatParser::PSDParser do
4
4
  describe 'is able to parse all the examples from FastImage' do
5
5
  Dir.glob(fixtures_dir + '/*.psd').each do |psd_path|
6
6
  it "is able to parse #{File.basename(psd_path)}" do
7
- parsed = subject.information_from_io(File.open(psd_path, 'rb'))
7
+ parsed = subject.call(File.open(psd_path, 'rb'))
8
8
 
9
9
  expect(parsed).not_to be_nil
10
- expect(parsed.file_nature).to eq(:image)
11
- expect(parsed.file_type).to eq(:psd)
10
+ expect(parsed.nature).to eq(:image)
11
+ expect(parsed.format).to eq(:psd)
12
12
 
13
13
  expect(parsed.width_px).to be_kind_of(Integer)
14
14
  expect(parsed.width_px).to be > 0
@@ -4,11 +4,11 @@ describe FormatParser::TIFFParser do
4
4
  describe 'is able to parse all the examples from FastImage' do
5
5
  Dir.glob(fixtures_dir + '/TIFF/*.tif').each do |tiff_path|
6
6
  it "is able to parse #{File.basename(tiff_path)}" do
7
- parsed = subject.information_from_io(File.open(tiff_path, 'rb'))
7
+ parsed = subject.call(File.open(tiff_path, 'rb'))
8
8
 
9
9
  expect(parsed).not_to be_nil
10
- expect(parsed.file_nature).to eq(:image)
11
- expect(parsed.file_type).to eq(:tif)
10
+ expect(parsed.nature).to eq(:image)
11
+ expect(parsed.format).to eq(:tif)
12
12
 
13
13
  expect(parsed.width_px).to be_kind_of(Integer)
14
14
  expect(parsed.width_px).to be > 0
@@ -22,7 +22,7 @@ describe FormatParser::TIFFParser do
22
22
  describe 'is able to parse all the TIFF exif examples from FastImage' do
23
23
  Dir.glob(fixtures_dir + '/exif-orientation-testimages/tiff-*/*.tif').each do |tiff_path|
24
24
  it "is able to parse #{File.basename(tiff_path)}" do
25
- parsed = subject.information_from_io(File.open(tiff_path, 'rb'))
25
+ parsed = subject.call(File.open(tiff_path, 'rb'))
26
26
  expect(parsed).not_to be_nil
27
27
 
28
28
  expect(parsed.orientation).to be_kind_of(Symbol)
@@ -5,18 +5,18 @@ describe FormatParser::WAVParser do
5
5
  # while fixtures prefixed with d_ deviate from the standard.
6
6
  Dir.glob(fixtures_dir + '/WAV/c_*.*').each do |wav_path|
7
7
  it "is able to parse #{File.basename(wav_path)}" do
8
- parse_result = subject.information_from_io(File.open(wav_path, 'rb'))
8
+ parse_result = subject.call(File.open(wav_path, 'rb'))
9
9
 
10
- expect(parse_result.file_nature).to eq(:audio)
11
- expect(parse_result.file_type).to eq(:wav)
10
+ expect(parse_result.nature).to eq(:audio)
11
+ expect(parse_result.format).to eq(:wav)
12
12
  end
13
13
  end
14
14
 
15
15
  it "returns correct info about pcm files" do
16
- parse_result = subject.information_from_io(File.open(__dir__ + '/../fixtures/WAV/c_8kmp316.wav', 'rb'))
16
+ parse_result = subject.call(File.open(__dir__ + '/../fixtures/WAV/c_8kmp316.wav', 'rb'))
17
17
 
18
- expect(parse_result.file_nature).to eq(:audio)
19
- expect(parse_result.file_type).to eq(:wav)
18
+ expect(parse_result.nature).to eq(:audio)
19
+ expect(parse_result.format).to eq(:wav)
20
20
  expect(parse_result.num_audio_channels).to eq(1)
21
21
  expect(parse_result.audio_sample_rate_hz).to eq(8000)
22
22
  expect(parse_result.media_duration_frames).to eq(110488)
@@ -24,10 +24,10 @@ describe FormatParser::WAVParser do
24
24
  end
25
25
 
26
26
  it "returns correct info about pcm files with more channels" do
27
- parse_result = subject.information_from_io(File.open(__dir__ + '/../fixtures/WAV/c_39064__alienbomb__atmo-truck.wav', 'rb'))
27
+ parse_result = subject.call(File.open(__dir__ + '/../fixtures/WAV/c_39064__alienbomb__atmo-truck.wav', 'rb'))
28
28
 
29
- expect(parse_result.file_nature).to eq(:audio)
30
- expect(parse_result.file_type).to eq(:wav)
29
+ expect(parse_result.nature).to eq(:audio)
30
+ expect(parse_result.format).to eq(:wav)
31
31
  expect(parse_result.num_audio_channels).to eq(2)
32
32
  expect(parse_result.audio_sample_rate_hz).to eq(44100)
33
33
  expect(parse_result.media_duration_frames).to eq(162832)
@@ -35,10 +35,10 @@ describe FormatParser::WAVParser do
35
35
  end
36
36
 
37
37
  it "returns correct info about non pcm files" do
38
- parse_result = subject.information_from_io(File.open(__dir__ + '/../fixtures/WAV/c_11k16bitpcm.wav', 'rb'))
38
+ parse_result = subject.call(File.open(__dir__ + '/../fixtures/WAV/c_11k16bitpcm.wav', 'rb'))
39
39
 
40
- expect(parse_result.file_nature).to eq(:audio)
41
- expect(parse_result.file_type).to eq(:wav)
40
+ expect(parse_result.nature).to eq(:audio)
41
+ expect(parse_result.format).to eq(:wav)
42
42
  expect(parse_result.num_audio_channels).to eq(1)
43
43
  expect(parse_result.audio_sample_rate_hz).to eq(11025)
44
44
  expect(parse_result.media_duration_frames).to eq(152267)
@@ -47,7 +47,7 @@ describe FormatParser::WAVParser do
47
47
 
48
48
  it "cannot parse file with audio format different from 1 and no 'fact' chunk" do
49
49
  expect {
50
- subject.information_from_io(File.open(__dir__ + '/../fixtures/WAV/d_6_Channel_ID.wav', 'rb'))
50
+ subject.call(File.open(__dir__ + '/../fixtures/WAV/d_6_Channel_ID.wav', 'rb'))
51
51
  }.to raise_error(FormatParser::IOUtils::InvalidRead)
52
52
  end
53
53
  end
@@ -22,23 +22,23 @@ describe 'Fetching data from HTTP remotes' do
22
22
  it 'parses the animated PNG over HTTP' do
23
23
  file_information = FormatParser.parse_http('http://localhost:9399/PNG/anim.png')
24
24
  expect(file_information).not_to be_nil
25
- expect(file_information.file_nature).to eq(:image)
25
+ expect(file_information.first.nature).to eq(:image)
26
26
  end
27
27
 
28
28
  it 'parses the JPEGs exif data' do
29
29
  file_information = FormatParser.parse_http('http://localhost:9399/exif-orientation-testimages/jpg/top_left.jpg')
30
30
  expect(file_information).not_to be_nil
31
- expect(file_information.file_nature).to eq(:image)
32
- expect(file_information.file_type).to eq(:jpg)
33
- expect(file_information.orientation).to eq(:top_left)
31
+ expect(file_information.first.nature).to eq(:image)
32
+ expect(file_information.first.format).to eq(:jpg)
33
+ expect(file_information.first.orientation).to eq(:top_left)
34
34
  end
35
35
 
36
36
  it 'parses the TIFFs exif data' do
37
37
  file_information = FormatParser.parse_http('http://localhost:9399/TIFF/test.tif')
38
38
  expect(file_information).not_to be_nil
39
- expect(file_information.file_nature).to eq(:image)
40
- expect(file_information.file_type).to eq(:tif)
41
- expect(file_information.orientation).to eq(:top_left)
39
+ expect(file_information.first.nature).to eq(:image)
40
+ expect(file_information.first.format).to eq(:tif)
41
+ expect(file_information.first.orientation).to eq(:top_left)
42
42
  end
43
43
 
44
44
  describe 'is able to correctly parse orientation for all remote JPEG EXIF examples from FastImage' do
@@ -49,9 +49,9 @@ describe 'Fetching data from HTTP remotes' do
49
49
  file_information = FormatParser.parse_http(remote_jpeg_path)
50
50
  expect(file_information).not_to be_nil
51
51
 
52
- expect(file_information.orientation).to be_kind_of(Symbol)
52
+ expect(file_information.first.orientation).to be_kind_of(Symbol)
53
53
  # Filenames in this dir correspond with the orientation of the file
54
- expect(filename.include?(file_information.orientation.to_s)).to be true
54
+ expect(filename.include?(file_information.first.orientation.to_s)).to be true
55
55
  end
56
56
  end
57
57
  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.1.7
4
+ version: 0.2.0
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-01-16 00:00:00.000000000 Z
12
+ date: 2018-01-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ks
@@ -144,14 +144,17 @@ files:
144
144
  - README.md
145
145
  - Rakefile
146
146
  - format_parser.gemspec
147
+ - lib/audio.rb
147
148
  - lib/care.rb
148
- - lib/file_information.rb
149
+ - lib/document.rb
149
150
  - lib/format_parser.rb
150
151
  - lib/format_parser/version.rb
152
+ - lib/image.rb
151
153
  - lib/io_constraint.rb
152
154
  - lib/io_utils.rb
153
155
  - lib/parsers/aiff_parser.rb
154
156
  - lib/parsers/dpx_parser.rb
157
+ - lib/parsers/dsl.rb
155
158
  - lib/parsers/exif_parser.rb
156
159
  - lib/parsers/fdx_parser.rb
157
160
  - lib/parsers/gif_parser.rb
@@ -167,6 +170,7 @@ files:
167
170
  - lib/parsers/wav_parser.rb
168
171
  - lib/read_limiter.rb
169
172
  - lib/remote_io.rb
173
+ - lib/video.rb
170
174
  - spec/aiff_parser_spec.rb
171
175
  - spec/care_spec.rb
172
176
  - spec/file_information_spec.rb
@@ -192,7 +196,12 @@ licenses:
192
196
  - MIT
193
197
  metadata:
194
198
  allowed_push_host: https://rubygems.org
195
- post_install_message:
199
+ post_install_message: "\n -----------------------------------------------------------------------------\n
200
+ \ | ATTENTION: format_parser v0.2.0 introduces changes to the gem's interface.|\n
201
+ \ | See https://github.com/WeTransfer/format_parser#basic-usage |\n
202
+ \ | for up-to-date usage instructions. Thank you for using format_parser! :) |\n
203
+ \ -----------------------------------------------------------------------------\n
204
+ \ "
196
205
  rdoc_options: []
197
206
  require_paths:
198
207
  - lib
@@ -208,7 +217,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
208
217
  version: '0'
209
218
  requirements: []
210
219
  rubyforge_project:
211
- rubygems_version: 2.5.2
220
+ rubygems_version: 2.5.1
212
221
  signing_key:
213
222
  specification_version: 4
214
223
  summary: A library for efficient parsing of file metadata