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
# part of the BL core lib... | |
module Blacklight | |
module SolrDoc | |
def self.decorators | |
@decorators ||= {} | |
end | |
def self.decorate(name = :default, &blk) |
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 for breaking up XML docs | |
# into multiple chunks by a given node type. | |
# For example, in TEI the "pb" tag exists to signify page breaks... | |
# Using this code, you could break up the doc into multiple documents | |
# based on the position/depth of the individual "pb" tags. | |
require 'rubygems' | |
require 'nokogiri' | |
def next_node(start, e=[], &b) |
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
# number helper for limiting a number within a given range | |
class Fixnum | |
def limit(range) | |
return range.min if self < range.min | |
return range.max if self > range.max | |
self | |
end | |
end | |
puts true == (1 == -1998.limit(1..100)) |
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
# set default params here for each of the SolrDocument methods (search, find_document, opensearch etc..) | |
SolrDocument.default_params[:search] = {:qt=>:search} | |
class MyController < ApplicationController | |
include Controller::Solrizable | |
# call the #search method on SolrDocument when the #index action is executed | |
# this also creates the #index action as well as some other helpers. | |
# controller.solr_index_params is automatically created and exposed as a view helper. |
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 module (for including into the core Ruby Hash class) which performs deep merging, | |
# but only replaces a value if the replacement value is not nil. | |
# Operates on object references: friendly_deep_merge!, or copies: friendly_deep_merge | |
# Also does reverse merging; a hash can be updated only if its own values aren't nil. | |
module FriendlyDeepMerge | |
def friendly_deep_merge(hash) | |
target = dup | |
hash.keys.each do |key| | |
if hash[key].is_a? Hash and self[key].is_a? Hash |
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/ruby | |
require "socket" | |
require "etc" | |
MySocket = "/tmp/drb.madcap" | |
class String | |
#randomly set case of each letter | |
def madcap |
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 for breaking up XML docs | |
# into multiple chunks by a given node type. | |
# For example, in TEI the "pb" tag exists to signify page breaks... | |
# Using this code, you could break up the doc into multiple documents | |
# based on the position/depth of the individual "pb" tags. | |
# | |
# Think of this as an xml splitter, like String#split | |
# | |
require 'rubygems' |
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 for breaking up XML docs | |
# into multiple chunks by a given node type. | |
# For example, in TEI the "pb" tag exists to signify page breaks... | |
# Using this code, you could break up the doc into multiple documents | |
# based on the position/depth of the individual "pb" tags. | |
# | |
# Think of this as an xml splitter, like String#split | |
# | |
require 'rubygems' |
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
# source objects | |
[ | |
{:id=>1, :path=>'a::poems::one::1'}, | |
{:id=>2, :path=>'a::poems::one::2'}, | |
{:id=>3, :path=>'a::poems::one::3'}, | |
{:id=>4, :path=>'a::poems::one::4'}, | |
{:id=>5, :path=>'a::poems::two::1'}, | |
{:id=>6, :path=>'a::poems::two::2'}, | |
{:id=>7, :path=>'a::poems::two::3'}, | |
{:id=>8, :path=>'a::poems::two::4'} |
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
# Be sure to restart your server when you modify this file | |
# Specifies gem version of Rails to use when vendor/rails is not present | |
RAILS_GEM_VERSION = '2.3.2' unless defined? RAILS_GEM_VERSION | |
# Bootstrap the Rails environment, frameworks, and default configuration | |
require File.join(File.dirname(__FILE__), 'boot') | |
require File.join(File.dirname(__FILE__), '../vendor/plugins/engines/boot') | |
Rails::Initializer.run do |config| |