Popularity
1.0
Declining
Activity
0.0
Stable
0
3
1

Monthly Downloads: 684
Programming language: Elixir
License: MIT License
Tags: Utilities    
Latest version: v1.2.0

exjprop alternatives and similar packages

Based on the "Utilities" category.
Alternatively, view exjprop alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of exjprop or a related project?

Add another 'Utilities' Package

README

Exjprop

Build Status

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

{:exjprop, "~> 1.2"}

Load application properties at runtime

First, define a property loader module

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

defmodule MyApp do
  use Application
  import Supervisor.Spec
  alias MyApp.PropLoader

  def 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.

  {: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

  {:jason, "~> 1.1.2"},