Skip to content

Instantly share code, notes, and snippets.

View jeremyf's full-sized avatar

Jeremy Friesen jeremyf

View GitHub Profile
module ApplicationHelper
def curation_concern_collection_path(asset)
collection_path(asset)
end
end
@jeremyf
jeremyf / ezid_spec.rb
Created September 25, 2013 18:12
proposed-configuration-for-ezid
Hydra::Ezid.configure do
register(DescendantOfActiveFedora) do |config|
store_doi at: :descMetadata
store_ark at: :properties, in: :some_ark
find_creator at: :descMetadata, in: :author
find_title at: :properties
find_publisher at: :properties
find_publication_year at: :descMetadata, in: :pubYear
end
end
@jeremyf
jeremyf / generic_work.rb
Created October 14, 2013 14:04
An expanded Curate object. Or how I want to begin breaking out functionality.
class GenericWork < ActiveFedora::Base
begin # include CurationConcern::Model
def self.human_readable_type
name.demodulize.titleize
end
begin # include Sufia::ModelMethods
begin # include Hydra::ModelMethods
class Work < ActiveFedora::Base
  has_metadata "descMetadata", type: ArticleMetadataDatastream

  section :required_information, label: "Required Information" do |section|
    section.attribute :title, datastream: :descMetadata, required: true
  end

  section :secondary_information, label: "Secondary Information" do |section|
    section.attribute :contributor, datastream: :descMetadata
@jeremyf
jeremyf / spec_helper.rb
Created October 28, 2013 14:41
Turning InMemory tests off and on again.
RSpec.configure do |config|
config.before(:each) do
require 'active_fedora/in_memory'
ActiveFedora::InMemory.cleanup!
end
config.before(:suite) do
require 'active_fedora/in_memory'
ActiveFedora::InMemory.begin!
end
@jeremyf
jeremyf / cleanup-history.sh
Created October 28, 2013 14:46
Script to cleanup curate's history
#!/usr/bin/env sh
git filter-branch --force --index-filter 'git rm --cached --ignore-unmatch spec/dummy/spec/master.zip' --prune-empty --tag-name-filter cat -- --all
git filter-branch --force --index-filter 'git rm --cached --ignore-unmatch spec/dummy/spec/curate-without-xacml-alterations.zip' --prune-empty --tag-name-filter cat -- --all
git filter-branch --force --index-filter 'git rm --cached --ignore-unmatch jetty' --prune-empty --tag-name-filter cat -- --all
git filter-branch --force --index-filter 'git rm --cached --ignore-unmatch spec/dummy/spec/jetty' --prune-empty --tag-name-filter cat -- --all
rm -rf .git/refs/original/
git reflog expire --expire=now --all
git gc --prune=now
@jeremyf
jeremyf / .bash_alias
Created October 30, 2013 20:15
Kill all the Jetty's
alias kill-jetty='ps ax | grep jetty | grep -v grep | sed "s/^ *//g" | cut -f1 -d " " | xargs kill -9'
@jeremyf
jeremyf / gource_committers.bash
Created November 1, 2013 18:35
gource-committers.bash
git_joined_committers_caption() {
authors=`git log --no-merges --format='%aN' | sort -u`
OLD_IFS=$IFS
IFS=$(echo -en "\n\b")
author_list=""
for author in $authors; do
author_first_commit=`git log --author="${author}" --pretty=format:%H|tail -1`
author_list+="$(git log -1 --format='%ct|%an started comitting' $author_first_commit)\n"
done
IFS=$OLD_IFS
@jeremyf
jeremyf / rdf-conversion-notes.txt
Created November 4, 2013 17:30
RDF 1.0.9 to RDF 1.0.10
I've begun the process of migrating some of our content in Curate. I have encountered an ever pleasant character encoding error (see Best way to lose a day of productivity). The issue, I believe is that prior to RDF 1.0.10 character encoding was less strictly acted on. With 1.0.10, encoding is being more strictly applied. Long story short, I've submitted a pull request for fixing this in the RDF gem.
https://github.com/ruby-rdf/rdf/pull/133
Ultimately the character encoding of RDF 1.0.10 is a good thing, because I noticed we were persisting the following (bold added for calling out the confusing text):
<info:fedora/und:cv43nv93h01> <http://purl.org/dc/terms/title> \"Procreation Metaphors in S\xC3\xA9an \xC3\x93 R\xC3\xADord\xC3\xA1in's Poetry\" ."
When what I really wanted was:
@jeremyf
jeremyf / person-migrator.rb
Created November 5, 2013 16:36
Migration script for content
# rails runner script/migrations/person-migrator.rb
module Migrator
module_function
def call
@successes = []
@silent_failures = []
@failures = []
ActiveFedora::Base.send(:connections).each do |connection|
connection.search('pid~und:*').each do |rubydora_object|