This file contains hidden or 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
include 'dm-is-list' | |
class Node | |
include DataMapper::Resource | |
property :id, Serial | |
# other properties... | |
has n, :parts | |
end |
This file contains hidden or 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
header = nil | |
FasterCSV.foreach(FILE) do |row| | |
row.map! { |v| v.strip!; v == 'NULL' || v.blank? ? nil : v } | |
unless header | |
header = row.freeze | |
next | |
end | |
This file contains hidden or 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
# As an exercise, come up with a ruby-way to specify | |
# a set of search conditions for this SQL: | |
# simple or | |
# WHERE name = 'Dan' OR name = 'Paul' | |
# nested or, plus duplicating field names | |
# WHERE name = 'Paul' AND ( age < 18 OR age > 21 ) | |
# not ( and don't say != ) |
This file contains hidden or 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
# limit/offset using Enumerable#slice | |
collection[0, 20] # LIMIT 0, 20 | |
collection[0..20] # LIMIT 0, 20 | |
# ordering using Enumerable#sort_by (will not require ParseTree) | |
collection.sort_by { |o| o.name } # ORDER BY name | |
collection.sort_by { |o| -o.name } # ORDER BY name DESC |
This file contains hidden or 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
This repository has moved to http://github.com/dkubb/dm-ambition |
This file contains hidden or 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 'pp' | |
require 'rubygems' | |
gem 'dm-core', '0.10.0' # http://github.com/datamapper/dm-core (next branch) | |
require 'dm-core' | |
gem 'dm-ambition', '0.10.0' # http://github.com/dkubb/dm-ambition (master branch) | |
require 'dm-ambition' | |
DataMapper::Logger.new($stdout, :debug) |
This file contains hidden or 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
NOTE: run all the commands prefixed with "$" from the command-line. | |
0) Make sure sake is installed: | |
$ sudo gem install sake | |
1) Make sure you've applied this patch to sake: | |
http://err.lighthouseapp.com/attachments/50325/sake_rake_0.8.2.patch | |
This file contains hidden or 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
# Here is a list of all the dm-core runtime deps. | |
$ gem dep dm-core --remote | |
Gem dm-core-0.9.10 | |
data_objects (~> 0.9.11, runtime) | |
extlib (~> 0.9.10, runtime) | |
addressable (~> 2.0.1, runtime) | |
This file contains hidden or 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
[[email protected]] extlib (next) % rake spec --trace | |
(in /Users/dankubb/Programming/ruby/open-source/dm/extlib) | |
rake aborted! | |
unknown marshal code: 1 | |
kernel/compiler/compile.rb:211:in `single_load {}' | |
kernel/compiler/compile.rb:142:in `compile_feature' | |
kernel/compiler/compile.rb:210:in `single_load' | |
kernel/compiler/compile.rb:131:in `unified_load {}' | |
kernel/bootstrap/array.rb:49:in `each' | |
kernel/compiler/compile.rb:95:in `unified_load' |
This file contains hidden or 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
rake spec results: | |
MySQL | |
102 examples, 1 failure, 1 pending | |
Postgres | |
114 examples, 10 failures, 1 pending | |
SQLite3 | |
SQlite3 -- database locked |