format_parser 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 99d5518139da4b6ee5131ec57009f9c3982a3a3d
4
- data.tar.gz: 386ca02d14fac20a0d9d74bce6a43a65d862b73c
3
+ metadata.gz: ca1971c0e4a5b658e7d32101f068402fa7593fe7
4
+ data.tar.gz: '08494169e521c31c2620cce195b359eac0695cdc'
5
5
  SHA512:
6
- metadata.gz: 791c835fbd9a2cbbcb8dce9dc07c34417967880fff6c3e044ae07142c5da5e106be378041461b28673136a2639ae42ae24022438a00d4e53366edd126bc7ac1a
7
- data.tar.gz: 196a9d2137cee58e07621cd9e6140320863358830c4ca20407c11e5d523dce08790a9e132c97045e44a7d48ab82105499b6a0f9aa21314ccb5682136e87922c7
6
+ metadata.gz: 6d969293a2bc611dc5cba25be05328006938727f9d766d74baea6d1278fd0d0e8b41a045e8946773c9a9596997ab57459bcc7ee18aa6058d5e4947706d740452
7
+ data.tar.gz: 97f2968333b20bdbda8231f188649236d3209a64a4a9a847e2376b2fb7d0122b906d6a57b2cb10fcbf7b46832f160cb25178f42b5fc68eac318145d9731be84c
data/.gitignore CHANGED
@@ -10,4 +10,4 @@
10
10
  *.gem
11
11
 
12
12
  # rspec failure tracking
13
- .rspec_status
13
+ .rspec_status
data/README.md CHANGED
@@ -9,7 +9,7 @@ and [dimensions,](https://github.com/sstephenson/dimensions) borrowing from them
9
9
 
10
10
  ## Currently supported filetypes:
11
11
 
12
- `TIFF, PSD, PNG, MP3, JPEG, GIF, DPX, AIFF, WAV`
12
+ `TIFF, PSD, PNG, MP3, JPEG, GIF, DPX, AIFF, WAV, FDX`
13
13
 
14
14
  ...with more on the way!
15
15
 
@@ -65,3 +65,6 @@ Unless specified otherwise in this section the fixture files are MIT licensed an
65
65
  - c_11k16bitpcm.wav and c_8kmp316.wav are from [Wikipedia WAV](https://en.wikipedia.org/wiki/WAV#Comparison_of_coding_schemes), retrieved January 7, 2018
66
66
  - c_39064__alienbomb__atmo-truck.wav is from [freesound](https://freesound.org/people/alienbomb/sounds/39064/) and is CC0 licensed
67
67
  - c_M1F1-Alaw-AFsp.wav and d_6_Channel_ID.wav are from a [McGill Engineering site](http://www-mmsp.ece.mcgill.ca/Documents/AudioFormats/WAVE/Samples.html)
68
+
69
+ # FDX
70
+ - fixture.fdx was created by one of the project maintainers and is MIT licensed
@@ -58,6 +58,9 @@ module FormatParser
58
58
  # as an Integer
59
59
  attr_accessor :media_duration_frames
60
60
 
61
+ # XML Document Type
62
+ attr_accessor :document_type
63
+
61
64
  # If a parser wants to provide any extra information to the caller
62
65
  # it can be placed here
63
66
  attr_accessor :intrinsics
@@ -1,3 +1,3 @@
1
1
  module FormatParser
2
- VERSION = '0.1.4'
2
+ VERSION = '0.1.5'
3
3
  end
@@ -0,0 +1,30 @@
1
+ class FormatParser::FDXParser
2
+ include FormatParser::IOUtils
3
+
4
+ def information_from_io(io)
5
+ return if !xml_check(io)
6
+ file_and_document_type = safe_read(io, 100)
7
+ file_type, document_type = check_for_document_type(file_and_document_type)
8
+ return if file_type != :fdx
9
+ file_info = FormatParser::FileInformation.new(
10
+ file_nature: :document,
11
+ file_type: file_type,
12
+ document_type: document_type
13
+ )
14
+ end
15
+
16
+ def xml_check(io)
17
+ xml_check = safe_read(io, 5)
18
+ xml_check == "<?xml" ? true : false
19
+ end
20
+
21
+ def check_for_document_type(file_and_document_type)
22
+ sanitized_data = file_and_document_type.downcase
23
+ if sanitized_data.include?("finaldraft") && sanitized_data.include?("script")
24
+ return :fdx, :script
25
+ else
26
+ return
27
+ end
28
+ end
29
+ FormatParser.register_parser_constructor self
30
+ end
@@ -0,0 +1,24 @@
1
+ require 'spec_helper'
2
+
3
+ describe FormatParser::FDXParser do
4
+ describe 'is able to parse the sample file' do
5
+ Dir.glob(fixtures_dir + '/XML/*.fdx').each do |fdx_path|
6
+ it "is able to parse #{File.basename(fdx_path)}" do
7
+ parsed = subject.information_from_io(File.open(fdx_path, 'rb'))
8
+ expect(parsed).not_to be_nil
9
+ expect(parsed.file_nature).to eq(:document)
10
+ expect(parsed.file_type).to eq(:fdx)
11
+ expect(parsed.document_type).to eq(:script)
12
+ end
13
+ end
14
+ end
15
+
16
+ describe 'does not parse other XML files as FDX' do
17
+ Dir.glob(fixtures_dir + '/*.svg').each do |svg_path|
18
+ it 'returns nil when parsing a non-fdx xml file' do
19
+ parsed = subject.information_from_io(File.open(svg_path, 'rb'))
20
+ expect(parsed).to eq(nil)
21
+ end
22
+ end
23
+ end
24
+ 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.4
4
+ version: 0.1.5
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-09 00:00:00.000000000 Z
12
+ date: 2018-01-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ks
@@ -153,6 +153,7 @@ files:
153
153
  - lib/parsers/aiff_parser.rb
154
154
  - lib/parsers/dpx_parser.rb
155
155
  - lib/parsers/exif_parser.rb
156
+ - lib/parsers/fdx_parser.rb
156
157
  - lib/parsers/gif_parser.rb
157
158
  - lib/parsers/jpeg_parser.rb
158
159
  - lib/parsers/mp3_parser.rb
@@ -171,6 +172,7 @@ files:
171
172
  - spec/io_utils_spec.rb
172
173
  - spec/parsers/dpx_parser_spec.rb
173
174
  - spec/parsers/exif_parser_spec.rb
175
+ - spec/parsers/fdx_parser_spec.rb
174
176
  - spec/parsers/gif_parser_spec.rb
175
177
  - spec/parsers/jpeg_parser_spec.rb
176
178
  - spec/parsers/mp3_parser_spec.rb