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
# Rack file for local Rubygems server, using YARD | |
require "rubygems" | |
require "yard" | |
libraries = {} | |
Gem.source_index.find_name('').each do |spec| | |
libraries[spec.name] ||= [] | |
libraries[spec.name] << YARD::Server::LibraryVersion.new(spec.name, spec.version.to_s, nil, :gem) | |
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
@invalid_user = Factory.create(:user) | |
@invalid_user.stub(:valid?).and_return(false) | |
User.stub(:new).and_return(@invaild_user) | |
post :create, :user_name => "some user name that won't even be used" |
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
module Paperclip | |
module ClassMethods | |
def has_attached_file name, options = {} | |
include InstanceMethods | |
write_inheritable_attribute(:attachment_definitions, {}) if attachment_definitions.nil? | |
attachment_definitions[name] = {:validations => []}.merge(options) | |
after_save :save_attached_files | |
before_destroy :destroy_attached_files |
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
# http://henrik.nyh.se/2008/12/git-dirty-prompt | |
# http://www.simplisticcomplexity.com/2008/03/13/show-your-git-branch-name-in-your-prompt/ | |
# username@Machine ~/dev/dir[master]$ # clean working directory | |
# username@Machine ~/dev/dir[master*]$ # dirty working directory | |
function parse_git_dirty { | |
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*" | |
} | |
function parse_git_branch { | |
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/" |
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 Image < ActiveRecord::Base | |
before_create, :set_width_and_height | |
has_attached_file :img, | |
:url => "/system/images/:attachment/:id/:basename.:extension", | |
:path => "#{Rails.root}/public/system/images/:attachment/:id/:basename.:extension" | |
def set_width_and_height | |
# this next line is the magic line | |
geo = Paperclip::Geometry.from_file(img.to_file(:original)) |
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
Factory.define :application do |factory| | |
factory.attachment(:sample, "public/samples/sample.doc", "application/msword") | |
end |