1. Dmitry Belyaev
  2. emongo

Commits

Jacob Vorreuter  committed 5ba9b91

first commit

  • Participants
  • Branches default

Comments (0)

Files changed (10)

File .gitignore

View file
+ebin/*.beam
+ebin/*.app

File Makefile

View file
+VERSION=0.0.1
+PKGNAME=emongo
+LIBDIR=`erl -eval 'io:format("~s~n", [code:lib_dir()])' -s init stop -noshell`
+ROOTDIR=`erl -eval 'io:format("~s~n", [code:root_dir()])' -s init stop -noshell`
+
+all: rel
+	
+compile: app
+	mkdir -p ebin/
+	(cd src;$(MAKE))
+
+app:
+	sh ebin/$(PKGNAME).app.in $(VERSION)
+
+test: compile
+	prove t/*.t
+
+clean:
+	(cd src;$(MAKE) clean)
+	rm -rf erl_crash.dump *.boot *.rel *.script ebin/*.beam ebin/*.app
+
+rel: compile
+	erl -pa ebin -noshell -run $(PKGNAME) build_rel -s init stop
+	
+package: clean
+	@mkdir $(PKGNAME)-$(VERSION)/ && cp -rf ebin include Makefile priv README.markdown src support t $(PKGNAME)-$(VERSION)
+	@COPYFILE_DISABLE=true tar zcf $(PKGNAME)-$(VERSION).tgz $(PKGNAME)-$(VERSION)
+	@rm -rf $(PKGNAME)-$(VERSION)/
+	
+install:
+	@mkdir -p $(prefix)/$(LIBDIR)/$(PKGNAME)-$(VERSION)/{ebin,include,priv}
+	@mkdir -p $(prefix)/$(ROOTDIR)/bin
+	for i in ebin/*.beam include/*.hrl ebin/*.app; do install $$i $(prefix)/$(LIBDIR)/$(PKGNAME)-$(VERSION)/$$i ; done
+	cp *.boot $(prefix)/$(ROOTDIR)/bin/

File README.markdown

Empty file added.

File ebin/emongo.app.in

View file
+#!/bin/bash
+
+VERSION=${1}
+MODULES=`ls -1 src/*.erl | awk -F[/.] '{ print "\t\t" $2 }' | sed '$q;s/$/,/g'`
+
+cat > ebin/emongo.app << EOF
+{application, emongo, [
+    {description, "Erlang MongoDB Driver"},
+    {vsn, "${VERSION}"},
+    {modules, [
+${MODULES}
+    ]},
+    {registered, []},
+    {mod, {emongo_app, []}},
+    {applications, [kernel, stdlib]}
+]}.
+EOF

File include/emongo.hrl

Empty file added.

File priv/example.config

Empty file added.

File src/Makefile

View file
+include ../support/include.mk
+
+all: $(EBIN_FILES)
+
+debug:
+	$(MAKE) DEBUG=-DDEBUG
+
+clean:
+	rm -rf $(EBIN_FILES) erl_crash.dump

File src/emongo.erl

View file
+%% Copyright (c) 2009 Jacob Vorreuter <jacob.vorreuter@gmail.com>
+%% 
+%% Permission is hereby granted, free of charge, to any person
+%% obtaining a copy of this software and associated documentation
+%% files (the "Software"), to deal in the Software without
+%% restriction, including without limitation the rights to use,
+%% copy, modify, merge, publish, distribute, sublicense, and/or sell
+%% copies of the Software, and to permit persons to whom the
+%% Software is furnished to do so, subject to the following
+%% conditions:
+%% 
+%% The above copyright notice and this permission notice shall be
+%% included in all copies or substantial portions of the Software.
+%% 
+%% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+%% EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+%% OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+%% NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+%% HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+%% WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+%% FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+%% OTHER DEALINGS IN THE SOFTWARE.
+-module(emongo).
+-compile(export_all).
+
+show_dbs() -> ok.
+
+show_collections(Database)
+
+show_users(Database) ->
+
+show_profile(Database) ->
+
+use_db(PoolId) ->
+
+find(PoolId) ->
+	
+find(PoolId, )
+
+find_one
+
+insert
+
+update
+
+save
+
+remove
+
+ensure_index
+
+count
+
+drop_collection
+
+clear
+
+

File src/emongo_app.erl

View file
+%% Copyright (c) 2009 Jacob Vorreuter <jacob.vorreuter@gmail.com>
+%% 
+%% Permission is hereby granted, free of charge, to any person
+%% obtaining a copy of this software and associated documentation
+%% files (the "Software"), to deal in the Software without
+%% restriction, including without limitation the rights to use,
+%% copy, modify, merge, publish, distribute, sublicense, and/or sell
+%% copies of the Software, and to permit persons to whom the
+%% Software is furnished to do so, subject to the following
+%% conditions:
+%% 
+%% The above copyright notice and this permission notice shall be
+%% included in all copies or substantial portions of the Software.
+%% 
+%% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+%% EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+%% OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+%% NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+%% HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+%% WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+%% FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+%% OTHER DEALINGS IN THE SOFTWARE.
+-module(emongo_app).
+-behaviour(application).
+
+-export([start/2,stop/1, init/1, build_rel/0]).
+
+start(_, _) ->
+    supervisor:start_link({local, ?MODULE}, ?MODULE, []).
+
+stop(_) -> ok.
+
+init(_) ->
+   {ok, {{one_for_one, 10, 10}, [
+       %{ex_scheduler, {ex_scheduler, start_link, []}, permanent, 5000, worker, [ex_scheduler]}
+   ]}}.
+
+build_rel() ->
+    {ok, FD} = file:open("emongo.rel", [write]),
+    RelInfo = {release,
+        {"emongo", "0.3"},
+        {erts, "5.7.2"}, [
+            {kernel, "2.13.2"},
+            {stdlib, "1.16.2"},
+            {sasl, "2.1.6"},
+            {emongo, "0.0.1"}
+        ]
+    },
+    io:format(FD, "~p.", [RelInfo]),
+    file:close(FD),
+    systools:make_script("emongo", [local]),
+    ok.

File support/include.mk

View file
+## -*- makefile -*-
+
+ERL := erl
+ERLC := $(ERL)c
+
+INCLUDE_DIRS := ../include
+EBIN_DIRS := $(wildcard ../ebin)
+ERLC_FLAGS := -W $(INCLUDE_DIRS:../%=-I ../%) $(EBIN_DIRS:%=-pa %)
+
+ifndef no_debug_info
+  ERLC_FLAGS += +debug_info
+endif
+
+ifdef debug
+  ERLC_FLAGS += -Ddebug
+endif
+
+EBIN_DIR := ../ebin
+DOC_DIR  := ../doc
+EMULATOR := beam
+
+ERL_SOURCES  := $(wildcard *.erl)
+ERL_HEADERS  := $(wildcard *.hrl) $(wildcard ../include/*.hrl)
+ERL_OBJECTS  := $(ERL_SOURCES:%.erl=$(EBIN_DIR)/%.beam)
+ERL_TEMPLATES := $(ERL_TEMPLATE:%.et=$(EBIN_DIR)/%.beam)
+ERL_OBJECTS_LOCAL := $(ERL_SOURCES:%.erl=./%.$(EMULATOR))
+APP_FILES := $(wildcard *.app)
+EBIN_FILES = $(ERL_OBJECTS) $(APP_FILES:%.app=../ebin/%.app) $(ERL_TEMPLATES)
+MODULES = $(ERL_SOURCES:%.erl=%)
+
+../ebin/%.app: %.app
+	cp $< $@
+
+$(EBIN_DIR)/%.$(EMULATOR): %.erl
+	$(ERLC) $(ERLC_FLAGS) -o $(EBIN_DIR) $<
+
+./%.$(EMULATOR): %.erl
+	$(ERLC) $(ERLC_FLAGS) -o . $<