Class: Quby::Questionnaires::Repos::BundleDiskRepo
- Defined in:
- lib/quby/questionnaires/repos/bundle_disk_repo.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #exists?(key) ⇒ Boolean
- #find(key) ⇒ Object
-
#initialize(path) ⇒ BundleDiskRepo
constructor
A new instance of BundleDiskRepo.
- #keys ⇒ Object
- #timestamp(key) ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(path) ⇒ BundleDiskRepo
Returns a new instance of BundleDiskRepo.
12 13 14 15 |
# File 'lib/quby/questionnaires/repos/bundle_disk_repo.rb', line 12 def initialize(path) @path = path @questionnaire_cache = {} end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
10 11 12 |
# File 'lib/quby/questionnaires/repos/bundle_disk_repo.rb', line 10 def path @path end |
Instance Method Details
#exists?(key) ⇒ Boolean
30 31 32 33 |
# File 'lib/quby/questionnaires/repos/bundle_disk_repo.rb', line 30 def exists?(key) questionnaire_path = questionnaire_path(key) File.exist?(questionnaire_path) end |
#find(key) ⇒ Object
23 24 25 26 27 28 |
# File 'lib/quby/questionnaires/repos/bundle_disk_repo.rb', line 23 def find(key) fail(QuestionnaireNotFound, key) unless exists?(key) json = read(key) = File.mtime(questionnaire_path(key)) Entities::Definition.new(key: key, path: questionnaire_path(key), json: json, timestamp: ) end |
#keys ⇒ Object
17 18 19 20 21 |
# File 'lib/quby/questionnaires/repos/bundle_disk_repo.rb', line 17 def keys Dir[File.join(path, "*.rb")].map do |filename| File.basename(filename, '.rb') end end |
#timestamp(key) ⇒ Object
35 36 37 |
# File 'lib/quby/questionnaires/repos/bundle_disk_repo.rb', line 35 def (key) File.mtime(questionnaire_path(key)) end |