Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
92fd8db
initial Rebar3/BRT build support
tburghart Nov 26, 2016
42cdc51
tweak .gitignore
tburghart Nov 27, 2016
c2a6e4d
Enable Thumbs
Dec 1, 2016
4709e4a
rearrange some more for newer BRT patterns
tburghart Jan 2, 2017
ec0439c
All tests running and passing.
tburghart Jan 7, 2017
9074b4d
Merge branch 'develop' into feature/riak-2903/rebar3 and confirm all …
tburghart Jan 7, 2017
fc1182f
Add functions to find common test directories in Reabr3's directory s…
tburghart Jan 9, 2017
c629fa8
Builds all Thumbs targets clean on R16 through OTP-20, with and witho…
tburghart Jan 21, 2017
35ba8c4
Merge the 'enable_thumbs' branch. This changes nothing, it's only to …
tburghart Jan 21, 2017
6256376
switch to default eunit_formatters
tburghart Jan 25, 2017
0dd476a
change to 'rebar3' branch
tburghart Feb 27, 2017
1b4381e
merge current 'develop' branch
tburghart Feb 27, 2017
01495c2
Don't warn about erlang:get_stacktrace/0 deprecation
dumbbell Jul 1, 2019
d984079
Rmeove -compile(export_all)
dumbbell Jul 1, 2019
549aee2
Support bbmustache to render test templates
dumbbell Jul 2, 2019
c943341
Use unicode:characters_to_binary/1 to convert an UTF-8 string
dumbbell Jul 2, 2019
9e5a7e4
Paths in tests are relative to project root dir
dumbbell Jul 2, 2019
58b52d3
Enable Travis CI + export test coverage
dumbbell Jul 2, 2019
b2e4963
Fix #translation{} definition: `func` can be undefined
dumbbell Jul 2, 2019
b0464d4
Merge pull request #10 from rabbitmq/fix-tests
Licenser Jul 10, 2019
19c4462
Support reading files & schemas from .ez archives
dumbbell Jul 2, 2019
b6d6287
Bump Lager to a version compatible with modern Erlang/OTP releases
michaelklishin Jul 11, 2019
42ee502
Merge pull request #13 from Kyorai/lager-3.7.x
michaelklishin Jul 11, 2019
58b04b9
Merge pull request #12 from rabbitmq/read-files-from-ez-archives
dumbbell Jul 11, 2019
8c59aec
README.md: Add CI & Hex.pm badges
Licenser Jul 10, 2019
74ac2e2
Merge pull request #14 from Kyorai/integrations-take-2
dumbbell Jul 11, 2019
cbede78
cuttlefish.app.src: Update link to GitHub
dumbbell Jul 11, 2019
42df984
Explain why this repository is no longer a fork
michaelklishin Jul 12, 2019
445f28c
README.md: Add test coverage badge
dumbbell Jul 12, 2019
121d10a
cuttlefish.app.src: Bump version to 2.2.0
dumbbell Jul 11, 2019
6948112
Merge remote-tracking branch 'upstream/develop' into develop
dumbbell Jul 12, 2019
ef90390
Add failing test for gh-1
lukebakken Aug 3, 2019
143dcad
Fix PEG grammar to consider whitespace as one or more whitespace char…
lukebakken Aug 3, 2019
7a154b5
Restore schema file reading from .ez archives
michaelklishin Aug 3, 2019
2caf452
Update an assertion
michaelklishin Aug 3, 2019
fff866a
Merge pull request #2 from Kyorai/gh-1-line-with-whitespace-only
michaelklishin Aug 3, 2019
1f4d7ed
Add NOTE about neotoma and conf_parse:file/1
lukebakken Aug 5, 2019
2ccea1a
Add appveyor file
lukebakken Aug 5, 2019
caf9116
Merge pull request #3 from lukebakken/lrb-windows-build
lukebakken Aug 5, 2019
f44480a
Add appvoyer badge
Licenser Aug 5, 2019
26f8e50
Merge pull request #4 from Kyorai/appvoyer-badge
lukebakken Aug 5, 2019
7a857e9
v2.2.1
michaelklishin Aug 7, 2019
e9f3cf9
More debug logging
michaelklishin Aug 7, 2019
c090113
Ignore doc/*
michaelklishin Aug 7, 2019
14583ca
Minor logging improvements
michaelklishin Aug 7, 2019
69744a9
Repurpose -a to mean --advanced_conf_file as --app_config is not actu…
michaelklishin Aug 7, 2019
d782598
Merge pull request #5 from Kyorai/mk-repurpose-dash-a-switch
lukebakken Aug 7, 2019
27fc2d2
v2.3.0
michaelklishin Aug 7, 2019
4dd6f46
Create develop-3.0 branch
martinsumner Apr 17, 2020
2f9b34f
Remove lock file
martinsumner Apr 17, 2020
c4bcb11
Bump lager version
martinsumner Apr 17, 2020
e58068a
Merge remote-tracking branch 'origin/rebar3' into develop-3.0-mergere…
martinsumner Apr 23, 2020
dac4780
Update .gitignore
martinsumner Apr 23, 2020
ec17f55
Switch back to develop-3.0 rebar.config
martinsumner Apr 23, 2020
9c684df
Delete .thumbs.yml
martinsumner Apr 23, 2020
7dfb6b0
Add xref to travis checks
martinsumner Apr 23, 2020
ee875d8
Remove basho as maintainers
martinsumner Apr 23, 2020
ff12621
Standardise versions
martinsumner May 7, 2020
9273682
Merge pull request #248 from basho/develop-3.0-mergerebar3
martinsumner May 7, 2020
326cdb6
Change folder for test
martinsumner May 13, 2020
e84070b
Fix reference to test file
martinsumner May 13, 2020
1e27870
Allow compilation via Mix
picaoao Aug 11, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 37 additions & 11 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,15 +1,41 @@
.rebar3
_build
.DS_Store
generated.config
generated.conf
ebin/*
.eunit
deps
cuttlefish
# rebar and tools
*.crashdump
.cache/
.rebar3/
_build/
_checkouts
rebar.lock
log/

# work environments
*.bak
*.dump
*.iml
*.plt
*.sublime-project
*.sublime-workspace
log
.local_dialyzer_plt
*.tmp
*.txt
*_plt
*~
.DS_Store
.idea/
.project
.settings/
.tm_properties
erln8.config
tmp/

# Erlang artifacts
*.app
*.beam
/doc/
/ebin/

# build/test artifacts
/cuttlefish
generated.conf
generated.config
src/conf_parse.erl
src/cuttlefish_duration_parse.erl
test_fixtures/escript_prune_test/generated.config/*
8 changes: 8 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
language: erlang
otp_release:
- 20.3.8
- 21.3
- 22.3
script:
- chmod u+x rebar3
- ./rebar3 do upgrade, compile, xref, dialyzer, eunit
111 changes: 111 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
# -------------------------------------------------------------------
#
# Copyright (c) 2013-2017 Basho Technologies, Inc.
#
# This file is provided to you under the Apache License,
# Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
# -------------------------------------------------------------------

prj_dir := $(CURDIR)
cache := $(prj_dir)/.cache

dl_tgts :=
#
# tools
#
ifeq ($(REBAR3),)
REBAR3 := $(cache)/rebar3
dl_tgts += $(REBAR3)
endif
export REBAR3
CP := /bin/cp -p
RM := /bin/rm

.PHONY : check clean clean-deps clean-docs clean-dist compile dialyzer \
default docs escript prereqs test validate veryclean xref

default : compile

prereqs ::

compile :: prereqs
$(REBAR3) as prod compile

check :: prereqs
$(REBAR3) as check do brt-deps --check, dialyzer, xref

clean :: prereqs
$(REBAR3) clean --all

clean-deps :: clean
$(RM) -rf $(prj_dir)/_build

clean-docs ::
$(REBAR3) as docs clean

clean-dist ::
$(RM) -f $(prj_dir)/cuttlefish

docs :: prereqs
$(REBAR3) edoc

dialyzer :: prereqs
$(REBAR3) as check dialyzer

escript :: prereqs
$(REBAR3) as prod escriptize
$(CP) _build/prod/bin/cuttlefish $(prj_dir)/cuttlefish

test :: prereqs
$(REBAR3) eunit

validate :: prereqs
$(REBAR3) as validate compile

veryclean :: clean clean-docs clean-deps clean-dist
$(RM) -rf $(cache)

xref :: prereqs
$(REBAR3) as check xref

#
# how to download files if we need to
#
ifneq ($(dl_tgts),)

dlcmd := $(shell which wget 2>/dev/null || true)
ifneq ($(wildcard $(dlcmd)),)
dlcmd += -O
else
dlcmd := $(shell which curl 2>/dev/null || true)
ifneq ($(wildcard $(dlcmd)),)
dlcmd += -o
else
$(error Need wget or curl to download files)
endif
endif

prereqs :: $(dl_tgts)

veryclean ::
$(RM) -rf $(dl_tgts)

$(cache)/rebar3 :
@test -d $(@D) || /bin/mkdir -p $(@D)
@echo Downloading $@ ...
@$(dlcmd) $@ https://s3.amazonaws.com/rebar3/rebar3
@/bin/chmod +x $@

endif # dl_tgts
20 changes: 19 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
# Cuttlefish

[![Build Status](https://travis-ci.org/Kyorai/cuttlefish.svg?branch=develop)](https://travis-ci.org/Kyorai/cuttlefish)
[![Build status (windows)](https://ci.appveyor.com/api/projects/status/lo8ssrixiqmufc3j?svg=true)](https://ci.appveyor.com/project/Licenser/cuttlefish)
[![Coverage Status](https://coveralls.io/repos/github/Kyorai/cuttlefish/badge.svg?branch=master)](https://coveralls.io/github/Kyorai/cuttlefish)
[![Hex version](https://img.shields.io/hexpm/v/cuttlefish.svg "Hex version")](https://hex.pm/packages/cuttlefish)

Cuttlefish is a library for Erlang applications that wish to walk the
fine line between Erlang `app.config`s and a sysctl-like syntax.
The name is a pun on the pronunciation of 'sysctl' and jokes are
better explained.

This repository retains full history of the original repository, [basho/cuttlefish/](https://github.com/basho/cuttlefish/),
but intentionally cut ties with that repo to avoid confusion as to
where is the most up-to-date, maintained version is.

This is the repository used to produce [Hex.pm releases](https://hex.pm/packages/cuttlefish) of the project.

## Riak Disclaimer

While this readme and test suite is Riak-heavy, the fact is that this
Expand Down Expand Up @@ -88,7 +99,14 @@ https://github.com/basho/cuttlefish/wiki/Cuttlefish-for-Application-Users
* [node_package](https://github.com/basho/cuttlefish/wiki/Cuttlefish-for-node_package-users)
* [non node_package](https://github.com/basho/cuttlefish/wiki/Cuttlefish-for-non-node_package-users)


## Current Status

Cuttlefish is ready for production deployments.

## Re-generating parser

```
rebar3 as dev neotoma
```

Please see the *NOTE* in `src/conf_parse.peg` as well.
9 changes: 9 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
build: off

install:
- curl -OL https://s3.amazonaws.com/rebar3/rebar3

test_script:
- escript ./rebar3 do compile,eunit,dialyzer

deploy: false
25 changes: 20 additions & 5 deletions rebar.config
Original file line number Diff line number Diff line change
@@ -1,20 +1,35 @@
{minimum_otp_vsn, "R16"}.
{minimum_otp_vsn, "20"}.

{erl_opts, [warnings_as_errors,
{parse_transform, lager_transform},
debug_info,
warn_untyped_record]}.

{deps, [getopt, {lager, "~>3.6.0"}]}.
{deps, [
{lager, {git, "git://github.com/erlang-lager/lager.git", {tag, "3.8.0"}}},
{getopt, {git, "git://github.com/jcomellas/getopt.git", {tag, "v1.0.1"}}}]}.

{escript_emu_args, "%%! -escript main cuttlefish_escript +S 1 +A 0\n"}.
{escript_incl_apps, [goldrush, getopt, lager, cuttlefish]}.
{escript_incl_apps, [getopt, lager, cuttlefish]}.
{escript_main_app, cuttlefish}.

{provider_hooks, [{post, [{compile, {default, escriptize}}]}]}.
% {provider_hooks, [{post, [{compile, {default, escriptize}}]}]}.

{xref_checks, [
undefined_function_calls,
undefined_functions,
locals_not_used,
deprecated_function_calls,
deprecated_functions
]}.

{eunit_opts, [verbose]}.
{cover_enabled, true}.
{cover_print_enabled, true}.
{cover_export_enabled, true}.

{profiles, [{dev, [{deps, [neotoma]},
{plugins, [rebar3_neotoma_plugin]}]}]}.
{plugins, [rebar3_neotoma_plugin]}]},
{test, [{deps, [bbmustache]}]}]}.


15 changes: 15 additions & 0 deletions rebar.config.script
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
%% vim:ft=erlang:

case os:getenv("TRAVIS_JOB_ID") of
false -> CONFIG;
JobId ->
%% coveralls.io.
[{plugins, [{coveralls,
{git, "https://github.com/markusn/coveralls-erl",
{branch, "master"}}}]}
,{coveralls_coverdata, "_build/test/cover/eunit.coverdata"}
,{coveralls_service_name, "travis-ci"}
,{coveralls_service_job_id, JobId}
|CONFIG
]
end.
10 changes: 0 additions & 10 deletions rebar.lock

This file was deleted.

Binary file added rebar3
Binary file not shown.
41 changes: 30 additions & 11 deletions src/conf_parse.erl
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@

%% -------------------------------------------------------------------
%%
%% conf_parse: for all your .conf parsing needs.
%%
%% Copyright (c) 2013 Basho Technologies, Inc. All Rights Reserved.
%% Copyright (c) 2013-2017 Basho Technologies, Inc.
%%
%% This file is provided to you under the Apache License,
%% Version 2.0 (the "License"); you may not use this file
Expand All @@ -36,10 +34,13 @@
%% under the License.
%%
%% -------------------------------------------------------------------
%%
%% This is a generated file, changes should be made to conf_parse.peg.
%%

%% This module implements the parser for a sysctl-style
%% configuration format. Example:
%% This module implements the parser for a sysctl-style configuration format.
%%
%% Example:
%% ```
%% riak.local.node = riak@127.0.0.1
%% riak.local.http = 127.0.0.1:8098
Expand All @@ -56,17 +57,18 @@
%%
%% Other modules in this application interpret and validate the
%% result of a successful parse.
%% @end
%%

-define(line, true).
-define(FMT(F,A), lists:flatten(io_lib:format(F,A))).

-ifdef(TEST).
-include_lib("eunit/include/eunit.hrl").
-compile(export_all).
-endif.

%% @doc Only let through lines that are not comments or whitespace.
is_setting(ws) -> false;
is_setting([ws]) -> false;
is_setting(comment) -> false;
is_setting(_) -> true.

Expand All @@ -79,7 +81,7 @@ unescape_dots([C|Rest]) ->

-ifdef(TEST).
file_test() ->
Conf = conf_parse:file("../test/riak.conf"),
Conf = conf_parse:file(cuttlefish_test_util:test_file("riak.conf")),
?assertEqual([
{["ring_size"],"32"},
{["anti_entropy"],"debug"},
Expand All @@ -92,18 +94,35 @@ file_test() ->
ok.

utf8_test() ->
Conf = conf_parse:parse("setting = thingŒ\n"),
Conf = conf_parse:parse("setting = thing" ++ [338] ++ "\n"),
?assertEqual([{["setting"],
{error, {conf_to_latin1, 1}}
}], Conf),
ok.

gh_1_two_tab_test() ->
Conf = conf_parse:parse("setting0 = thing0\n\t\t\nsetting1 = thing1\n"),
?assertEqual([
{["setting0"],"thing0"},
{["setting1"],"thing1"}
], Conf),
ok.

gh_1_three_tab_test() ->
Conf = conf_parse:parse("setting0 = thing0\n\t\t\t\nsetting1 = thing1\n"),
?assertEqual([
{["setting0"],"thing0"},
{["setting1"],"thing1"}
], Conf),
ok.

-endif.

-spec file(file:name()) -> any().
file(Filename) -> case file:read_file(Filename) of {ok,Bin} -> parse(Bin); Err -> Err end.

-spec parse(binary() | list()) -> any().
parse(List) when is_list(List) -> parse(list_to_binary(List));
parse(List) when is_list(List) -> parse(unicode:characters_to_binary(List));
parse(Input) when is_binary(Input) ->
_ = setup_memo(),
Result = case 'config'(Input,{{line,1},{column,1}}) of
Expand Down Expand Up @@ -172,7 +191,7 @@ parse(Input) when is_binary(Input) ->

-spec 'ws'(input(), index()) -> parse_result().
'ws'(Input, Index) ->
p(Input, Index, 'ws', fun(I,D) -> (p_charclass(<<"[\s\t]">>))(I,D) end, fun(_Node, _Idx) ->ws end).
p(Input, Index, 'ws', fun(I,D) -> (p_one_or_more(p_charclass(<<"[\s\t]">>)))(I,D) end, fun(_Node, _Idx) ->ws end).



Expand Down
Loading