https://github.com/stocks29/exjprop
Elixir library for reading Java properties files from various sources.
https://github.com/stocks29/exjprop
Last synced: about 1 month ago
JSON representation
Elixir library for reading Java properties files from various sources.
- Host: GitHub
- URL: https://github.com/stocks29/exjprop
- Owner: stocks29
- License: mit
- Created: 2015-03-15T01:04:18.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2019-07-28T16:56:48.000Z (over 5 years ago)
- Last Synced: 2025-03-01T11:20:39.541Z (about 2 months ago)
- Language: Elixir
- Size: 42 KB
- Stars: 0
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- freaking_awesome_elixir - Elixir - Elixir library for reading Java properties files from various sources. (Utilities)
- fucking-awesome-elixir - exjprop - Elixir library for reading Java properties files from various sources. (Utilities)
- awesome-elixir - exjprop - Elixir library for reading Java properties files from various sources. (Utilities)
README
Exjprop
=======[](https://travis-ci.org/stocks29/exjprop)
Exjprop is a library for reading Java properties files from various sources.
Implementations are provided for File, Stream, Function (which returns a stream), and Amazon S3.
API documentation is available at http://hexdocs.pm/exjprop
### Add as dependency
```elixir
{:exjprop, "~> 1.2"}
```### Load application properties at runtime
First, define a property loader module
```elixir
defmodule MyApp.PropLoader do
use Exjprop.Loader
import Exjprop.Validators, only: [required: 1]property "endpoint.secret", {:my_app, MyApp.Endpoint, :secret_key_base}
property "foo.bar", {:my_app, MyApp.Foo, :bar}, secret: false, pipeline: [&required/1]
property "foo.quux", {:my_app, MyApp.Foo, :quux}, secret: false, pipeline: [&required/1, &integer/1]property "other_app.thing", {:other_app, :thing}, secret: false, pipeline: [&required/1, &integer/1]
end
```Next, when your application starts, have it read in your properties and update
your application environment```elixir
defmodule MyApp do
use Application
import Supervisor.Spec
alias MyApp.PropLoaderdef start(_type, _args) do
PropLoader.load_and_update_env({:system, "MYAPP_PROPS_FILE"})
...
```This configuration will cause the prop loader to read the `MYAPP_PROPS_FILE`
environment var, and attempt to use that as a uri for loading a properties file.
The uri should either `file:///path/to/file.properties` or
`s3:///myapp_bucket/path/to/s3/file.properties`.### Using S3 URLs
To enable support for retrieving property files from S3, a few additional dependencies are required.
```elixir
{:ex_aws, "~> 2.1"},
{:sweet_xml, "~> 0.6"},
```ExAws also needs an HTTP client - it defaults to Hackney, but can be modified (see https://hexdocs.pm/ex_aws/ExAws.Request.HttpClient.html)
### JSON
Enable validators for json to keyword lists or maps
```elixir
{:jason, "~> 1.1.2"},
```