From be806f197425b95b47b622a5b54748e1922c3391 Mon Sep 17 00:00:00 2001 From: jaron Date: Fri, 24 Aug 2007 17:12:41 +0000 Subject: [PATCH] start and end scripts run automatically To make scripting more DRY there is a start script that runs before the chosen script and an end script that runs afterwards. Both start and end are optional but if present they will be run. git-svn-id: svn+ssh://rubyforge.org/var/svn/zcc/trunk@311 695555e7-a3f4-42c9-822d-1d0ed3746087 --- bin/zcc | 16 ++++++++++------ examples/zcc.yaml | 44 +++++++++++++++++++------------------------- 2 files changed, 29 insertions(+), 31 deletions(-) diff --git a/bin/zcc b/bin/zcc index 04fe0bd..d5f15c9 100644 --- a/bin/zcc +++ b/bin/zcc @@ -166,11 +166,13 @@ loop { scripting_menu.prompt = "Enter which script you would like to run on this record: " scripting_menu.select_by = :index_or_name scripting.each do |key, value| - scripting_menu.choice(key, "no help, ha!") do |cmd, d| - if cmd == :help - next - else - return scripting[cmd] + unless key == 'start' || key == 'end' + scripting_menu.choice(key, "no help, ha!") do |cmd, d| + if cmd == :help + next + else + return scripting[cmd] + end end end end @@ -189,7 +191,9 @@ loop { picked_scripting = which_script scripting display_record(final_taken) say("SCRIPTING...".bold.white.on_black) - final_taken.local_script(picked_scripting) + final_taken.local_script(scripting["start"]) if scripting["start"] + final_taken.local_script(picked_scripting) + final_taken.local_script(scripting["end"]) if scripting["end"] end if EDITING diff --git a/examples/zcc.yaml b/examples/zcc.yaml index 39521ce..769bbc6 100644 --- a/examples/zcc.yaml +++ b/examples/zcc.yaml @@ -85,7 +85,7 @@ zservers: ####################################################### # CSV files # Follows is the template for creating csv files. -# Saving information to a csv file might be useful for print labels in +# Saving information to a csv file might be useful for printing labels in # a program like glabels or for statistics. ####################################################### labels: @@ -104,23 +104,23 @@ labels: # Scripting # Scripting allows you to change the record before saving it. # Below is where you make changes to the scripting -# that will be run on each record. This feature is -# turned on in the main script with the value of the -# constant SCRIPTING at the head of the file. +# that will be run on each record. Scripts under 'start' will +# be run before every script. Scripts under 'end' will +# be run after chosen script is run. So for instance if you process +# the record with the 'non_fiction' script the following scripts +# will be run in order: start, non_fiction, end. +# Start and end of optional. ################################################# scripting: - non_fiction: + start: - [remove, 9XX] - [create-field, 942, " ", " "] #create new field with empty indicators - [create-field, 952, " ", " "] - [append-subfield, 952, 2, DLC] - [append-subfield, 952, b, MRML] - [append-subfield, 942, c, BOOK] - - [append-subfield, 942, k, proc get_dewey] # "proc name" is the way to get - # the script to evaluate a block - # of code. See below. comment out for BIO - - [append-subfield, 942, j, proc get_decimal] #comment out for BIO - - [append-subfield, 942, l, proc get_cutter] #comment out for BIO + + end: - [append-subfield, 952, k, proc get_combined_callnum] - [prompt, 942, x, IS THERE A CIP] - [append-subfield, 942, y, proc get_cip_callnum] @@ -129,25 +129,19 @@ scripting: - [prompt, 952, x, INTERNAL NOTE] - [proc barcode_and_itemnum] # [sort-tags] #This currently doesn't work. + + non_fiction: + - [append-subfield, 942, k, proc get_dewey] # "proc name" is the way to get + # the script to evaluate a block + # of code. See below. comment out for BIO + - [append-subfield, 942, j, proc get_decimal] #comment out for BIO + - [append-subfield, 942, l, proc get_cutter] #comment out for BIO + biography: - - [remove, 9XX] - - [create-field, 942, " ", " "] #create new field with empty indicators - - [create-field, 952, " ", " "] - - [append-subfield, 952, 2, DLC] - - [append-subfield, 952, b, MRML] - [append-subfield, 952, c, BIO] # BIO, Fic - - [append-subfield, 942, c, BOOK] - [append-subfield, 942, l, proc prompt_cutter] #BIO - - [append-subfield, 952, k, proc get_combined_callnum] - - [prompt, 942, x, IS THERE A CIP] - - [append-subfield, 942, y, proc get_cip_callnum] - - [prompt, 942, z, OLD CALL NUMBER] - - [prompt, 952, z, PUBLIC NOTE FOR ITEM] - - [prompt, 952, x, INTERNAL NOTE] - - [proc barcode_and_itemnum] - - + #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! # This is where the procs go for added scripting power. -- 2.11.4.GIT