Sha256: c64d88805649f008a74e3f70b79b03f7b43e03197c379f8903582cb87e70dfc0
Contents?: true
Size: 1.74 KB
Versions: 27
Compression:
Stored size: 1.74 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 # rubocop:disable Metrics/MethodLength # rubocop:disable Metrics/AbcSize def open ext = File.extname(@param[:process_file]) || '.haml' @param[:projectname] = @param[:projectname] || File.basename(@param[:process_file], ext) @param[:logname] = "#{@param[:projectname]}-log.txt" @param[:outputname] = "#{@param[:projectname]}-gift.txt" @param[:lessonname] = "#{@param[:projectname]}-doc.txt" @param[:yamlname] = "#{@param[:projectname]}.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 # rubocop:enable Metrics/MethodLength # rubocop:enable Metrics/AbcSize end
Version data entries
27 entries across 27 versions & 1 rubygems