Sha256: 2972e1d5329411cacea6bcbcdbdd79aaa557c6e0ed8115d71ba0dc254480c0f4
Contents?: true
Size: 1.57 KB
Versions: 3
Compression:
Stored size: 1.57 KB
Contents
# frozen_string_literal: true require "singleton" class ProjectData include Singleton attr_reader :default, :param def initialize reset end def reset @default = {inputbasedir: FileUtils.pwd, stages: {d: true, b: true, f: true, i: true, s: true, t: true}, threshold: 0.5, outputdir: "output", weights: "1, 1, 1"} @param = {} end def get(key) return @param[key] unless @param[key].nil? @default[key] end def set(key, value) @param[key] = value end ## # Open new project # * setting new params and # * creating output files # IMPORTANT: We need at least these values # * process_file # * inputdirs def open ext = File.extname(@param[:process_file]) || ".haml" @param[:projectname] = @param[:projectname] || File.basename(@param[:process_file], ext) @param[:logname] = "#{@param[:projectname]}.log" @param[:outputname] = "#{@param[:projectname]}-gift.txt" @param[:lessonname] = "#{@param[:projectname]}.txt" @param[:yamlname] = "#{@param[:projectname]}-questions.yaml" @param[:moodlename] = "#{@param[:projectname]}-moodle.xml" outputdir = get(:outputdir) @param[:logpath] = File.join(outputdir, get(:logname)) @param[:outputpath] = File.join(outputdir, get(:outputname)) @param[:lessonpath] = File.join(outputdir, get(:lessonname)) @param[:yamlpath] = File.join(outputdir, get(:yamlname)) @param[:moodlepath] = File.join(outputdir, get(:moodlename)) Dir.mkdir(outputdir) unless Dir.exist?(outputdir) end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
asker-tool-2.7.2 | lib/asker/data/project_data.rb |
asker-tool-2.7.1 | lib/asker/data/project_data.rb |
asker-tool-2.7.0 | lib/asker/data/project_data.rb |