Socket
Book a DemoInstallSign in
Socket

strict_konf

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

strict_konf

0.0.1
bundlerRubygems
Version published
Maintainers
1
Created
Source

StrictKonf

Extend Konf with required keys

Build Status

Rationale

It's very annoying when configuration files get out of sync, i.e.: you have a developer's config.yml that is ignored, config.yml.sample checked-in and another config.yml on the production box. Problems arise when the developer, when adding a new key, forgets to update .sample file or the production config and the code & configuration is out of sync.

This gem extends Konf to fail when there is a discrepancy between the required list of keys and the actual configuration file content.

Example

Based on https://github.com/GBH/konf#usage

development:
  name: Dev
  email: dev@test.test

You can read the file like usual with Konf:

config = StrictKonf.new('configuration.yml', 'development', [:name, :email])
config.name # => Dev

It will fail when you have too much or too few keys in your configuration:

StrictKonf.new('configuration.yml', 'development', [:name])                # raises UnknownKeys error
StrictKonf.new('configuration.yml', 'development', [:name, :email, :role]) # raises NotFound error

It also supports nested hashes. We can pass nil to start from the root of the hash:

StrictKonf.new('configuration.yml', nil, development: [:name, :email])

Installation

Add this line to your application's Gemfile:

gem 'strict_konf', github: 'wojtekmach/strict_konf'

And then execute:

$ bundle

FAQs

Package last updated on 06 May 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.