ewoga/bin/ewoga-test

81 lines
1.5 KiB
Text
Raw Permalink Normal View History

2016-06-16 23:32:08 +00:00
#!/usr/bin/env ruby
require 'pathname'
require 'fileutils'
require 'colorize'
ROOTDIR=Pathname.new(__FILE__).dirname.parent.realpath.to_s
2016-08-08 09:43:59 +00:00
DATADIR=(Pathname.new(ROOTDIR) + 'NEXTFORMATION-ROR').to_s
2016-06-16 23:32:08 +00:00
# puts "ROOTDIR = #{ROOTDIR}"
# puts "DATA = #{DATADIR}"
$INDENT = 2
def indent
" " * $INDENT
end
class Project
def initialize path
@path = path
@name = File.basename path
@score = 0
@score_max = 0
@errors = 0
2016-06-16 23:32:08 +00:00
end
class ExtractionError < Exception ; end
def extract
Dir.chdir(@path)
tarfile = Dir.glob('projet-*.tar').sort.last
# tarfile = @path + '/projet.tar'
print indent + "Extracting project data from #{tarfile}... "
2016-06-16 23:32:08 +00:00
system "tar xavf #{tarfile} > extractlog"
raise ExtractionError unless $?.success?
puts "success".green
dir = %x{head -n1 extractlog}.strip
2016-08-08 09:43:59 +00:00
if dir != 'datingapp/' then
FileUtils.rm_rf 'datingapp'
FileUtils.mv dir, 'datingapp'
2016-06-16 23:32:08 +00:00
end
FileUtils.rm 'extractlog'
puts ""
FileUtils.rm_f ENV['HOME'] + '/.taskman.yml'
FileUtils.rm_f ENV['HOME'] + '/.taskman'
2016-06-16 23:32:08 +00:00
end
private
def bundle_prefix
prefix = ''
prefix = 'bundle exec ' if File.exist? 'Gemfile'
prefix
end
end
projects = []
if ARGV.empty? then
projects = Dir.glob(DATADIR + '/*')
else
projects = ARGV
end
out = File.open('result.csv','w+')
2016-06-16 23:32:08 +00:00
projects.each do |name|
projectpath = Pathname.new(name).realpath.to_s
puts "[#{File.basename(projectpath).yellow.on_blue}] #{projectpath}"
project = Project.new(projectpath)
project.extract
puts ""
end
out.close
2016-06-16 23:32:08 +00:00
exit 0