Class: Reviser::Exec
- Inherits:
-
Thor
- Object
- Thor
- Reviser::Exec
- Defined in:
- lib/reviser/exec.rb
Overview
Class used for managing all actions in command line This class enables the user to interact with the programm in command line. It use the powerful toolkit Thor for building command line interfaces
Constant Summary collapse
- VERSION =
'0.0.4.2'
- @@setup =
false
Instance Method Summary collapse
- #add(meth, label) ⇒ Object
- #clean ⇒ Object
- #extract ⇒ Object
- #init(dir = '.') ⇒ Object
-
#initialize(*args) ⇒ Exec
constructor
A new instance of Exec.
- #version ⇒ Object
- #work ⇒ Object
Constructor Details
#initialize(*args) ⇒ Exec
Returns a new instance of Exec.
46 47 48 49 50 51 52 |
# File 'lib/reviser/exec.rb', line 46 def initialize(*args) super # If config.yml already exists in the working # directory, then we setup reviser here config_file = File.('config.yml') setup config_file if File.exist? config_file end |
Instance Method Details
#add(meth, label) ⇒ Object
134 135 136 137 |
# File 'lib/reviser/exec.rb', line 134 def add meth, label res = Helpers::Criteria::Labels.add meth, label "#{res} label".green,meth + " => " + label end |
#clean ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/reviser/exec.rb', line 70 def clean if File.exist? 'config.yml' FileUtils.rm_rf(Cfg[:dest], :verbose => true) if Cfg.has_key?(:options) && Cfg[:options].has_key?(:log_dir) FileUtils.rm_rf(Cfg[:options][:log_dir], :verbose => true) else FileUtils.rm_f(Dir['*.txt'], :verbose => true) end if Cfg[:out_format].respond_to? 'each' Cfg[:out_format].each { |format| FileUtils.rm_f(Dir["*.#{format}"], :verbose => true) } else FileUtils.rm_f(Dir["*.#{Cfg[:out_format]}"], :verbose => true) end # We shall not delete it because the user is likely to # add his own files and doesn't want to lose them every # single time #FileUtils.rm_rf(Cfg[:res_dir], :verbose => true) else ("Error".red, "'config.yml' doesn't exist! Check if you are in the good directory.") end end |
#extract ⇒ Object
113 114 115 116 117 118 119 120 121 122 |
# File 'lib/reviser/exec.rb', line 113 def extract if File.exists? 'config.yml' Reviser::load :component => 'archiver' Reviser::load :component => 'organiser', :input_from => 'archiver' Reviser::run else ('Error'.red, "'config.yml' file doesn't exist! @see 'reviser init'") end end |
#init(dir = '.') ⇒ Object
57 58 59 60 61 62 63 64 65 |
# File 'lib/reviser/exec.rb', line 57 def init(dir = '.') # Import all files and directories init_workspace dir setup File.(File.join(dir, 'config.yml')) unless @@setup puts "Customize config.yml to your needs @see docs".yellow puts 'Then simply execute \'reviser work\' to launch analysis.'.yellow end |
#version ⇒ Object
140 141 142 |
# File 'lib/reviser/exec.rb', line 140 def version puts "Reviser".yellow + " " + "#{VERSION}".light_red + " Copyright (C) 2015 Renan Strauss, Yann Prono, Anthony Cerf, Romain Ruez" end |
#work ⇒ Object
99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/reviser/exec.rb', line 99 def work if File.exists? 'config.yml' Reviser::load :component => 'archiver' Reviser::load :component => 'organiser', :input_from => 'archiver' Reviser::load :component => 'checker', :input_from => 'organiser' Reviser::load :component => 'generator', :input_from => 'checker' Reviser::run else ('Error'.red, "'config.yml' file doesn't exist! @see 'reviser init'") end end |