Skip to content

Instantly share code, notes, and snippets.

View calavera's full-sized avatar

David Calavera calavera

View GitHub Profile
require 'paperclip/geometry'
module Paperclip
module ClassMethods
# Places ActiveRecord-style validations on the width of the file assigned. The
# possible options are:
# * +in+: a Range of pixels (i.e. +10..100+),
# * +less_than+: equivalent to :in => 0..options[:less_than]
# * +greater_than+: equivalent to :in => options[:greater_than]..Infinity
# * +message+: error message to display, use :min and :max as replacements
def validates_attachment_width name, options = {}
From 6cd3c50ba52e50bcc577fe729a927718734ce3a6 Mon Sep 17 00:00:00 2001
From: David Calavera <david.calavera@gmail.com>
Date: Thu, 3 Sep 2009 20:00:57 +0200
Subject: [PATCH] Encoding specs for IO and FILE initialization
---
core/file/initialize_spec.rb | 16 +++++++++++++
core/io/initialize_spec.rb | 51 ++++++++++++++++++++++++++++++++++++++++++
2 files changed, 67 insertions(+), 0 deletions(-)
From 1e3fc7d16c791147e769d49ab8f9b14a5bae1498 Mon Sep 17 00:00:00 2001
From: David Calavera <david.calavera@gmail.com>
Date: Thu, 10 Sep 2009 18:40:24 +0200
Subject: [PATCH] added Enumerator#with_object and Enumerator#each_with_object specs
---
core/enumerator/each_with_object_spec.rb | 8 ++++++++
core/enumerator/with_object_spec.rb | 8 ++++++++
shared/enumerator/with_object.rb | 19 +++++++++++++++++++
3 files changed, 35 insertions(+), 0 deletions(-)
david@MacSkull ~/dev/rubyspec$ git add core/io/gets_spec.rb
david@MacSkull ~/dev/rubyspec$ git ci -m "added specs for IO.gets with an integer as parameter to limit the outputs's size"
Created commit b12220d: added specs for IO.gets with an integer as parameter to limit the outputs's size
1 files changed, 26 insertions(+), 0 deletions(-)
david@MacSkull ~/dev/rubyspec$ git push origin master
Counting objects: 9, done.
Compressing objects: 100% (5/5), done.
Writing objects: 100% (5/5), 694 bytes, done.
#!/usr/bin/ruby
RUBYSPEC_PATH = '../rubyspec/'
if ARGV.length == 1
Dir.glob("#{RUBYSPEC_PATH}#{ARGV[0]}/*_spec.rb") do |spec|
system("bin/jruby -T -J-Djruby.compat.version=RUBY1_9 spec/mspec/bin/mspec #{File.expand_path(spec)}")
end
elsif ARGV.length >= 2
ARGV[1..-1].each do |arg|
@calavera
calavera / gist:195524
Created September 28, 2009 15:49
weird behaviours running specs
* Error parsing symbols.
Some specs fail because mspec raises an error with some symbols, this is an example:
An exception occurred during: Mock.cleanup
Hash#== returns true if other Hash has the same number of keys and each key-value pair matches, even though the default-value are not same ERROR
NoMethodError: undefined method `first' for :"__mspec_14_eql?__":Symbol
/home/david/dev/rubyspec/core/hash/equal_value_spec.rb:5
/home/david/dev/rubyspec/core/hash/equal_value_spec.rb:55:in `load'
####################################
### INTERPRETER BEFORE THE PATCH ###
####################################
irb(main):002:0> Benchmark.bm { |x| x.report { for i in 1..5000; h = {"foo" => "foo", "bar" => "bar", "zoo" => "zoo", "baaz" => "baaz"}; end } }
user system total real
0.197000 0.000000 0.197000 ( 0.196000)
=> true
###################################
### INTERPRETER AFTER THE PATCH ###
@JRubyMethod(name = "initialize", visibility = Visibility.PRIVATE, compat = CompatVersion.RUBY1_9)
public IRubyObject initialize19(ThreadContext context, Block block) {
if (!block.isGiven()) {
throw context.getRuntime().newArgumentError(0, 1);
} else {
// I DON'T KNOW WHAT TO DO WITH THE BLOCK
return null;
}
}
install-gems:
[java] **************************************************
[java]
[java] Thank you for installing rspec-1.2.6
[java]
[java] Please be sure to read History.rdoc and Upgrade.rdoc
[java] for useful information about this release.
[java]
[java] **************************************************
[java] Successfully installed rspec-1.2.6
From 02eadbc2707e46914b28e5f040ffbbf8becf9888 Mon Sep 17 00:00:00 2001
From: David Calavera <david.calavera@gmail.com>
Date: Tue, 24 Nov 2009 13:11:25 +0100
Subject: [PATCH] fixes JRUBY-4268: speed-up yaml/yecht loading
---
src/org/jruby/Ruby.java | 25 +++++++++-----
src/org/jruby/RubyJRuby.java | 12 ++++++
src/org/jruby/ext/LateLoadingLibrary.java | 7 ++--
src/org/jruby/ext/LateLoadingScriptLibrary.java | 42 +++++++++++++++++++++++