class Pione::Package::ScenarioReader

ScenarioReader is a reader for scenario location.

Public Class Methods

new(location) click to toggle source
# File lib/pione/package/scenario-reader.rb, line 11
def initialize(location)
  @location = location
  @document_location = @location + "Scenario.pione"
  @info_location = @location + "pione-scenario.json"
end
read(location) click to toggle source
# File lib/pione/package/scenario-reader.rb, line 6
def read(location)
  new(location).read
end

Public Instance Methods

read() click to toggle source
# File lib/pione/package/scenario-reader.rb, line 17
def read
  if @document_location.mtime > @info_location.mtime
    # update the information file and make handler by it
    new_info = ScenarioScanner.scan(@location)
    return ScenarioHandler.new(@locaiton, new_info).tap {|handler| handler.write_info_file}
  else
    # make handler by informaiton file
    ScenarioHandler.new(@location, ScenarioInfo.read(@info_location))
  end
end