forked from zdavatz/oddb2xml
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
49 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/usr/bin/env ruby | ||
# Helper script to test all common usageas of oddb2xml | ||
# - runs rake install to install the gem | ||
# - Creates an output directory ausgabe/time_stamp | ||
# - runs all commands (and add ---skip-download) | ||
# - saveds output and data/download to ausgabe/time_stamp | ||
|
||
|
||
require 'fileutils' | ||
|
||
def test_one_call(cmd) | ||
dest = File.join(Ausgabe, cmd.gsub(/[ -]/, '_')) | ||
cmd.sub!('oddb2xml', 'oddb2xml --skip-download') | ||
files = (Dir.glob('%.xls*') + Dir.glob('*.dat*') + Dir.glob('*.xml')) | ||
FileUtils.rm(files, :verbose => true) | ||
puts "#{Time.now}: Running cmd #{cmd}" | ||
startTime = Time.now | ||
res = system(cmd) | ||
endTime = Time.now | ||
diffSeconds = (endTime - startTime).to_i | ||
duration = "#{Time.now}: Took #{sprintf('%3d', diffSeconds)} seconds for" | ||
puts "#{duration} success #{res} for #{cmd}" | ||
exit 2 unless res | ||
FileUtils.makedirs(dest) | ||
FileUtils.cp_r('data/download', dest, :preserve => true, :verbose => true) if Dir.glob(Ausgabe).size > 0 | ||
FileUtils.cp(Dir.glob('*.dat'), dest, :preserve => true, :verbose => true) if Dir.glob('*.dat').size > 0 | ||
FileUtils.cp(Dir.glob('*.xml'), dest, :preserve => true, :verbose => true) if Dir.glob('*.xml').size > 0 | ||
FileUtils.cp(Dir.glob('*.gz'), dest, :preserve => true, :verbose => true) if Dir.glob('*.gz').size > 0 | ||
end | ||
|
||
|
||
system("rake install") # build and install our gem first | ||
Ausgabe = File.join(Dir.pwd, 'ausgabe', Time.now.strftime('%Y.%m.%d-%H:%M')) | ||
FileUtils.makedirs(Ausgabe) | ||
test_one_call('oddb2xml -f dat', 'oddb.dat') | ||
test_one_call('oddb2xml -f xml', 'oddb.xml') | ||
test_one_call('oddb2xml -f dat -a nonpharma') | ||
test_one_call('oddb2xml -t md') | ||
test_one_call('oddb2xml -a nonpharma -t md -c tar.gz') | ||
test_one_call('oddb2xml -e') # take hours, therefor at the end |