Skip to content

Instantly share code, notes, and snippets.

View ahawkins's full-sized avatar
💭
🌈🏄🏼‍♂️🤙🏻

Adam Hawkins ahawkins

💭
🌈🏄🏼‍♂️🤙🏻
View GitHub Profile
module KeepUp
module Permissions
module CommonMethods
def self.included(klass)
klass.class_eval do
alias :authorize :grant
end
end
module KeepUp
module Permissions
module Language
def method_missing(method_id, *attrs)
if /can_not_(.+)\?/.match(method_id.to_s)
return !has_permission?($~[1])
elsif /can_(.+)\?/.match(method_id.to_s)
return has_permission?($~[1])
#elsif /is_(.+)\?/.match(method_id.to_s)
#return true if has_permission? :god
module KeepUp
module Permissions
module RoleExtension
def self.included(klass)
klass.class_eval do
include KeepUp::Permissions::CommonMethods
include KeepUp::Permissions::Language
has_and_belongs_to_many :users, :join_table => :user_roles
has_one :permission, :as => :authorizable
module KeepUp
module Permissions
module UserExtension
def self.included(klass)
klass.class_eval do
has_one :permission, :as => :authorizable
has_and_belongs_to_many :roles, :join_table => :user_roles
alias :can? :has_permission?
vendored_cucumber_dir = Dir["#{RAILS_ROOT}/vendor/{gems,plugins}/cucumber*"].first
$LOAD_PATH.unshift("#{vendored_cucumber_dir}/lib") unless vendored_cucumber_dir.nil?
require 'cucumber/rake/task'
namespace :cucumber do
vendored_cucumber_binary = "#{vendored_cucumber_dir}/bin/cucumber" unless vendored_cucumber_dir.nil?
Cucumber::Rake::Task.new({:rcov => 'db:test:prepare'}, 'Run features through RCOV') do |t|
t.binary = vendored_cucumber_binary
# mocks s3 for testing
S3_MODELS = {
:user => :avatar,
:car => :picture
}
S3_MODELS.each do |model, attachment|
definition = model.to_s.gsub(" ", "_").classify.constantize.attachment_definitions[attachment.to_sym]
path = "http://s3.amazonaws.com/:id/#{definition[:path]}"
>> m = Mail.new :bcc => "Adman1965@gmai.com"
=> #<Mail::Message:2187944080, Multipart: false, Headers: <Bcc: Adman1965@gmai.com>>
>> m.bcc
=> ["Adman1965@gmai.com"]
>> m.to_s
=> "Date: Sat, 27 Mar 2010 02:18:00 -0700\r\nMessage-ID: <4badcd4819ef0_3fe6800b81ac13570@Mini.local.mail>\r\nMime-Version: 1.0\r\nContent-Type: text/plain;\r\n\tcharset=\"US-ASCII\";\r\nContent-Transfer-Encoding: 7bit\r\n\r\n"
>> a = Mail.new(to_s)
=> #<Mail::Message:2187861660, Multipart: false, Headers: <main: >>
>> a.bcc
=> nil
// duplicates the current functionality
settingsCheck({
askUrl: '/settings/todo/ready',
formUrl: '/settings/todo/edit',
selector: 'a.new-todo',
event: 'click',
defaultAction: function() {
$("a.new-todo").live('click', function(){
$("#" + $(this).attr('rel')).toggle('fast');
return false;
#!/usr/bin/ruby
require 'rss/2.0'
require 'open-uri'
require 'uri'
require 'rubygems'
require 'active_record'
ActiveRecord::Base.establish_connection :adapter => 'sqlite3', :database => 'downloaded.sqlite3'
require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
class MockResponse
def content_type
'text/html'
end
end
class RenderingController < ApplicationController