Skip to content

Commit

Permalink
Merge pull request #29 from felipenoris/fn/refactoring
Browse files Browse the repository at this point in the history
Fn/refactoring
  • Loading branch information
ScottPJones authored Aug 21, 2018
2 parents 32a8b3f + a08e373 commit c315ff0
Show file tree
Hide file tree
Showing 13 changed files with 145 additions and 122 deletions.
10 changes: 9 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
*.cov
*.jl.cov
*.jl.*.cov
*.jl.mem
/deps/build.log
/deps/deps.jl
/deps/usr/
/docs/build/
/docs/site/
/docs/out.xml
10 changes: 3 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,12 @@ language: julia
os:
- linux
julia:
- 0.5
- 0.6
# - nightly
services:
- mongodb
notifications:
email: false
sudo: false
script:
- if [[ -a .git/shallow ]]; then git fetch --unshallow; fi
- julia -e 'Pkg.clone(pwd()); Pkg.build("Mongo"); Pkg.test("Mongo", coverage=true)'
before_script:
- julia -e 'Pkg.clone("LibBSON"); Pkg.build()'
after_success:
- if [ $JULIAVERSION = "juliareleases" ]; then julia -e 'cd(Pkg.dir("Mongo")); Pkg.add("Coverage"); using Coverage; Coveralls.submit(Coveralls.process_folder())'; fi
- julia -e 'VERSION < v"0.7.0-DEV" || (using Pkg); cd(Pkg.dir("Mongo")); Pkg.add("Coverage"); using Coverage; Coveralls.submit(Coveralls.process_folder()); Codecov.submit(Codecov.process_folder())'
6 changes: 0 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
IMPORTANT: Looking for New Maintainer
-------------------------------------

Note that we are looking for a new maintainer for the Mongo.jl package. If you are interested in taking over maintenance of Mongo.jl please contact peter dot zion at gmail dot com.

Mongo.jl
===========

[![Build Status](https://api.travis-ci.org/pzion/Mongo.jl.svg?branch=master)](https://travis-ci.org/pzion/Mongo.jl)
=======
[![0.6 Status](http://pkg.julialang.org/badges/Mongo_0.6.svg)](http://pkg.julialang.org/?pkg=Mongo)
[![0.5 Status](http://pkg.julialang.org/badges/Mongo_0.5.svg)](http://pkg.julialang.org/?pkg=Mongo)
[![Coverage Status](https://img.shields.io/coveralls/pzion/Mongo.jl.svg)](https://coveralls.io/r/pzion/Mongo.jl?branch=master)

[MongoDB](http://www.mongodb.org) bindings for [The Julia Language](http://julialang.org/)
Expand Down
8 changes: 3 additions & 5 deletions REQUIRE
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
julia 0.5
LibBSON 0.2.8
BinDeps 0.4
Compat 0.9
@osx Homebrew
julia 0.6 0.7
LibBSON
BinaryProvider
5 changes: 0 additions & 5 deletions deps/.gitignore

This file was deleted.

54 changes: 34 additions & 20 deletions deps/build.jl
Original file line number Diff line number Diff line change
@@ -1,26 +1,40 @@
using BinDeps

@BinDeps.setup
using BinaryProvider # requires BinaryProvider 0.3.0 or later

libmongoc = library_dependency(
"libmongoc",
aliases = ["libmongoc", "libmongoc-1.0"]
)
# Parse some basic command-line arguments
const verbose = "--verbose" in ARGS
const prefix = Prefix(get([a for a in ARGS if a != "--verbose"], 1, joinpath(@__DIR__, "usr")))
products = [
LibraryProduct(prefix, String["libmongoc"], :libmongoc),
]

provides(Sources, Dict(
URI("http://github.com/mongodb/mongo-c-driver/releases/download/1.0.0/mongo-c-driver-1.0.0.tar.gz") => libmongoc
))
# Download binaries from hosted location
bin_prefix = "https://github.com/felipenoris/mongo-c-driver-builder/releases/download/v1.9.5"

provides(
BuildProcess,
Autotools(libtarget = "libmongoc-1.0.la"),
libmongoc,
os = :Unix
)

@static if is_apple()
using Homebrew
provides(Homebrew.HB, Dict("mongo-c-driver" => libmongoc))
# Listing of files generated by BinaryBuilder:
download_info = Dict(
Linux(:aarch64, :glibc) => ("$bin_prefix/libmongoc.v1.9.5.aarch64-linux-gnu.tar.gz", "3bcad8b9004e7ca498db6ef58e7c12819b47b316b1bbfc30c017968d6a086c94"),
Linux(:armv7l, :glibc, :eabihf) => ("$bin_prefix/libmongoc.v1.9.5.arm-linux-gnueabihf.tar.gz", "5c329679e4206a10c43a4b447c29e1fe9601ad4023d48c805ebaa4cc75ec1e06"),
Linux(:powerpc64le, :glibc) => ("$bin_prefix/libmongoc.v1.9.5.powerpc64le-linux-gnu.tar.gz", "9f786c54e33986eddf2132b2ea35f967416246e4d5e098ee468d8cc2e98e7111"),
MacOS(:x86_64) => ("$bin_prefix/libmongoc.v1.9.5.x86_64-apple-darwin14.tar.gz", "465a4628d18f0485772e79214ec916af0c934eea5534e0d2ebac9b6e78e2f3a0"),
Linux(:x86_64, :glibc) => ("$bin_prefix/libmongoc.v1.9.5.x86_64-linux-gnu.tar.gz", "3b9a4464c2eac6b7a98dd295b42f3a7793238d11b9e9f6ce5b4e8b3b0859aa86"),
FreeBSD(:x86_64) => ("$bin_prefix/libmongoc.v1.9.5.x86_64-unknown-freebsd11.1.tar.gz", "d4737348d786f094710dc7e94ca6e9363252c2d002a9c502aaab85a77177c1d4"),
)

# Install unsatisfied or updated dependencies:
unsatisfied = any(!satisfied(p; verbose=verbose) for p in products)
if haskey(download_info, platform_key())
url, tarball_hash = download_info[platform_key()]
if unsatisfied || !isinstalled(url, tarball_hash; prefix=prefix)
# Download and install binaries
install(url, tarball_hash; prefix=prefix, force=true, verbose=verbose)
end
elseif unsatisfied
# If we don't have a BinaryProvider-compatible .tar.gz to download, complain.
# Alternatively, you could attempt to install from a separate provider,
# build from source or something even more ambitious here.
error("Your platform $(triplet(platform_key())) is not supported by this package!")
end

@BinDeps.install Dict(:libmongoc => :libmongoc)
# Write out a deps.jl file that will contain mappings for our products
write_deps_file(joinpath(@__DIR__, "deps.jl"), products, verbose=verbose)
18 changes: 9 additions & 9 deletions src/Mongo.jl
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@

__precompile__(true)
module Mongo

include("../deps/deps.jl")
const deps_script = joinpath(dirname(@__FILE__), "..", "deps", "deps.jl")
if !isfile(deps_script)
error("Mongo.jl is not installed properly, run Pkg.build(\"Mongo\") and restart Julia.")
end
include(deps_script)
check_deps()

using LibBSON

import Base.show,
Base.convert,
Base.start,
Base.next,
Base.count,
Base.find,
Base.done

ccall(
(:mongoc_init, libmongoc),
Void, ()
)

atexit() do
ccall((:mongoc_cleanup, libmongoc), Void, ())
end
Expand Down
13 changes: 7 additions & 6 deletions src/MongoClient.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Compat

type MongoClient
mutable struct MongoClient
uri::AbstractString
_wrap_::Ptr{Void}

Expand All @@ -26,19 +25,19 @@ MongoClient(host::AbstractString, user::AbstractString, password::AbstractString
end
export MongoClient

show(io::IO, client::MongoClient) = print(io, "MongoClient($(client.uri))")
export show
Base.show(io::IO, client::MongoClient) = print(io, "MongoClient($(client.uri))")

"""
Issues a command to MongoDB client through `mongoc_client_command_simple`.
Possible commands: https://docs.mongodb.org/manual/reference/command/
"""
command_simple(
function command_simple(
client::MongoClient, # mongoc_client_t
db_name::AbstractString, # const char
command::BSONObject#, # const bson_t
) = begin
)

dbCStr = String(db_name)
reply = BSONObject() # bson_t
bsonError = BSONError() # bson_error_t
Expand All @@ -54,6 +53,7 @@ command_simple(
) || error("update: $(string(bsonError))")
return reply
end

command_simple(
client::MongoClient,
db_name::AbstractString,
Expand All @@ -63,6 +63,7 @@ command_simple(
db_name,
BSONObject(command)
)

command_simple(
client::MongoClient,
db_name::AbstractString,
Expand Down
Loading

0 comments on commit c315ff0

Please sign in to comment.