Skip to content

Instantly share code, notes, and snippets.

View pmoran's full-sized avatar

Peter Moran pmoran

  • REA Group
  • Melbourne, Australia
View GitHub Profile
class Product
def self.select_satisfying(specification)
satisfying = specification.all
# apply more complex selection, such as selecting across different combination of model objects
end
end
---
title: About Us
order: 1
filter: erb
---
<%= render(:partial => "main/about") %>
gemmate() {
mate $GEMDIR/gems/`$(which ls) $GEMDIR/gems | grep $1 | sort`
}
complete -o default -o nospace -F _gemdocomplete gemmate
class IsEffectiveProductSpecification
def criteria
{ :conditions => ["effective_from => :today", { :today <= Date.today}] }
end
end
class CompositeSpecification < Array
def all
self.inject(Product.scoped(nil)) do |combined_scope, specification|
combined_scope.scoped(specification.criteria)
end
end
end
<% menu_items.each do |page| %>
<% if is_current_page?(page) %>
<li class='current'><p><%= page.title %></p> </li>
<% else %>
<li><%= link_to_page(page) %></li>
<% end %>
<% end %>
def menu_items
@pages.find(:all, :in_directory => "/main", :sort_by => 'order')
end
<% @partials.find(:all, :in_directory => "/main") do |partial| %>
<div id='<%= partial.name %>' style='display: none'>
<div><%= render(:partial => partial) %></div>
</div>
<% end %>
# Ripped from cucumber-0.8.3/examples/watir/features/support/screenshots.rb
module Screenshots
if Cucumber::OS_X
def embed_screenshot(id)
`screencapture -t png reports/#{id}.png`
embed("#{id}.png", "image/png")
end
else
def embed_screenshot(id)
`import -window root reports/#{id}.png`
db.get(id)[:status]