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
case "$COMP_WORDBREAKS" in | |
*:*) : great ;; | |
*) COMP_WORDBREAKS="$COMP_WORDBREAKS:" | |
esac | |
__rakefile_path() { | |
( | |
while [ "$PWD" != / ]; do | |
if [ -f "Rakefile" ]; then |
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
unless Rails.env.production? | |
# Inspired by http://github.com/fcheung/tattler/blob/master/lib/tattler.rb | |
# | |
class ActionView::Template | |
def render_with_comment(*args, &block) | |
render_result = render_without_comment(*args, &block) | |
if mime_type.nil? || mime_type.in?([Mime::HTML, Mime::XML]) | |
[ | |
"<!-- STARTTEMPLATE: #{identifier} -->", | |
render_result, |
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/ruby1.9.1 | |
require 'find' | |
require 'set' | |
module Tools | |
class ViewStructure | |
include Enumerable | |
EXTENSIONS = '.erb' |
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
if Rails.env.development? || Rails.env.test? | |
module ConsoleTools | |
EDITOR = ENV['CONSOLE_TOOLS_EDITOR'] || 'kwrite' | |
BROWSER = ENV['CONSOLE_TOOLS_BROWSER'] || 'firefox -new-window' | |
def edit_object(obj = @response) | |
# TODO add support for XML nodes | |
case obj | |
#when ActiveRecord::Base |
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 Rake::Task | |
# Forget an already defined task. | |
# | |
# Rake tasks with the same name are cumulative, | |
# a new definition adds to an already existing one, | |
# it does not override it. | |
# In order to completely redefine a task, this | |
# method makes rake forget the previous definition(s). | |
# | |
def forget |
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 Hash | |
# Safely access an element in a nested hash by its path. | |
# If any of the intervening hashes is not present, nil is returned. | |
def at(*path) | |
val = self | |
path.each do |k| | |
val = val[k] | |
return nil unless val | |
end | |
val |
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
# Monkey-patch another helper into Sprockets that expands small files | |
# into data URIs. | |
module Sprockets | |
class Context | |
def asset_uri(path) | |
fullpath = environment.find_asset(path) | |
if fullpath && File.file?(fullpath) && File.size(fullpath) < 2048 | |
asset_data_uri(path) | |
else | |
path |
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 bash | |
# Place this file at ~/.rvm/hooks/after_use_switch_gemfiles | |
# and make it executable. | |
# | |
# This version copies Ruby-specific Gemfile.lock.x to Gemfile.lock. | |
if [ -e "Gemfile" ]; then | |
. "${rvm_path}/scripts/functions/hooks/jruby" | |
unset current_platform gemfile_platform |
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
_cheat() | |
{ | |
local sheets | |
list="$HOME/.cheat/.sheets" | |
if [ ! -f "$list" ]; then | |
cheat sheets | sed -n 's/^ \(.*\)$/\1/p' > "$list" | |
fi | |
sheets=$(cat "$list") |
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
__cucumbercomp() { | |
local cur="${COMP_WORDS[COMP_CWORD]}" | |
COMPREPLY=( $( compgen -W "$1" -- "$cur" ) ) | |
} | |
__cucumbertags() { | |
sed -r -n 's/^\s*(((@[[:alnum:]]+)\s?)+).*$/\1/p' features/**/*.feature \ | |
| sed -r 's/\s+/\n/' | |
} |
OlderNewer