lib/edl.rb in edl-0.0.6 vs lib/edl.rb in edl-0.0.7
- old
+ new
@@ -6,12 +6,12 @@
require File.dirname(__FILE__) + '/edl/transition'
require File.dirname(__FILE__) + '/edl/timewarp'
# A simplistic EDL parser
module EDL
- VERSION = "0.0.6"
- DEFAULT_FPS = 25
+ VERSION = "0.0.7"
+ 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
@@ -154,11 +154,11 @@
def initialize
super(/\* (.+)/)
end
def apply(stack, line)
- stack[-1].comments << line.scan(@regexp).flatten.pop.strip
+ stack[-1].comments.push("* %s" % line.scan(@regexp).flatten.pop.strip)
end
end
# Fallback matcher for things like FINAL CUT PRO REEL
class FallbackMatcher < Matcher
@@ -333,16 +333,21 @@
# Parse a passed File or IO object line by line, or the whole string
def parse(io)
return parse(StringIO.new(io.to_s)) unless io.respond_to?(:eof?)
stack, matchers = List.new, get_matchers
+
+ at_line = 0
until io.eof?
+ at_line += 1
+
current_line = io.gets.strip
m = matchers.find{|m| m.matches?(current_line) }
next unless m
begin
m.apply(stack, current_line)
+ stack[-1].line_number = at_line if m.is_a?(EventMatcher)
rescue Matcher::ApplyError => e
STDERR.puts "Cannot parse #{current_line} - #{e}"
end
end
stack
\ No newline at end of file