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 function is trying to pass a grep pattern to Ag | |
" but it seems that the grepPattern is not well escaped | |
function! AgCurrentPartial() | |
let fileNameWithoutExtension = expand('%:t:r') | |
let fileNameWithoutUnderscore = substitute(fileNameWithoutExtension, '^_','','g') | |
let grepPattern = "render.*[\'\"].*" . fileNameWithoutUnderscore | |
echom renderInvocationGrepPattern | |
exec 'Ag "' . grepPattern . '"' | |
endfunction |
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
.sublayout | |
.this-is-a-partial | |
= yield # this will render the content inside the sublayout |
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 "something with a logger" do | |
let(:logger) { TestLogger.new } | |
before { Rails.logger = logger } | |
specify do | |
# ... call your code ... | |
logger.messages.should include("my message") | |
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
require 'roar/decorator' | |
# Ok..get ready for a fun one: | |
# | |
# We use Roar::Decorator to serialize into our search engine (ElasticSearch) | |
# Example: app/reverb/search/serializers/product.rb | |
# | |
# When we serialize fields that are false or nil (booleans), they are omitted | |
# from the json by default. | |
# |
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
Fixture.class_eval do | |
def find | |
if model_class | |
if model_class.respond_to?(:find_with_deleted) | |
model_class.find_with_deleted(self[model_class.primary_key]) | |
else | |
model_class.find(self[model_class.primary_key]) | |
end | |
else | |
raise FixtureClassNotFound, "No class attached to find." |
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 YamlErb | |
# Loads a yaml file that contains erb | |
def self.load_file(path) | |
YAML.load(ERB.new(File.read(path)).result) | |
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
class BlocksAreProcs | |
def try_to_invoke_block | |
foo do | |
puts "start here" | |
return | |
end | |
end | |
def foo | |
yield |
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 MyController < ApplicationController | |
class SomeWisperThing | |
include Wisper::Publisher | |
def execute | |
publish :foo | |
end | |
end | |
def create |
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 BatchStatusPaginator | |
include Sidekiq::Paginator | |
def initialize(page_size=25) | |
@page_size = page_size | |
end | |
# Get all batch statuses | |
def all | |
current_page, total_size, items = batches(1) |
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 ThreadFactory | |
if ENV['RAILS_ENV'] == 'development' | |
class FakeThread | |
def initialize(&block) | |
block.call | |
end | |
end | |
def initialize(&block) | |
FakeThread.new(&block) |
OlderNewer