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
-
#close ⇒ Object
Close output files.
-
#get(key) ⇒ Object
Get value param.
-
#initialize ⇒ Project
constructor
Initialize.
- #method_missing(method, *_args, &_block) ⇒ Object
-
#open ⇒ Object
Open new project * setting new params and * creating output files IMPORTANT: We need at least theses values * process_file * inputdirs.
-
#reset ⇒ Object
Reset project params.
-
#set(key, value) ⇒ Object
Set value param.
Constructor Details
#initialize ⇒ Project
Initialize
16 17 18 |
# File 'lib/asker/project.rb', line 16 def initialize reset end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *_args, &_block) ⇒ Object
90 91 92 |
# File 'lib/asker/project.rb', line 90 def method_missing(method, *_args, &_block) get(method) end |
Instance Attribute Details
#default ⇒ Object (readonly)
Returns the value of attribute default.
12 13 14 |
# File 'lib/asker/project.rb', line 12 def default @default end |
#param ⇒ Object (readonly)
Returns the value of attribute param.
12 13 14 |
# File 'lib/asker/project.rb', line 12 def param @param end |
Instance Method Details
#close ⇒ Object
Close output files
83 84 85 86 87 88 |
# File 'lib/asker/project.rb', line 83 def close get(:logfile).close get(:outputfile).close get(:lessonfile).close get(:yamlfile).close end |
#get(key) ⇒ Object
Get value param
32 33 34 35 36 |
# File 'lib/asker/project.rb', line 32 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 theses values
-
process_file
-
inputdirs
53 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 79 |
# File 'lib/asker/project.rb', line 53 def open config = Application.instance.config ext = File.extname(@param[:process_file]) || '.haml' #@param[:process_file] = @param[:process_file] || # get(:projectdir).split(File::SEPARATOR).last + ext @param[:projectname] = @param[:projectname] || File.basename(@param[:process_file], ext) #@param[:inputdirs] = @param[:inputdirs] || # File.join(get(:inputbasedir), @param[:projectdir]) @param[:logname] = "#{@param[:projectname]}-log.txt" @param[:outputname] = "#{@param[:projectname]}-gift.txt" @param[:lessonname] = "#{@param[:projectname]}-doc.txt" @param[:yamlname] = "#{@param[:projectname]}.yaml" outputdir = config['global']['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)) Dir.mkdir(outputdir) unless Dir.exist?(outputdir) create_log_file create_output_file create_lesson_file create_yaml_file end |
#reset ⇒ Object
Reset project params
22 23 24 25 26 27 |
# File 'lib/asker/project.rb', line 22 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
42 43 44 |
# File 'lib/asker/project.rb', line 42 def set(key, value) @param[key] = value end |