lib/abrizer/read_adaptations.rb in abrizer-0.4.0 vs lib/abrizer/read_adaptations.rb in abrizer-0.5.0
- old
+ new
@@ -1,17 +1,15 @@
module Abrizer
module ReadAdaptations
-
-
def read_adaptations
# Either we have a filepath to an original or we make the assumption we
# really have an identifier instead of a filepath and we use that
# identifier to look for an adaptations.json file. Failing finding the
# adaptations.json file we just use the adaptations based on the
# vp9_filepath.
- if File.exist?(File.expand_path(@filepath)) && !File.directory?(@filepath)
+ if @filepath && File.exist?(@filepath) && !File.directory?(@filepath)
@filename = @filepath
find_adaptations
elsif File.exist? adaptations_filepath
# assume we have an identifier and look up for the adaptations file
adaptations_json = File.read adaptations_filepath
@@ -25,10 +23,16 @@
elsif File.exist? vp9_filepath
# assume we just got an identifier and look for the webm
@filename = vp9_filepath
find_adaptations
else
- raise "Neither original file or VP9 version exist."
+ raise ReadAdaptationsError
end
end
+
+ def find_adaptations
+ finder = AdaptationFinder.new(filepath: @filename)
+ @adaptations = finder.adaptations
+ end
+
end
end