Skip to content

Commit

Permalink
More logging and exit 2 unless substances and limitations okay for ex…
Browse files Browse the repository at this point in the history
…tended
  • Loading branch information
ngiger committed Apr 24, 2014
1 parent 149d35d commit 40bfe38
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Rakefile
Expand Up @@ -15,6 +15,8 @@ task :gem => :build do
Rake::Task[:build].invoke
end

task :spec => :clean

desc 'Run oddb2xml with all commonly used combinations'
task :test => [:clean, :spec, :gem] do
system("./test_options.rb 2>&1 | tee test_options.log")
Expand Down
8 changes: 7 additions & 1 deletion lib/oddb2xml/builder.rb
Expand Up @@ -153,6 +153,7 @@ def prepare_articles(reset=false)
end
def prepare_substances
unless @substances
Oddb2xml.log("prepare_substances from #{@items.size} items")
@substances = []
@items.values.uniq.each do |seq|
next unless seq[:substances]
Expand All @@ -162,10 +163,13 @@ def prepare_substances
end
@substances.uniq!
@substances.sort!
Oddb2xml.log("prepare_substances done. Total #{@substances.size} from #{@items.size} items")
exit 2 if @options[:extended] and @substances.size == 0
end
end
def prepare_limitations
unless @limitations
Oddb2xml.log("prepare_limitations from #{@items.size} items")
limitations = []
@items.values.uniq.each do |seq|
next unless seq[:packages]
Expand All @@ -177,6 +181,7 @@ def prepare_limitations
# limitation.xml needs all duplicate entries by this keys.
limitations.uniq! {|lim| lim[:id] + lim[:code] + lim[:type] }
@limitations = limitations.sort_by {|lim| lim[:code] }
Oddb2xml.log("prepare_limitations done. Total #{@limitations.size} from #{@items.size} items")
end
end
def prepare_interactions
Expand Down Expand Up @@ -259,6 +264,7 @@ def build_substance
'VALID_DATE' => datetime
) {
Oddb2xml.log "build_substance #{@substances.size} substances"
exit 2 if @options[:extended] and @substances.size == 0
@substances.each_with_index do |sub_name, i|
xml.SB('DT' => '') {
xml.SUBNO((i + 1).to_i)
Expand Down Expand Up @@ -292,7 +298,7 @@ def build_limitation
'PROD_DATE' => datetime,
'VALID_DATE' => datetime
) {
@limitations.each do |lim|
@limitations.each do |lim|
xml.LIM('DT' => '') {
case lim[:key]
when :swissmedic_number8
Expand Down

0 comments on commit 40bfe38

Please sign in to comment.