
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Configster is a tidy little configuration management utility for your application.
You probably haven't heard of it.
Add this line to your application's Gemfile:
gem 'configster'
And then execute:
$ bundle
Or install it yourself as:
$ gem install configster
For most applications, you'll want to load Configster before you start loading the rest of your application. For example:
require 'configster'
Configster.load!(File.join('path', 'to', 'my_config.yml'))
You can also pass a raw hash of stuff into load!
as long as it's in the format of "ClassName" => { 'variable' => 'whatever' }
Configster.load!('MyAwesomeClass' => { :something => 'cool' })
Or load an entire directory:
Configster.load!(File.join(Rails.root, 'config', 'configster'))
Then, just include Configster in any classes you want:
class KonfiguredKlass
include Configster
end
Your class now has access to a configster
and raw_configster
function where you can query bits and pieces of your configuration.
Say you're writing a sweet application that uses HTTParty to fetch data from Twitter. You want to share this application with the world, but you don't want to hard code your credentials. Here's how you might handle that:
First, make yourself a nice little configuration file and save it to ~/my_sweet_app_credentials.yml
:
MySweetApp:
username: SweetUsername
password: SweetPassword123
Then, you'll write your application like this:
require 'configster'
Configster.load!('File.expand_path(~/my_sweet_app_credentials.yml'))
class MySweetApp
include Configster
include HTTParty
def initialize
@auth = {
:username => configster.username,
:password => configster.password
}
end
def timeline(which = :friends, options = { })
options.merge!(:basic_auth => @auth)
self.class.get("/statuses/#{which}_timeline.json", options)
end
end
You can also access the configuration more directly without the mixin by doing the following:
# Return the config as an instance of OpenStruct
Configster.config_for('MySweetApp')
# Return the config as a raw hash
Configster.raw_config_for('MySweetApp')
Now you can share your application without hard coding and/or sharing your credentials.
For more examples accessing Configster directly or using it without YAML, check the examples directory in the gem.
git checkout -b my-new-feature
)git commit -am 'Add some feature'
)git push origin my-new-feature
)FAQs
Unknown package
We found that configster 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
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.