Sha256: e2517d10a746a4822e319a8c2813e0608f3c61fcf9fe14f86d2774a03340f813
Contents?: true
Size: 1.18 KB
Versions: 11
Compression:
Stored size: 1.18 KB
Contents
# frozen_string_literal: true require 'quby/questionnaires/repos' require 'quby/questionnaires' module Quby module Questionnaires module Repos class BundleDiskRepo < Base attr_reader :path def initialize(path) @path = path @questionnaire_cache = {} end def keys Dir[File.join(path, "*.rb")].map do |filename| File.basename(filename, '.rb') end end def find(key) fail(QuestionnaireNotFound, key) unless exists?(key) json = read(key) timestamp = File.mtime(questionnaire_path(key)) Entities::Definition.new(key: key, path: questionnaire_path(key), json: json, timestamp: timestamp) end def exists?(key) questionnaire_path = questionnaire_path(key) File.exist?(questionnaire_path) end def timestamp(key) File.mtime(questionnaire_path(key)) end private def read(key) JSON.parse(File.read(questionnaire_path(key))) end def questionnaire_path(key) File.join(path,key, "quby-frontend-v1.json") end end end end end
Version data entries
11 entries across 11 versions & 1 rubygems