edl 0.0.5 → 0.0.6

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.
@@ -1,3 +1,8 @@
1
+ === 0.0.6 / 2000-01-14
2
+
3
+ * Fix comments in events appearing twice
4
+ * Capture extra comments that have no star at the beginning as fallback
5
+
1
6
  === 0.0.5 / 2000-01-14
2
7
 
3
8
  * EDL::Event#starts_with_transition? is an alias
data/SPECS.txt CHANGED
@@ -38,6 +38,7 @@
38
38
  * parse from a File/IOish
39
39
  * properly parse a dissolve
40
40
  * return a spliced EDL if the sources allow
41
+ * not apply any Matchers if a match is found (empty)
41
42
 
42
43
  == A TimewarpMatcher should
43
44
  * not create any extra events when used within a Parser
@@ -62,6 +63,12 @@
62
63
  * match a comment
63
64
  * apply the comment to the last clip on the stack
64
65
 
66
+ == FallbackMatcher should
67
+ * match anything
68
+ * not match whitespace
69
+ * append the matched content to comments
70
+ * raise an ApplyError if no clip is on the stack
71
+
65
72
  == ClipNameMatcher should
66
73
  * match a clip name
67
74
  * not match a simple comment
@@ -79,7 +86,10 @@
79
86
  == A FinalCutPro speedup with fade at the end should
80
87
  * be parsed cleanly
81
88
 
89
+ == In the trailer EDL the event 4 should
90
+ * not have too many comments
91
+
82
92
  == A FinalCutPro speedup and reverse with fade at the end should
83
93
  * parse cleanly
84
94
 
85
- 59 specifications, 1 empty (161 requirements), 0 failures
95
+ 65 specifications, 2 empty (168 requirements), 0 failures
data/lib/edl.rb CHANGED
@@ -8,7 +8,7 @@ require File.dirname(__FILE__) + '/edl/timewarp'
8
8
 
9
9
  # A simplistic EDL parser
10
10
  module EDL
11
- VERSION = "0.0.5"
11
+ VERSION = "0.0.6"
12
12
  DEFAULT_FPS = 25
13
13
 
14
14
  # Represents an EDL, is returned from the parser. Traditional operation is functional style, i.e.
@@ -159,6 +159,21 @@ module EDL
159
159
  stack[-1].comments << line.scan(@regexp).flatten.pop.strip
160
160
  end
161
161
  end
162
+
163
+ # Fallback matcher for things like FINAL CUT PRO REEL
164
+ class FallbackMatcher < Matcher
165
+ def initialize
166
+ super(/^(\w)(.+)/)
167
+ end
168
+
169
+ def apply(stack, line)
170
+ begin
171
+ stack[-1].comments << line.scan(@regexp).flatten.join.strip
172
+ rescue NoMethodError
173
+ raise ApplyError.new("Line can only be a comment but no event was on the stack", line)
174
+ end
175
+ end
176
+ end
162
177
 
163
178
  # Clip name matcher
164
179
  class NameMatcher < Matcher
@@ -322,14 +337,13 @@ module EDL
322
337
  stack, matchers = List.new, get_matchers
323
338
  until io.eof?
324
339
  current_line = io.gets.strip
325
- matchers.each do | matcher |
326
- next unless matcher.matches?(current_line)
327
-
328
- begin
329
- matcher.apply(stack, current_line)
330
- rescue Matcher::ApplyError => e
331
- STDERR.puts "Cannot parse #{current_line} - #{e}"
332
- end
340
+ m = matchers.find{|m| m.matches?(current_line) }
341
+ next unless m
342
+
343
+ begin
344
+ m.apply(stack, current_line)
345
+ rescue Matcher::ApplyError => e
346
+ STDERR.puts "Cannot parse #{current_line} - #{e}"
333
347
  end
334
348
  end
335
349
  stack
@@ -60,7 +60,7 @@ module EDL
60
60
  end
61
61
 
62
62
  def outgoing_transition_duration #:nodoc:
63
- @outgoing_transition_duration || 0
63
+ @outgoing_transition_duration ||= 0
64
64
  end
65
65
 
66
66
  # Is the clip reversed in the edit?
@@ -282,6 +282,17 @@ context "A Parser should" do
282
282
  @spliced[0].src_start_tc.should.equal '06:42:50:18'.tc
283
283
  @spliced[0].src_end_tc.should.equal '06:42:52:16'.tc
284
284
  end
285
+
286
+ specify "not apply any Matchers if a match is found" do
287
+ p = EDL::Parser.new
288
+ m1 = flexmock
289
+ m1.should_receive(:matches?).with("plop").once.and_return(true)
290
+ m1.should_receive(:apply).once
291
+
292
+ flexmock(p).should_receive(:get_matchers).once.and_return([m1, m1])
293
+
294
+ p.parse("plop")
295
+ end
285
296
  end
286
297
 
287
298
  context "A TimewarpMatcher should" do
@@ -485,6 +496,38 @@ context "CommentMatcher should" do
485
496
  end
486
497
  end
487
498
 
499
+ context "FallbackMatcher should" do
500
+ specify "match anything" do
501
+ line = "SOME"
502
+ EDL::FallbackMatcher.new.matches?(line).should.equal true
503
+
504
+ line = "OR ANOTHER "
505
+ EDL::FallbackMatcher.new.matches?(line).should.equal true
506
+ end
507
+
508
+ specify "not match whitespace" do
509
+ line = "\s\s\s\r\n\r"
510
+ EDL::FallbackMatcher.new.matches?(line).should.equal false
511
+ end
512
+
513
+ specify "append the matched content to comments" do
514
+ e = flexmock
515
+ cmts = []
516
+ e.should_receive(:comments).and_return(cmts)
517
+
518
+ EDL::FallbackMatcher.new.apply([e], "FOOBAR")
519
+ cmts.should.equal ["FOOBAR"]
520
+
521
+ EDL::FallbackMatcher.new.apply([e], "FINAL CUT PRO REEL: 006-I REPLACED BY: 006I")
522
+ cmts.should.equal ["FOOBAR", "FINAL CUT PRO REEL: 006-I REPLACED BY: 006I"]
523
+ end
524
+
525
+ specify "raise an ApplyError if no clip is on the stack" do
526
+ lambda { EDL::FallbackMatcher.new.apply([], "FINAL CUT PRO REEL: 006-I REPLACED BY: 006I") }.should.raise(EDL::Matcher::ApplyError)
527
+ end
528
+
529
+ end
530
+
488
531
  context "ClipNameMatcher should" do
489
532
  specify "match a clip name" do
490
533
  line = "* FROM CLIP NAME: TAPE_6-10.MOV"
@@ -580,6 +623,14 @@ context "A FinalCutPro speedup with fade at the end should" do
580
623
  end
581
624
  end
582
625
 
626
+ context "In the trailer EDL the event 4 should" do
627
+ specify "not have too many comments" do
628
+ evts = EDL::Parser.new.parse(File.open(TRAILER_EDL))
629
+ evt = evts[6]
630
+ evt.comments.length.should.equal(5)
631
+ end
632
+ end
633
+
583
634
  context "A FinalCutPro speedup and reverse with fade at the end should" do
584
635
  specify "parse cleanly" do
585
636
  first_evt = EDL::Parser.new.parse(File.open(SPEEDUP_REVERSE_AND_FADEOUT)).shift
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: edl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julik
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-01-15 00:00:00 +01:00
12
+ date: 2009-01-17 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency