GithubHelp home page GithubHelp logo

ruby-hocon's Introduction

Build Status

ruby-hocon

This is a port of the Typesafe Config library to Ruby.

The library provides Ruby support for the HOCON configuration file format.

At present, it supports supports parsing and modification of existing HOCON/JSON files via the ConfigFactory class and the ConfigValueFactory class, and rendering parsed config objects back to a String. It also supports the parsing and modification of HOCON/JSON files via ConfigDocumentFactory. PLEASE NOTE this project is in an experimental state, and in some cases may not work properly, so please be wary when using it. If you find a problem, feel free to open a github issue.

The implementation is intended to be as close to a line-for-line port as the two languages allow, in hopes of making it fairly easy to port over new changesets from the Java code base over time.

Basic Usage

gem install hocon
require 'hocon/config_factory'

conf = Hocon::ConfigFactory.parse_file("myapp.conf")
conf_map = conf.root.unwrapped

To use the ConfigDocument API

require 'hocon/parser/config_document_factory'
require 'hocon/config_value_factory'

# The below 4 variables will all be ConfigDocument instances
doc = Hocon::Parser::ConfigDocumentFactory.parse_file("myapp.conf")
doc2 = doc.set_value("a.b", "[1, 2, 3, 4, 5]")
doc3 = doc.remove_value("a")
doc4 = doc.set_config_value("a.b", Hocon::ConfigValueFactory.from_any_ref([1, 2, 3, 4, 5]))

doc_has_value = doc.has_value?("a") # returns boolean
orig_doc_text = doc.render # returns string

Testing

bundle install
bundle exec rspec spec

Unsupported Features

This supports many of the same things as the Java library, but there are some notable exceptions. Unsupported features include:

  • Non file includes
  • Loading resources from the class path or URLs
  • Properties files
  • Parsing anything other than files and strings
  • Duration and size settings
  • Java system properties

ruby-hocon's People

Contributors

cprice404 avatar mslilah avatar jpinsonault avatar kevincorcoran avatar dakatsuka avatar jmccure avatar rlinehan avatar

Watchers

James Cloos avatar  avatar

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.