Class: Reviser::Exec
- Inherits:
-
Thor
- Object
- Thor
- Reviser::Exec
- Defined in:
- lib/reviser/exec.rb
Constant Summary collapse
- VERSION =
'0.0.3.1'- @@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.
49 50 51 52 53 54 55 |
# File 'lib/reviser/exec.rb', line 49 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
149 150 151 152 |
# File 'lib/reviser/exec.rb', line 149 def add meth, label res = Helpers::Criteria::Labels.add meth, label "#{res} label".green,meth + " => " + label end |
#clean ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/reviser/exec.rb', line 73 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
124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/reviser/exec.rb', line 124 def extract begin Reviser::load :component => 'archiver' Reviser::load :component => 'organiser', :input_from => 'archiver' Reviser::run rescue Interrupt => i puts 'Bye bye' rescue Gem::LoadError => e ('Missing gem'.yellow, e.) rescue Exception => e ('Error'.red, e.) end end |
#init(dir = '.') ⇒ Object
60 61 62 63 64 65 66 67 68 |
# File 'lib/reviser/exec.rb', line 60 def init(dir = '.') # Import all files and directories init_workspace dir setup File.(File.join(dir, File.basename($template_path))) 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
155 156 157 |
# File 'lib/reviser/exec.rb', line 155 def version puts "Reviser".yellow + " " + "#{VERSION}".light_red + " Copyright (C) 2015 Renan Strauss, Yann Prono, Anthony Cerf, Romain Ruez" end |
#work ⇒ Object
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/reviser/exec.rb', line 102 def work if File.exists? 'config.yml' begin 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 rescue Interrupt => i puts 'Bye bye' rescue Gem::LoadError => e ('Missing gem'.light_red, e.) rescue Exception => e ('Error'.red, e.) end else ('Error'.red, "'config.yml' file doesn't exist! @see 'reviser init'") end end |