Permalink
Browse files

Add specifications.

  • Loading branch information...
1 parent 2193715 commit dcf4b6b12bba9ad6e2dac54db59d739d5ef43254 @arcusfelis arcusfelis committed Oct 13, 2011
Showing with 61 additions and 12 deletions.
  1. +3 −8 Makefile
  2. +5 −2 rebar.config
  3. +7 −0 setenv.mk
  4. +8 −0 setenv.sh
  5. +1 −1 src/i18n.app.src
  6. +20 −0 src/i18n_calendar.erl
  7. +14 −0 src/i18n_search.erl
  8. +3 −1 start-dev.sh
View
@@ -2,14 +2,9 @@
PREFIX:=../
DEST:=$(PREFIX)$(PROJECT)
-REBAR=./rebar
-
-export CC=$(shell icu-config --cc)
-export CXX=$(shell icu-config --cxx)
-export ICU_CFLAGS=$(shell icu-config --cflags)
-export ICU_CXXFLAGS=$(shell icu-config --cxxflags)
-export ICU_LDFLAGS=$(shell icu-config --ldflags)
-export VERSION=.$(shell date +%s)
+REBAR=./rebar -v
+-include setenv.mk
+
View
@@ -1,5 +1,6 @@
%% -*- tab-width: 4;erlang-indent-level: 4;indent-tabs-mode: nil -*-
%% ex: ft=erlang ts=4 sw=4 et
+
{port_sources, ["c_src/*.{c,cpp}"]}.
{port_envs, [
@@ -11,10 +12,12 @@
]}.
{so_specs, [
- {"priv/i18n_nif$VERSION.so", ["c_src/i18n_nif.o",
- "c_src/cloner.o"]}
+ {"priv/i18n_nif$I18N_BUILD_ID.so", ["c_src/i18n_nif.o",
+ "c_src/cloner.o"]}
]}.
+
+
{clean_files, ["priv/i18n_*.so"]}.
{eunit_opts, [verbose, {report,{eunit_surefire,[{dir,"."}]}}]}.
View
@@ -0,0 +1,7 @@
+
+export CC=$(shell icu-config --cc)
+export CXX=$(shell icu-config --cxx)
+export ICU_CFLAGS=$(shell icu-config --cflags)
+export ICU_CXXFLAGS=$(shell icu-config --cxxflags)
+export ICU_LDFLAGS=$(shell icu-config --ldflags)
+export I18N_BUILD_ID=.$(shell date +%s)
View
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+export CC="$(icu-config --cc)"
+export CXX="$(icu-config --cxx)"
+export ICU_CFLAGS="$(icu-config --cflags)"
+export ICU_CXXFLAGS="$(icu-config --cxxflags)"
+export ICU_LDFLAGS"=$(icu-config --ldflags)"
+export I18N_BUILD_ID=".$(date +%s)"
View
@@ -1,7 +1,7 @@
{application, i18n,
[
{description, ""},
- {vsn, "1"},
+ {vsn, git},
{registered, []},
{applications, [
kernel,
View
@@ -27,20 +27,40 @@
-export([available_locales/0]).
-type i18n_locale_id() :: atom().
+-type resource() :: <<>>.
+-type i18n_calendar() :: resource().
+-type i18n_timezone() :: atom() | i18n_string().
+-type i18n_calendar_type() :: .
+
+-spec open() -> i18n_calendar().
open() ->
Locale = i18n_locale:get_locale(),
open(Locale).
+
+-spec open(i18n_locale()) -> i18n_calendar().
+
open(Locale) ->
?TRY_RES(?IM:open_calendar(Locale)).
+-spec open(i18n_locale(), i18n_timezone()) -> i18n_calendar().
+
+open(Locale, TZ) when is_atom(TZ) ->
+ ?TRY_RES(?IM:open_calendar(Locale, i18n_string:from(TZ)));
open(Locale, TZ) ->
?TRY_RES(?IM:open_calendar(Locale, TZ)).
+
+-spec open(i18n_locale(), i18n_timezone(), i18n_calendar_type()) ->
+ i18n_calendar().
+
+open(Locale, TZ, Type) when is_atom(TZ) ->
+ ?TRY_RES(?IM:open_calendar(Locale, i18n_string:from(TZ), Type));
open(Locale, TZ, Type) ->
?TRY_RES(?IM:open_calendar(Locale, TZ, Type)).
+
-spec available_locales() -> [i18n_locale_id()].
available_locales() ->
?TRY_LIST(?IM:calendar_locales()).
View
@@ -44,19 +44,33 @@
%% API
%%
+-spec open(i18n_collator(), i18n_string()) -> i18n_searcher().
+
open(Col, Pattern) ->
?TRY_RES(?IM:search_open(Col, Pattern)).
+-spec index(i18n_searcher(), i18n_string()) -> [{Start::non_neg_integer(),
+ Length::non_neg_integer()}].
+
index(Searcher, String) ->
?TRY_LIST(?IM:search_index(Searcher, String)).
+
+-spec match_all(i18n_searcher(), i18n_string()) -> [i18n_string()].
+
match_all(Searcher, String) ->
?TRY_LIST(?IM:search_match_all(Searcher, String)).
+
%% @doc Test matches.
+-spec test(i18n_searcher(), i18n_string()) -> boolean().
+
test(Searcher, String) ->
?TRY_ATOM(?IM:search_index(Searcher, String)).
+
+-spec match(i18n_searcher(), i18n_string()) -> i18n_string() | 'false'.
+
match(Searcher, String) ->
?TRY_STR_OR_ATOM(?IM:search_match(Searcher, String)).
View
@@ -1,6 +1,8 @@
#!/bin/sh
cd `dirname $0`
-./rebar compile
+
+make
+
# NOTE: mustache templates need \ because they are not awesome.
exec erl -pa $PWD/ebin edit $PWD/deps/*/ebin \
-boot start_sasl \

0 comments on commit dcf4b6b

Please sign in to comment.