Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
51 additions
and
349 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,56 @@ | ||
NAME | ||
---- | ||
mongoid-sequence | ||
mongoid-grid_fs | ||
|
||
INSTALL | ||
------- | ||
gem install mongoid-sequence | ||
gem install mongoid-grid_fs | ||
|
||
SYNOPSIS | ||
-------- | ||
|
||
````ruby | ||
|
||
require 'mongoid' | ||
require 'mongoid-sequence' | ||
require 'mongoid-grid_fs' | ||
|
||
g = GridFs.put readable | ||
|
||
class Page | ||
include Mongoid::Document | ||
include Mongoid::Sequence | ||
GridFS.get id | ||
|
||
sequence :number | ||
end | ||
|
||
p Page.create.number #=> 1 | ||
p Page.create.number #=> 2 | ||
p Page.create.number #=> 3 | ||
GridFS.delete id | ||
|
||
|
||
```` | ||
|
||
DESCRIPTION | ||
----------- | ||
mongoid_sequence is a pure mongoid sequence generator based on mongodb's | ||
increment operator | ||
mongoid_grid_fs is a pure mongoid 3 / moped implementation of the mongodb | ||
grid_fs specification | ||
|
||
ref: http://www.mongodb.org/display/DOCS/GridFS+Specification | ||
|
||
it has the following features: | ||
|
||
- implementation is on top of mongoid for portability. moped (the driver) is | ||
barely used | ||
|
||
- simple, REST-like api | ||
|
||
- support for custom namespaces (fs.files vs. image.files) | ||
|
||
- pathnames and io-like objects can be written to the grid | ||
|
||
- auto-unique pathnames are generated (by default) to avoid collisions using #put | ||
|
||
'path/info/a.rb' -> '$object_id/a.rb' | ||
|
||
- [] and []= methods which allow the grid to be used like a giant file | ||
hash in the sky | ||
|
||
- supprt for data_uris | ||
|
||
````erb | ||
<%= image_tag :src => file.data_uri %> | ||
```` |
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,18 @@ | ||
# -*- encoding : utf-8 -*- | ||
require 'pp' | ||
require_relative 'testing' | ||
require_relative '../lib/mongoid-sequence.rb' | ||
require_relative '../lib/mongoid-grid_fs.rb' | ||
|
||
Mongoid.configure do |config| | ||
config.connect_to('mongoid-sequence') | ||
config.connect_to('mongoid-grid_fs_test') | ||
end | ||
|
||
require 'stringio' | ||
|
||
class SIO < StringIO | ||
attr_accessor :filename | ||
|
||
def initialize(filename, *args, &block) | ||
@filename = filename | ||
super(*args, &block) | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.