Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added missing types, not ideal, but they're there. Now for tests...È
- Loading branch information
Showing
11 changed files
with
174 additions
and
19 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
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,4 +1,22 @@ | ||
module BSON | ||
class Code# < String | ||
class Code | ||
|
||
property :javascript | ||
|
||
def initialize(@javascript = "") | ||
end | ||
|
||
def self.from_bson(bson : IO) | ||
new String.from_bson_bytes(bson.next_bytes(Int32.from_bson(bson))) | ||
end | ||
|
||
def to_bson(bson : IO) | ||
javascript.to_bson(bson) | ||
end | ||
|
||
def bson_size | ||
javascript.bson_size | ||
end | ||
|
||
end | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
module BSON | ||
class CodeWithScope | ||
|
||
getter :javascript, :scope | ||
|
||
def initialize(@javascript = "", @scope = Document.new) | ||
end | ||
|
||
def self.from_bson(bson : IO) | ||
bson.read(4) # Throw away the total length. | ||
js = String.from_bson_bytes(bson.next_bytes(Int32.from_bson(bson))) | ||
scope = Document.from_bson(bson) | ||
new(js, scope) | ||
end | ||
|
||
def to_bson(bson : IO) | ||
bson_size.to_bson(bson) | ||
js.to_bson(bson) | ||
scope.to_bson(bson) | ||
end | ||
|
||
def bson_size | ||
4 + scope.bson_size + 4 + javascript.bson_size | ||
end | ||
|
||
end | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
module BSON | ||
class DBPointer | ||
|
||
property :pointer | ||
|
||
def initialize(@pointer = "") | ||
end | ||
|
||
def self.from_bson(bson : IO) | ||
new String.from_bson_bytes(bson.next_bytes(Int32.from_bson(bson))) | ||
end | ||
|
||
def to_bson(bson : IO) | ||
pointer.to_bson(bson) | ||
end | ||
|
||
def bson_size | ||
pointer.bson_size | ||
end | ||
|
||
end | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
require "./specialized" | ||
|
||
module BSON | ||
struct MaxKey | ||
include Specialized | ||
extend Specialized::ClassMethods | ||
end | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
require "./specialized" | ||
|
||
module BSON | ||
struct MinKey | ||
include Specialized | ||
extend Specialized::ClassMethods | ||
end | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
module BSON | ||
module Specialized | ||
|
||
def to_bson(bson : IO) | ||
# Do nothing | ||
end | ||
|
||
def bson_size | ||
0 | ||
end | ||
|
||
module ClassMethods | ||
def from_bson(bson : IO) | ||
new | ||
end | ||
end | ||
|
||
end | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
module BSON | ||
class Symbol | ||
|
||
property :string | ||
|
||
def initialize(@string = "") | ||
end | ||
|
||
def self.from_bson(bson : IO) | ||
new String.from_bson_bytes(bson.next_bytes(Int32.from_bson(bson))) | ||
end | ||
|
||
def to_bson(bson : IO) | ||
string.to_bson(bson) | ||
end | ||
|
||
def bson_size | ||
string.bson_size | ||
end | ||
|
||
end | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
module BSON | ||
class Timestamp | ||
|
||
getter :time, :increment | ||
|
||
def initialize(@increment : Int32, @time : Time) | ||
end | ||
|
||
def self.from_bson(bson : IO) | ||
new(Int32.from_bson(bson), Time.epoch(Int32.from_bson(bson))) | ||
end | ||
|
||
def to_bson(bson : IO) | ||
increment.to_bson(bson) | ||
time.epoch.to_bson(bson) # Int32 | ||
end | ||
|
||
def bson_size | ||
sizeof(Int32) + sizeof(Int32) | ||
end | ||
|
||
end | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
module BSON | ||
class Undefined | ||
|
||
def self.from_bson(bson : IO) | ||
nil | ||
end | ||
|
||
def to_bson(bson : IO) | ||
# Do nothing | ||
end | ||
|
||
def bson_size | ||
0 | ||
end | ||
|
||
end | ||
end |
This file was deleted.
Oops, something went wrong.