lib/overlayer.rb in sensible-cinema-0.20.5 vs lib/overlayer.rb in sensible-cinema-0.21.3
- old
+ new
@@ -13,16 +13,19 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Sensible Cinema. If not, see <http://www.gnu.org/licenses/>.
=end
+
require 'sane'
require 'thread'
require 'timeout'
require 'yaml'
require_relative 'muter'
require_relative 'blanker'
+require_relative 'edl_parser'
+
require 'pp' # for pretty_inspect
class OverLayer
def muted?
@@ -67,21 +70,21 @@
end
attr_accessor :all_sequences
def reload_yaml!
- @all_sequences = OverLayer.translate_yaml(File.read(@filename))
+ @all_sequences = OverLayer.translate_file(@filename)
puts '(re) loaded mute sequences from ' + File.basename(@filename) + ' as', pretty_sequences.pretty_inspect, "" unless defined?($AM_IN_UNIT_TEST)
signal_change
end
def pretty_sequences
new_sequences = {}
@all_sequences.each{|type, values|
if values.is_a? Array
new_sequences[type] = values.map{|s, f|
- [translate_time_to_human_readable(s), translate_time_to_human_readable(f)]
+ [EdlParser.translate_time_to_human_readable(s), EdlParser.translate_time_to_human_readable(f)]
}
else
new_sequences[type] = values
end
}
@@ -104,21 +107,22 @@
@just_unblanked = false
@start_time = Time.now_f # assume they want to start immediately...
end
# note this is actually deprecated and won't work anymore <sigh> and needs to be updated.
- def self.translate_yaml raw_yaml
+ def self.translate_file filename
begin
- all = YAML.load(raw_yaml) || {}
- rescue NoMethodError, ArgumentError
- p 'appears your file has a syntax error in it--perhaps missing quotation marks?'
- return
+ all = EdlParser.parse_file(filename)
+ rescue NoMethodError, ArgumentError => e
+ p 'appears your file has a syntax error in it--perhaps missing quotation marks?', e.to_s
+ raise e # hope this is ok...
end
+
# now it's like {:mutes => {"1:02.0" => "1:3.0"}}
# translate to floats like 62.0 => 63.0
- for type in [:mutes, :blank_outs]
+ for type in [:mutes, :blank_outs] # LODO standardize these :mutes and :blank_outs somewhere...scary to have them repeated *everywhere*
maps = all[type] || all[type.to_s] || {}
new = {}
maps.each{|start,endy|
# both are like 1:02.0
start2 = EdlParser.translate_string_to_seconds(start) if start
@@ -160,20 +164,20 @@
def cur_time
Time.now_f - @start_time
end
def cur_english_time
- translate_time_to_human_readable(cur_time)
+ EdlParser.translate_time_to_human_readable(cur_time)
end
def status
time = cur_english_time
begin
mute, blank, next_sig = get_current_state
if next_sig == :done
state = " no more after this point..."
else
- state = " next will be at #{translate_time_to_human_readable next_sig}s "
+ state = " next will be at #{EdlParser.translate_time_to_human_readable next_sig}s "
end
if blank? or muted?
state += "(" + [muted? ? "muted" : nil, blank? ? "blanked" : nil ].compact.join(' ') + ") "
end
end