
Security News
Astral Launches pyx: A Python-Native Package Registry
Astral unveils pyx, a Python-native package registry in beta, designed to speed installs, enhance security, and integrate deeply with uv.
Configa makes it easier to use multi environment YAML configs.
Inspired by prepor
Add this line to your application's Gemfile:
gem 'configa'
And then execute:
$ bundle
Or install it yourself as:
$ gem install configa
config_file_path = File.expand_path("../config/config.yml", __FILE__)
config = Configa.new(config_file_path)
config.mysql.host
#=> "localhost"
config.development.mongodb.user
#=> "pedro"
config.development.mongodb(:user, :password)
#=> ["pedro", "password"]
config.development.mongodb(:user, :password, hash: true)
#=> { user: "pedro", password: "password"}
config.production.root.password
#=> Error is raised ;)
config = Configa.new(config_file_path, env: :development)
config.mongodb.user
#=> "pedro"
You can specify in your config file many environments without duplication
mysql:
adapter: mysql
encoding: utf8
host: localhost
username: root
development:
mysql:
database: mysql_dev
test:
mysql:
database: mysql_test
production:
mysql:
username: admin
password: strongone
So, it will create mysql
"node" which will be shared between all of environments:
config.development.mysql.username
#=> "root"
config.production.mysql.username
#=> "admin"
config.production.mysql(:username, :host)
#=> ["admin", "localhost"]
Also you can share base templates between multiple nodes of one environment
mysql:
adapter: mysql
encoding: utf8
host: localhost
username: root
development:
databases:
users:
mysql:
database: users_dev
blogs:
mysql:
database: blogs_dev
config.development.databases.users.mysql.database
#=> "users_dev"
You can create development.yml
, staging.yml
or any other file, put it into the same folder as a base config file and Configa will automatically fetch and load it. Also you can use cascade templates. For example in following example you can define tarantool
namespace, wich will be inherited by tarantool
namespace in "development" env.
# config.yml
mysql:
adapter: mysql
encoding: utf8
host: localhost
username: root
tarantool:
host: localhost
port: 13013
type: :block
# development.yml
mysql:
database: my_database
tarantool:
type: :em
videos:
tarantool:
space: 1
users:
tarantool:
space: 2
config = Configa.new("config.yml")
config.development.mysql.database
#=> "my_database"
config.development.mysql.username
#=> "root"
config.videos.tarantool.space
#=> 1
config.videos.tarantool.type
#=> :em
All properties that defined higher in the tree will rewrite root properties:
database:
adapter: sqlite
user: root
development:
database:
db: dev_sqlite
staging:
database:
adapter: mysql
internal_servers:
database:
db: internal_db
external_servers:
database:
db: external_db
user: external_root
So you can see how for whole staging node we rewrite database adapter, then for each subnode we specify other properties.
Also you can define default environment:
dev = Configa.new(path, env: development)
all = Configa.new(path)
dev.mysql
# the same as
all.development.mysql
dev.production.mysql
# will raise an error
all.production.mysql
# will return mysql for production
git checkout -b my-new-feature
)git commit -am 'Added some feature'
)git push origin my-new-feature
)FAQs
Unknown package
We found that configa demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Astral unveils pyx, a Python-native package registry in beta, designed to speed installs, enhance security, and integrate deeply with uv.
Security News
The Latio podcast explores how static and runtime reachability help teams prioritize exploitable vulnerabilities and streamline AppSec workflows.
Security News
The latest Opengrep releases add Apex scanning, precision rule tuning, and performance gains for open source static code analysis.