Skip to content

Instantly share code, notes, and snippets.

View burtlo's full-sized avatar

Lynn Frank burtlo

View GitHub Profile
@burtlo
burtlo / city_builder.rb
Created October 19, 2010 00:46
Registering a parser with YARD
module Cucumber
module Parser
class CityBuilder
include Gherkin::Rubify
def initialize(file)
@file = file
end
@burtlo
burtlo / build.sh
Created October 29, 2010 18:30
Hudson Bash Shell Command: Execute a test on a remote system, save the results, return the results file, return the results
#!/bin/bash -x
rm -f spec_results.html
ssh $TEST_SYSTEM "bash --login -c \"cd ~/testsuite/ && rm -f test_results.html && svn up --accept theirs-full && rake spec env=${TEST_SYSTEM} \""
declare test_results=$?
scp $TEST_SYSTEM:/home/automateduser/testsuite/test_results.html $WORKSPACE
exit $test_results
@burtlo
burtlo / environment.rb
Created November 18, 2010 00:34
Environment with defaults, system overrides, and user overrides
require 'yaml'
require 'active_support'
WINDOWS_PLATFORM = /mswin|win32|mingw/ unless defined?(WINDOWS_PLATFORM)
$env = YAML.load_file("#{File.dirname(__FILE__)}/environment.yml")
DEFAULT_ENVIRONMENT = "#{RUBY_PLATFORM =~ WINDOWS_PLATFORM ? 'windows_' : ''}default"
$default_env = $env[DEFAULT_ENVIRONMENT]
@burtlo
burtlo / event_steps.rb
Created November 22, 2010 18:40
Nested Step Definitions
module EventsHelper
def create_events(events_table)
events_table.map_headers! {|header| header.is_a?(Symbol) ? header : header.gsub(/\s/,'_').to_sym }
system_time = TimeService.now
events_table.hashes.each do |event|
event[:name] ||= "Event #{system_time.strftime("%H:%M:%S")}"
event[:enabled] ||= true
event[:time] ||= system_time
@burtlo
burtlo / proxy_class_idea.rb
Created November 24, 2010 03:41
submodule_override.rb ===================== Given a base module that may be extended that defines a core set of methods for a core set of services. Allow for a nested service override the base service methods based on an environment variable.
require 'active_resource'
class User
DEFAULT_CONTEXT_USER = "Models::Database::User"
class << self
def method_missing(method,*args,&block)
contextual_user = "Models::#{ENV['context']}::User".constantize
@burtlo
burtlo / proxy.rb
Created December 8, 2010 10:48
Allows
$ ruby proxy.rb
Proxy Object
Customer.create
Proxy Object
Customer.create
Proxy Object
Customer.create
@burtlo
burtlo / gist:739210
Created December 13, 2010 16:46
Windows Shortcut to open the command prompt at particular directory
C:\Windows\System32\cmd.exe /k "cd c:\users\username\dropbox\git"
@burtlo
burtlo / super_set.rb
Created January 14, 2011 05:39
Return the value that matches the most restrictive set or just return the default value
require 'set'
class SuperSet
def initialize(default)
@default = default
@hash = Hash.new
end
def ask(terms)
@burtlo
burtlo / happymapper_composition.rb
Created March 6, 2011 08:48
Utilizing modules to reduce element declarations
require 'happymapper'
module Publication
def self.included(receiver)
receiver.element :featured, Boolean, :tag => 'isFeatured'
receiver.element :exclusive, Boolean, :tag => 'isExclusive'
receiver.element :sponsored, Boolean, :tag => 'isSponsored'
end
end
@burtlo
burtlo / yardoc.rb
Created April 25, 2011 07:01
yardoc issue 300 workaround
# Parses commandline arguments
# @param [Array<String>] args the list of arguments
# @return [Boolean] whether or not arguments are valid
# @since 0.5.6
def parse_arguments(*args)
options[:markup] = nil # reset markup
# Hack: parse out --no-yardopts, --no-document before parsing files
['document', 'yardopts'].each do |file|
without, with = args.index("--no-#{file}") || -2, args.index("--#{file}") || -1