Skip to content

Instantly share code, notes, and snippets.

@jcoyne
Created December 21, 2011 20:05
Show Gist options
  • Save jcoyne/1507484 to your computer and use it in GitHub Desktop.
Save jcoyne/1507484 to your computer and use it in GitHub Desktop.
def self.note_template(opts={})
options = {:text => ""}.merge(opts)
builder = Nokogiri::XML::Builder.new do
note options[:text], :date=>Time.now.iso8601
end
return builder.doc.root
end
def insert_note(opts={})
node = self.class.note_template(opts)
nodeset = self.find_by_terms(:human_review,:field,:note)
unless nodeset.nil?
if nodeset.empty?
review_node = self.find_by_terms(:human_review,:field).first
raise "Couldn't find review node" unless review_node
review_node.add_child(node)
index=0
else
nodeset.after(node)
index=nodeset.length
end
self.dirty = true
end
return node, index
end
@jcoyne
Copy link
Author

jcoyne commented Jan 3, 2012

def self.xml_template
  Nokogiri::XML::Builder.new do
    workflow(:xmlns => 'http://schemas.mediashelf.us/narm/metadata_workflow/') {
      humanReview {
        field :name=>'title'
      }
    }
  end.doc
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment