
Security News
Follow-up and Clarification on Recent Malicious Ruby Gems Campaign
A clarification on our recent research investigating 60 malicious Ruby gems.
ConfigX provides you with a simple DSL to configure classes, modules and objects. The interface is kind of like attr accessors and class attr accessors on steroids. It comes with a few useful features.
to_h
on a config to get your config values in a hashThe configurable
method builds the interface for your configuration at parse time. All necessary methods are defined
into modules that are then used to extend your classes and objects before you actually use them in your application.
Add this line to your application's Gemfile:
gem 'config_x'
And then execute:
$ bundle
Or install it yourself as:
$ gem install config_x
configurable :class
class Client
extend ConfigX
configurable :class do
attr :env, accessor: true do
attr :url, default: 'www.example.com'
attr :api_key, memoize: true
end
end
end
Client.config.env.api_key { SecureRandom.hex }
p Client.config.env.api_key # 2594c07670bd16dfdd48f9874d190f80
p Client.config.env.url # www.example.com"
p Client.config.to_h # {:env=>{:url=>"www.example.com", :api_key=>"2594c07670bd16dfdd48f9874d190f80"}}
configurable :instance
class Client
extend ConfigX
configurable :instance do
attr :env, accessor: true do
attr :url, default: 'www.example.com'
attr :api_key, memoize: true
attr :timeout, instance_exec: true
end
end
def timeout
5
end
end
client = Client.new
client.config.env.api_key { SecureRandom.hex }
client.config.env.timeout { timeout } # or client.config.env.timeout { |client| client.timeout }
p client.config.env.api_key # 2594c07670bd16dfdd48f9874d190f80
p client.config.env.url # www.example.com"
p client.config.env.timeout # 5
p client.config.to_h # {:env=>{:url=>"www.example.com", :api_key=>"2594c07670bd16dfdd48f9874d190f80", :timeout=>5}}
configure & configure!
You can use the configure
method to assign values and configure!
will freeze the underlying hash so that values are
safe from being overwritten. Blocks cannot be memoized when you use configure!
client = Client.new
client.configure! do |config|
config.env.api_key = '123123'
config.env.timeout = 5
end
For further examples just have a look at the specs.
After checking out the repo, run bin/setup
to install dependencies. Then, run rake spec
to run the tests. You can also run bin/console
for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install
. To release a new version, update the version number in version.rb
, and then run bundle exec rake release
, which will create a git tag for the version, push git commits and tags, and push the .gem
file to rubygems.org.
Bug reports and pull requests are welcome on GitHub at https://github.com/Andreas Robecke/config_x.
FAQs
Unknown package
We found that config_x 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
A clarification on our recent research investigating 60 malicious Ruby gems.
Security News
ESLint now supports parallel linting with a new --concurrency flag, delivering major speed gains and closing a 10-year-old feature request.
Research
/Security News
A malicious Go module posing as an SSH brute forcer exfiltrates stolen credentials to a Telegram bot controlled by a Russian-speaking threat actor.