Class: Project
Overview
Contains Project data and methods
Instance Attribute Summary collapse
-
#default ⇒ Object
readonly
Returns the value of attribute default.
-
#param ⇒ Object
readonly
Returns the value of attribute param.
Instance Method Summary collapse
-
#get(key) ⇒ Object
Get value param.
-
#initialize ⇒ Project
constructor
Initialize.
-
#open ⇒ Object
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.
-
#reset ⇒ Object
Reset project params.
-
#set(key, value) ⇒ Object
Set value param.
Constructor Details
#initialize ⇒ Project
Initialize
15 16 17 |
# File 'lib/asker/project.rb', line 15 def initialize reset end |
Instance Attribute Details
#default ⇒ Object (readonly)
Returns the value of attribute default.
11 12 13 |
# File 'lib/asker/project.rb', line 11 def default @default end |
#param ⇒ Object (readonly)
Returns the value of attribute param.
11 12 13 |
# File 'lib/asker/project.rb', line 11 def param @param end |
Instance Method Details
#get(key) ⇒ Object
Get value param
31 32 33 34 35 |
# File 'lib/asker/project.rb', line 31 def get(key) return @param[key] unless @param[key].nil? @default[key] end |
#open ⇒ Object
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
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/asker/project.rb', line 54 def open config = Application.instance.config 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 = config['output']['folder'] @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) Logger.create(self) # Create log file where to save log messages Logger.verboseln '[INFO] Project open' Logger.verboseln ' ├── inputdirs = ' + Rainbow(get(:inputdirs)).bright Logger.verboseln ' └── process_file = ' + Rainbow(get(:process_file)).bright end |
#reset ⇒ Object
Reset project params
21 22 23 24 25 26 |
# File 'lib/asker/project.rb', line 21 def reset @default = { inputbasedir: FileUtils.pwd, stages: { d: true, b: true, f: true, i: true, s: true, t: true }, threshold: 0.5 } @param = {} end |
#set(key, value) ⇒ Object
Set value param
41 42 43 |
# File 'lib/asker/project.rb', line 41 def set(key, value) @param[key] = value end |