class Reviser::Exec
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
@author Yann Prono
Constants
- VERSION
Public Class Methods
new(*args)
click to toggle source
Calls superclass method
# 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.expand_path('config.yml') setup config_file if File.exist? config_file end
Public Instance Methods
add(meth, label)
click to toggle source
# File lib/reviser/exec.rb, line 134 def add meth, label res = Helpers::Criteria::Labels.add meth, label message "#{res} label".green,meth + " => " + label end
clean()
click to toggle source
# 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 message("Error".red, "'config.yml' doesn't exist! Check if you are in the good directory.") end end
extract()
click to toggle source
# 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 message('Error'.red, "'config.yml' file doesn't exist! @see 'reviser init'") end end
init(dir = '.')
click to toggle source
# File lib/reviser/exec.rb, line 57 def init(dir = '.') # Import all files and directories init_workspace dir setup File.expand_path(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
init_workspace(dir)
click to toggle source
Initialize workspace copying all files et directories. @param dir Directory to init.
# File lib/reviser/exec.rb, line 159 def init_workspace dir FileUtils.mkdir dir unless File.directory? dir # First copy directories [Cfg::RES_DIR, Cfg::TYPE_DIR].each do |d| path = File.join(Cfg::ROOT, d) if File.directory? path unless File.directory? File.join(dir, d) FileUtils.cp_r path, dir message('Create', dir == '.' && d || File.join(dir, d)) end end end # Then the config file ['config.yml', 'labels.yml'].each do |tpl| unless File.exists? File.join(dir, tpl) FileUtils.cp(File.join(Cfg::ROOT, tpl), dir) message('Create', dir == '.' && tpl || File.join(dir, tpl)) end end end
message(keyword, desc)
click to toggle source
A Formatter message for command line
# File lib/reviser/exec.rb, line 147 def message(keyword, desc) puts "\t#{keyword}\t\t#{desc}" end
setup(config_file)
click to toggle source
# File lib/reviser/exec.rb, line 151 def setup(config_file) Reviser::setup config_file @@setup = true end
version()
click to toggle source
# 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()
click to toggle source
# 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 message('Error'.red, "'config.yml' file doesn't exist! @see 'reviser init'") end end