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 "rubygems" | |
require "dm-core" | |
DataMapper.setup(:default, "sqlite3::memory:") | |
class Category | |
include DataMapper::Resource | |
property :id, Serial | |
has n, :items |
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
== 0.9.3 "We Sold Our Soul for Rock 'n' Roll" 2008-05-03 | |
* Added render(template_path) feature to view specs. | |
* add mutex around compiled statement generation in the router so reloading doesn't step | |
* BootLoader::LoadClasses now logs the actual exceptions | |
* Added String#unescape_regexp for usage in Router::Route#generate | |
* Added Time#to_json to Core Extensions so JSON formatted output for Time is ISO 8601 compatible | |
* redo stream_file to (hopefully) work | |
* _dispatch returns @body | |
* Refactored Merb::AbstractController.layout class method | |
* Fixed lurking infinite loop with not so common formats and ExceptionController |
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 Foo | |
private | |
def bar | |
"Hey" | |
end | |
protected | |
def baz | |
"HeyHey" | |
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
def requirable?(filename) | |
result = fork do | |
begin | |
require filename | |
exit!(0) | |
rescue | |
exit!(1) | |
end | |
end | |
result == 0 ? true : false |
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 DataMapper; class Collection; alias_method :create_or_error, :create; end; end | |
=> DataMapper::Collection | |
>> Customer.first.environments.create_or_error | |
=> #<Environment created_at=nil updated_at=nil id=nil number=nil classification=nil description=nil cluster_id=nil customer_id=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
def check_box(method_or_attrs = {}, attrs = {}) | |
unless method_or_attrs.is_a?(Hash) | |
method = method_or_attrs | |
name = control_name(method) | |
update_control_fields(method, attrs, "checkbox") | |
check_box({:name => name}.merge(attrs)) | |
else | |
attrs = method_or_attrs | |
end | |
update_fields(attrs, "checkbox") |
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
def dispatch_action(klass, action, status = 200) | |
controller = klass.new(self, status) | |
- if Dispatcher.use_mutex then | |
+ if nil then | |
@@mutex.synchronize { controller._dispatch(action) } | |
else | |
controller._dispatch(action) | |
end | |
controller | |
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
Thread.current[:rake_namespace] = "" | |
require "set" | |
class RakeTask | |
TASKS = Hash.new {|h,k| h[k] = {:blocks => [], :deps => []}} | |
CALLED_TASKS = Set.new | |
def self.call(task_name) | |
return if CALLED_TASKS.include?(task_name.to_sym) | |
CALLED_TASKS << task_name.to_s | |
task = TASKS[task_name.to_s] |
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 'rubygems' | |
require 'benchmark' | |
require 'drb' | |
module Spec | |
module Runner | |
module Formatters | |
class BaseTextFormatter | |
def dump_failure(counter, failure) | |
output = @options.error_stream |
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
1) | |
'Merb::Request query and body params should support XML params' FAILED | |
expected: {"foo"=>{"baz"=>nil, "bar"=>"baz"}}, | |
got: {} (using ==) | |
./spec/public/request/request_spec.rb:94: | |
./bin/../lib/merb-core/test/run_specs.rb:104:in `run_specs' | |
./bin/../lib/merb-core/test/run_specs.rb:95:in `fork' | |
./bin/../lib/merb-core/test/run_specs.rb:95:in `run_specs' | |
./bin/../lib/merb-core/test/run_specs.rb:93:in `each' | |
./bin/../lib/merb-core/test/run_specs.rb:93:in `run_specs' |