lib/edl.rb in edl-0.1.3 vs lib/edl.rb in edl-0.1.4
- old
+ new
@@ -8,11 +8,11 @@
require File.dirname(__FILE__) + '/edl/parser'
require File.dirname(__FILE__) + '/edl/linebreak_magician'
# A simplistic EDL parser
module EDL
- VERSION = "0.1.3"
+ VERSION = "0.1.4"
DEFAULT_FPS = 25.0
# Represents an EDL, is returned from the parser. Traditional operation is functional style, i.e.
# edl.renumbered.without_transitions.without_generators
class List < Array
@@ -132,11 +132,11 @@
# A generic matcher
class Matcher
class ApplyError < RuntimeError
def initialize(msg, line)
- super("%s - offending line was '%s'" % [msg, line])
+ super("%s - offending line was %s" % [msg, line.inspect])
end
end
def initialize(with_regexp)
@regexp = with_regexp
@@ -152,14 +152,16 @@
end
# EDL clip comment matcher, a generic one
class CommentMatcher < Matcher
def initialize
- super(/\* (.+)/)
+ super(/\*(.+)/)
end
def apply(stack, line)
+ raise ApplyError.new("No event to attach a comment to", line) if stack.empty?
+ # TODO: we should really remove "* " prefixes from comments
stack[-1].comments.push("* %s" % line.scan(@regexp).flatten.pop.strip)
end
end
# Fallback matcher for things like FINAL CUT PRO REEL
@@ -178,22 +180,22 @@
end
# Clip name matcher
class NameMatcher < Matcher
def initialize
- super(/\* FROM CLIP NAME:(\s+)(.+)/)
+ super(/\*\s*FROM CLIP NAME:(\s+)(.+)/)
end
def apply(stack, line)
stack[-1].clip_name = line.scan(@regexp).flatten.pop.strip
CommentMatcher.new.apply(stack, line)
end
end
class EffectMatcher < Matcher
def initialize
- super(/\* EFFECT NAME:(\s+)(.+)/)
+ super(/\*\s*EFFECT NAME:(\s+)(.+)/)
end
def apply(stack, line)
stack[-1].transition.effect = line.scan(@regexp).flatten.pop.strip
CommentMatcher.new.apply(stack, line)
@@ -288,21 +290,27 @@
end
evt = Event.new
transition_idx = props.delete(:transition)
evt.transition = case transition_idx
+ when 'C'
+ nil
when 'D'
d = Dissolve.new
d.duration = props.delete(:duration).to_i
d
when /W(\d+)/
w = Wipe.new
w.duration = props.delete(:duration).to_i
w.smpte_wipe_index = transition_idx.gsub(/W/, '')
w
+ when 'K'
+ k = Key.new
+ k.duration = props.delete(:duration).to_i
+ k
else
- nil
+ raise "Unknown transition type #{transition_idx}"
end
# Give a hint on the incoming clip as well
if evt.transition && stack[-1]
stack[-1].outgoing_transition_duration = evt.transition.duration
@@ -315,6 +323,6 @@
end
end
#:startdoc:
-end
\ No newline at end of file
+end