Skip to content

Instantly share code, notes, and snippets.

View bess's full-sized avatar

Bess Sadler bess

View GitHub Profile
#!/usr/bin/env ruby
#
# ./dscm-to-html.rb repository_url PID
#
require 'rubygems'
require 'nokogiri'
require 'open-uri'
require 'erb'
require 'active_support'
class EtdSubmitDatastream < ActiveFedora::NokogiriDatastream
set_terminology do |t|
t.root(:path=>"workflow") {
t.object_id(:path=>{:attribute=>"objectId"}, :label=>"Object ID")
}
# t.process would allow you to leave off
# the :path, but because we called it something
<add>
<doc>
<field name="id">druid:cf811xn0897</field>
<field name="register-object-status">completed</field>
<field name="submit-status">completed</field>
<field name="reader-approval-status">waiting</field>
<field name="registrar-approval-status">waiting</field>
<field name="start-accession-status">waiting</field>
<field name="register-object-attempts">1</field>
require 'rubygems'
require 'active-fedora'
require 'open-uri'
require File.expand_path(File.dirname(__FILE__) + '/boot')
class DeleteFedoraObjects
attr_reader :repository
attr_reader :workflow
attr_reader :registration_robot
# Brazil maps are losing their model type upon import. I think it is because some of the
# values contain square brackets. It is happening during the csv_attributes method
context "make a Hash of the CSV values attached to their headers" do
context "how things work now" do
let(:metadata_file) { "#{fixture_path}/csv/brazil.csv" }
let(:csv) { ::CSV.read(metadata_file) }
let(:header) { csv[0] }
let(:body) { csv[1] }
it "lines up the header and body fields consitently" do
attrs = Importer::CSV.csv_attributes(header, body)
@bess
bess / capybara cheat sheet
Created April 7, 2017 15:56 — forked from zhengjia/capybara cheat sheet
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
@bess
bess / explain_partials.rb
Created May 30, 2017 17:37 — forked from bmaddy/explain_partials.rb
An initializer to show what parts of your page come from what rails partials
# Start the app with EXPLAIN_PARTIALS=true to show locations of view partials
if Rails.env.development? and ENV['EXPLAIN_PARTIALS']
module ActionView
class PartialRenderer
def render_with_explanation(*args)
rendered = render_without_explanation(*args).to_s
# Note: We haven't figured out how to get a path when @template is nil.
start_explanation = "\n<!-- START PARTIAL #{@template.inspect} -->\n"
end_explanation = "\n<!-- END PARTIAL #{@template.inspect} -->\n"
start_explanation.html_safe + rendered + end_explanation.html_safe
require 'nokogiri'
require 'open-uri'
# Get a Nokogiri::HTML:Document for the page we're interested in...
doc = Nokogiri::HTML(open('http://www.google.com/search?q=tenderlove'))
# Do funky things with it using Nokogiri::XML::Node methods...
####
@bess
bess / backup_and_restore.md
Last active May 17, 2018 15:59
How to move data from one hyrax app to another

Steps required to restore data from etd.library.emory.edu to a clone of demo.curationexperts.com:

Start with a running Hyrax system (demo.curationexperts.com)

Restore fedora

On original fedora box:

  1. Zip up fedora-data directory:
  cd /opt/
  tar zcvf fedora-data.tar.gz fedora-data/
@bess
bess / legacy_embargoes.txt
Created July 9, 2018 17:52
Legacy ETDs with embargoes
emory:bpc0v
emory:7t8dc
emory:7v24q
emory:bq2dn
emory:pg1sx
emory:pkn0t
emory:92ht9
emory:br00v
emory:93bm1
emory:r9q8n