diff --git a/exe/quby-compile b/exe/quby-compile index bd7d029ee651690ae823d481d575894e0bb08ce3..6807247e9415311b4e9f7a529ceed9531dff14d4 100755 --- a/exe/quby-compile +++ b/exe/quby-compile @@ -35,8 +35,7 @@ paths.each do |path| key = File.basename(File.dirname(path)) sourcecode = File.read(path) - last_update = File.mtime(path) - compiled = Quby::Compiler.compile(key, sourcecode, path: path, lookup_tables: lookup_tables, last_update: last_update) + compiled = Quby::Compiler.compile(key, sourcecode, path: path, lookup_tables: lookup_tables) FileUtils.mkdir_p(File.join(output_path, key)) compiled[:outputs].each do |type, output| diff --git a/lib/quby/compiler.rb b/lib/quby/compiler.rb index a6dfa7151316bf3a7dd3ec88ea903f782d156d11..360b9fed09c7b9269de6878f37cad2fb518f7fc1 100644 --- a/lib/quby/compiler.rb +++ b/lib/quby/compiler.rb @@ -29,12 +29,11 @@ require 'quby/compiler/outputs' module Quby module Compiler - def self.compile(key, sourcecode, path: nil, lookup_tables:, last_update: nil, &block) + def self.compile(key, sourcecode, path: nil, lookup_tables:, &block) Quby::Compiler::Instance.new(lookup_tables: lookup_tables).compile( key: key, sourcecode: sourcecode, path: path, - last_update: last_update, &block ) end diff --git a/lib/quby/compiler/dsl.rb b/lib/quby/compiler/dsl.rb index 219984352ac498749e48093a4ac7f76c6aeb144a..24bca770c01c648a7fcfc8c37a751601f4b43d8e 100644 --- a/lib/quby/compiler/dsl.rb +++ b/lib/quby/compiler/dsl.rb @@ -9,15 +9,15 @@ module Quby module Compiler module DSL def self.build_from_definition(definition) - Entities::Questionnaire.new(definition.key, last_update: definition.timestamp).tap do |questionnaire| + Entities::Questionnaire.new(definition.key).tap do |questionnaire| builder = QuestionnaireBuilder.new(questionnaire, lookup_tables: definition.lookup_tables) builder.instance_eval(definition.sourcecode, definition.path) if definition.sourcecode questionnaire.callback_after_dsl_enhance_on_questions end end - def self.build(key, sourcecode = nil, path: nil, timestamp: nil, lookup_tables: {}, &block) - Entities::Questionnaire.new(key, last_update: timestamp).tap do |questionnaire| + def self.build(key, sourcecode = nil, path: nil, lookup_tables: {}, &block) + Entities::Questionnaire.new(key).tap do |questionnaire| builder = QuestionnaireBuilder.new(questionnaire, lookup_tables: lookup_tables) builder.instance_eval(sourcecode, path || key) if sourcecode builder.instance_eval(&block) if block diff --git a/lib/quby/compiler/entities/questionnaire.rb b/lib/quby/compiler/entities/questionnaire.rb index 5a96efc1ec853d7c71c04e0a5aae98fafea01269..586c3ded966c01a44e43efc2807ad8fb483f7366 100755 --- a/lib/quby/compiler/entities/questionnaire.rb +++ b/lib/quby/compiler/entities/questionnaire.rb @@ -29,10 +29,9 @@ module Quby RESPONDENT_TYPES = %i( profess patient parent second_parent teacher caregiver ) - def initialize(key, last_update: Time.now) + def initialize(key) @key = key @sbg_domains = [] - @last_update = Time.at(last_update.to_i) @score_calculations = {}.with_indifferent_access @charts = Charting::Charts.new @fields = Fields.new(self) @@ -92,7 +91,6 @@ module Quby attr_accessor :last_author attr_accessor :allow_hotkeys # allow hotkeys for :all views, just :bulk views (default), or :none for never - attr_accessor :last_update attr_accessor :charts diff --git a/lib/quby/compiler/instance.rb b/lib/quby/compiler/instance.rb index 86cdae6a3c9275298d274b66e0e72783d9b27386..746da0b0b70a279c264d54b5bd714e7570033283 100644 --- a/lib/quby/compiler/instance.rb +++ b/lib/quby/compiler/instance.rb @@ -7,12 +7,12 @@ module Quby @lookup_tables = lookup_tables end - def compile(key:, sourcecode:, path: nil, last_update: nil, &block) + def compile(key:, sourcecode:, path: nil, &block) if block # defined in block for tests questionnaire = DSL.build(key, path: path, &block) else # sourcecode given as string tempfile = Tempfile.new([key, '.rb']) - questionnaire = Entities::Questionnaire.new(key, last_update: last_update) + questionnaire = Entities::Questionnaire.new(key) Thread.current["quby-questionnaire-loading"] = Quby::Compiler::DSL::QuestionnaireBuilder.new(questionnaire, lookup_tables: lookup_tables) tempfile.puts "Thread.current['quby-questionnaire-loading'].instance_eval do" @@ -36,7 +36,7 @@ module Quby roqua: Output.new( key: :roqua, filename: "roqua.json", - content: Outputs::RoquaSerializer.new(questionnaire).to_json, + content: JSON.pretty_generate(Outputs::RoquaSerializer.new(questionnaire).as_json) ), seeds: Output.new( key: :seeds, @@ -46,7 +46,7 @@ module Quby quby_frontend_v1: Output.new( key: :quby_frontend_v1, filename: "quby-frontend-v1.json", - content: Outputs::QubyFrontendV1Serializer.new(questionnaire).to_json, + content: JSON.pretty_generate(Outputs::QubyFrontendV1Serializer.new(questionnaire).as_json), ), quby_frontend_v2: Output.new( key: :quby_frontend_v2, diff --git a/lib/quby/compiler/outputs/quby_frontend_v1_serializer.rb b/lib/quby/compiler/outputs/quby_frontend_v1_serializer.rb index 44560f8f53d912f95fae7df1281b2b394039db8f..7bd406b03185899178fe57becc90ccc942bf041a 100644 --- a/lib/quby/compiler/outputs/quby_frontend_v1_serializer.rb +++ b/lib/quby/compiler/outputs/quby_frontend_v1_serializer.rb @@ -322,7 +322,6 @@ module Quby licensor: questionnaire.licensor, language: questionnaire.language, renderer_version: questionnaire.renderer_version, - last_update: questionnaire.last_update, last_author: questionnaire.last_author, extra_css: questionnaire.extra_css, allow_switch_to_bulk: questionnaire.allow_switch_to_bulk,