This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is a theoretical means of writing a command line tool for pushing jobs | |
# into Resque. This is what we've explored. It allows us to keep our workers | |
# and other models in the same repository. | |
require 'resque' | |
# In the worker application, the SomeWorker class is defined and has methods for | |
# performing the work. This | |
class SomeWorker | |
def initialize(pid) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Is the ActiveRecord pattern the correct Pattern for Long Term preservation concerns | |
> Active Records are special forms of DTOs [Data Transfer Objects]. They are data structures with public variables; but they typically have navigational methods like *save* and *find*. Typically these Active Records are direct translations from database tables, or other data sources. | |
> | |
> Unfortunately we often find that developers try to treat these data structures as though they were objects by putting business rule methods in them. | |
> This is awkward because it creates a hybrid data structure and an object. | |
> | |
> The solution, of course, is to treat the Active Record as a data structure and to create separate objects that contain the business rules and that hide their internal data (which are probably just instance of the Active Record). | |
> | |
> -- Martin, Robert C. "Clean Code: A Handbook of Agile Software Craftsmanship (Robert C. Martin Series)" pp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby -wU | |
# Takes your paste buffer and outputs a markdown table with pretty spacing | |
content = `pbpaste`.strip | |
def columnize(line) | |
line.sub(/\A\s*\|?(.*)\|?\Z/, '\1').split("|") | |
end | |
lines = content.split("\n") | |
column_count = columnize(lines.first).size |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby -wU | |
content = `pbpaste`.strip | |
def columnize(line) | |
line.sub(/\A\|(.*)\|\s*\Z/, '\1').split("|") | |
end | |
lines = content.split("\n") | |
column_count = columnize(lines.first).size |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CurationConcern::GenericWorksController < CurationConcern::BaseController | |
before_filter :rip_out_viral_files, only: [:create, :update] | |
def rip_out_viral_files | |
files = attributes_for_actor(:files) | |
good_files = [] | |
viral_files = [] | |
files.each do |file| | |
if viral?(file) | |
viral_files << file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# a-gem/lib/hydra_permlink/spec_support.rb | |
require 'rspec' | |
shared_examples 'a permalinked object' do |options| | |
let(:model) { described_class.new } | |
included_services = options.fetch(:services) | |
if included_services.include?(:doi) | |
it 'should permalink to a DOI' | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def datastream_to_show | |
super | |
rescue Exception => e | |
if params[:datastream_id] == 'thumbnail' | |
redirect_to 'path/to/default thumbnail' | |
return false | |
else | |
raise e | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Feature: Do not create profile pages for new contributors when works are submitted | |
# https://jira.duraspace.org/browse/HYDRASIR-275 | |
Scenario Outline: Associate with contributor to a person | |
Given I am an authenticated user | |
And I am on the <action_name> work page | |
When I fill out the type ahead search for a contributor | |
And select a person | |
And submit a valid form |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubydora/repository' | |
require 'rubydora/rest_api_client' | |
require 'active_fedora/digital_object' | |
require 'active_fedora/base' | |
module Rubydora | |
class PerformedSoftDelete < RuntimeError | |
attr_reader :options | |
def initialize(method_name, pid, options) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe GroupMembershipForm do | |
let(:group) { Group.new } | |
let(:group_id) { 'abc:123'} | |
let(:person) { Person.new } | |
let(:member_id) { 'abc:456'} | |
let(:params) { | |
{ | |
# These are the parameters that are generated in the existing form. | |
"group_id" => group_id |