Giter VIP home page Giter VIP logo

tinyconfiguration's Introduction

Logo

Table of Contents

Introduction

Easily create and manage configuration files for your programs, check all properties are present and formally valid. TinyConfiguration is a software library that takes charge of this work and tries to be simple and effective at the same time.

Features

A few of the things you can do with TinyConfiguration:

  • Read, write and delete custom configuration file (even async)
  • Easily search and retrieve values
  • Execute validation on properties values with lambda functions
  • Export configuration as JSON, XML, YAML & CSV

Quick-start

The basics

import org.tinyconfiguration.imp.basic.Configuration;
import org.tinyconfiguration.abc.data.Value;

public class QuickStart {

    public static void main(String[] args){

          // Define your configuration 
          Configuration.Builder b = new Configuration.Builder().
                  setName("ConfigurationTest").
                  setVersion("1.0.0").
                  setPathname("./").
                  setFilename("tiny-configuration.json");

          // Add some properties for your application (as many as you want)
        b.put(new Property.Builder().
                setKey("language").
                setValue("EN").
                setValidator(property -> {
                    // Extract value
                    Value e = property.getValue();
                    // Return as String
                    String data = e.asString();
                    // Test
                    return data.equalsIgnoreCase("EN") || data.equalsIgnoreCase("IT");
                }).
                setDescription("Specifies the language environment for the session").
                build());

          b.put(new Property.Builder().
                  setKey("auto-update").
                  setValue(true).
                  setDescription("Specifies if the application should regularly check for new software releases").
                  build());

          // Build your configuration instance
          Configuration cfg = b.build();

    }
}

I/O

import org.tinyconfiguration.abc.ex.*;
import org.tinyconfiguration.abc.utils.FormatType;
import org.tinyconfiguration.imp.basic.Configuration;

import java.io.IOException;

public class QuickStart {

    public static void main(String[] args){

        // Assume you have a class which returns a Configuration object
        Configuration instance = FooBar.getConfiguration();

        // Does it exists on disk?
        if (!instance.exist()) {

            // If not, let's save it
            try {
                instance.write(FormatType.JSON);
            } catch (IOException e) {
                e.printStackTrace();
            }

            // Now, it should exists
            assert(instance.exist());
        }else{
            // Seems like there is already a cfg file, let's read it
            try {
                instance.read(FormatType.JSON);
            } catch (IOException e) {
                e.printStackTrace();
            } catch (ConfigurationException e) {
                e.printStackTrace();
            } catch (PropertyException e) {
                e.printStackTrace();
            }

            // If everything is gone well, 
            // the configuration instance now hold the read values
        }

        // Do you want to delete it?
        try {
            instance.delete();
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}

You can find out more on the wiki.

Build, download & changelog

This library should not be used in a production environment.
TinyConfiguration is currently in an alpha state, it's unstable and any new update may break backward compatibility

Building the library

TinyConfiguration requires Maven 3 and JDK 8.
The generated JARs is compatible only with Java 8 and higher.

Build command:

mvn clean package

The " target " directory with javadoc documentation and all JARs will be available at the root directory.

Download

Maven

To use the package, you need to use following Maven dependency:

<dependency>
  <groupId>io.github.mrsnix</groupId>
  <artifactId>tiny-configuration</artifactId>
  <version>0.0.3</version>
</dependency>
Non-Maven

You can get the latest precompiled .jar files from this page.

Tracking changes

The full changelog and planned features are available at CHANGELOG.md,
meanwhile the following table is a really short feature-list for each release.


Version Changelog
0.1 Initial release
0.2 New arrays methods and export format
Overhauled the entire class and package hierarchy
Rewritten documentation
0.3 Simplified I/O methods
Bug fixes

Feedback

If there's anything you'd like to chat about, or you want to send me feedback about this project, you can reach me on my e-mail, feature requests are always welcome.

License

Copyright 2020 Giuseppe Baittiner

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

tinyconfiguration's People

Contributors

dependabot[bot] avatar mrsnix avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

charlesfinley

tinyconfiguration's Issues

Support custom datatype

Is your feature request related to a problem? Please describe.
At the moment TinyConfiguration supports decoding simple and homogeneous properties,
I'd like to implement a feature that supports user-defined structured data types.

Describe the solution you'd like
A solution that easily manages the encoding and decoding of user-structured data in full compliance with the respective data formats supported by TinyConfiguration

Describe alternatives you've considered
No alternative were considered and further considerations are welcome

Additional context
At the end, create a pull request on the experimental branch

If you start to work on this issue, please leave a comment I start to work on this issue,
so i can assign it to you. Do not hesitate to ask for information about the issue.

Tutorial section

I'm looking for someone who can write some little introductory tutorials to use the library. In particular, an in-depth review of the following elements is very important to me:

  • Configuration class
  • how to use I/O methods
  • fully describe all exceptions that can be derived from ConfigurationException
  • fully describe all exceptions that can be derived from PropertyException

If you start to work on this issue, please leave a comment I start to work on this issue,
so i can assign it to you. Do not hesitate to ask for information about the issue.

Support .ini format type

Is your feature request related to a problem? Please describe.
The INI file format is an informal standard for the computer and software configuration file. TinyConfiguration should be able to export, read, and validate this data format.

Describe the solution you'd like
A new handler implementation for .ini files

Describe alternatives you've considered
None

Additional context
At the end, create a pull request on the experimental branch

If you start to work on this issue, please leave a comment I start to work on this issue,
so i can assign it to you. Do not hesitate to ask for information about the issue.

Implement group properties

Is your feature request related to a problem? Please describe.
TinyConfiguration doesn't support grouping multiple properties.

Describe the solution you'd like
Implements a new configuration class specific to managing grouped properties through a key, then implements the various handlers to be exportable to JSON, XML, YAML & CSV

Describe alternatives you've considered
None

Additional context
At the end, create a pull request on the experimental branch

If you start to work on this issue, please leave a comment I start to work on this issue,
so i can assign it to you. Do not hesitate to ask for information about the issue.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.