Skip to content

Commit

Permalink
rescue required begin
Browse files Browse the repository at this point in the history
  • Loading branch information
lsat12357 committed Jan 29, 2020
1 parent ce44368 commit c058aba
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions lib/tasks/create_profiles.rake
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,24 @@ DASH = "- "

desc 'Create asset profile yml file'
task create_profile: :environment do
export_path = ENV['export_path']
pids = ENV['pids']
pids.each do |pid|
f = File.open("#{export_path}/#{cleanpid(pid)}_profile.yml", 'w')
item = GenericAsset.find(pid)
f.puts "sets:"
f.print assemble_sets(item.descMetadata.set)
f.print assemble_primary(item.descMetadata.primarySet)
f.puts "fields:"
fields(item).each do |field|
vals = item.descMetadata.send(field)
next if vals.blank?
f.print assemble_field(field, vals)
begin
export_path = ENV['export_path']
pids = ENV['pids']
pids.each do |pid|
f = File.open("#{export_path}/#{cleanpid(pid)}_profile.yml", 'w')
item = GenericAsset.find(pid)
f.puts "sets:"
f.print assemble_sets(item.descMetadata.set)
f.print assemble_primary(item.descMetadata.primarySet)
f.puts "fields:"
fields(item).each do |field|
vals = item.descMetadata.send(field)
next if vals.blank?

f.print assemble_field(field, vals)
end
f.close
end
f.close
rescue StandardError => e
puts e.message
end
Expand All @@ -39,7 +42,7 @@ end
def assemble_primary(primary_set)
str = "#{INDENT}primarySet: "
primary = primary_set.blank? ? "" : primary_set.first.pid
str += "#{primary}\n"
str + "#{primary}\n"
end

def assemble_field(field, vals)
Expand Down

0 comments on commit c058aba

Please sign in to comment.