
Security News
Rspack Introduces Rslint, a TypeScript-First Linter Written in Go
Rspack launches Rslint, a fast TypeScript-first linter built on typescript-go, joining in on the trend of toolchains creating their own linters.
A DSL for describing and running the row-level processing of the records in the database (eg. anonymization)
Add this line to your application's Gemfile:
gem 'remont'
And then execute:
$ bundle
Or install it yourself as:
$ gem install remont
Add config/initializers/remont.rb
Remont.setup do |config|
config.process_timestamp_attribute = :processed_at
end
Option | Default value | Description |
---|---|---|
process_timestamp_attribute | nil | processing status attribute identifier |
On successful record processing, process_timestamp_attribute
on the record will be set to the current processing time (Time.now.getlocal
).
In the following example, the intention is to simulate anonymization of the users
and orders
table.
# config/initializers/remont.rb
Remont.setup do |config|
config.process_timestamp_attribute = :anonymized_at
end
# db/anonymize.rb
schema model: User do
attribute(:email) { 'user@example.com' }
end
schema model: Order do
attribute(:billing_address) { '23 Wall Street, NY' }
end
remont
rake task with the path to the processing scriptbundle exec rake "remont[db/anonymize.rb]"
Passing the script path to the rake task is mandatory.
Running the rake task would result in updating email
(and anonymized_at
) column for each row in the users
table, and billing_address
column for each row in the orders
table.
Defines database table hosting the rows to be processed. The initial dataset is defined through the model
option in the schema
method. model
value must be a subclass of the ActiveRecord::Base
.
schema model: Order do
end
Scope of the data that will be processed is controlled
scope
option in the schema
methodscope
within the schema
block# skip admin records
schema model: User, scope: { |scope| scope.where.not(role: :admin) } do
end
schema model: Order do
# process only active records
scope { |scope| scope.where(status: :active) }
end
Library supports an option to store the processing end time of a record. Enable the behavior by configuring a processing status attribute identifier for the schema. Configure the attribute identifier
Remont::Config#process_timestamp_attribute
, for all schemas)schema model: User, process_timestamp_attribute: :anonymized_at do
end
schema model: Order do
with_process_timestamp_attribute :anonymized_at
end
Set process status attribute to nil
to disable the behavior.
In some cases, it's desirable to skip already processed records. You can enable this behavior by declaring without_processed
within the schema
block. When declared, the processing dataset query will be extended with a condition that excludes already processed records.
schema model: User do
without_processed
# ...
end
Configure processing status attribute before declaring the without_processed
. An error will be raised otherwise.
Custom pre-processing or post-processing behavior can be declared using before
and after
callbacks.
schema model: User do
before { |record| Rails.logger.info("Started processing: #{record.id}") }
after { |record| Rails.logger.info("Finished processing: #{record.id}") }
end
Attributes are processed using processors (an object which responds to the call
method). The processor can be defined either as a block or with the :using
option passed to the attribute
method.
require 'securerandom'
class CachedNick
def initialize
@cache = Hash.new { |hash, nick| hash[nick] = SecureRandom.uuid }
end
def call(nick, _record)
@cache[nick]
end
end
schema model: User do
attribute(:email) { |email, record| "#{record.id}-#{email}" }
attribute(:nickname, using: CachedNick.new)
end
After checking out the repo, run bin/setup
to install dependencies. Then, run bundle exec rspec
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/infinum/remont. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
The gem is available as open source under the terms of the MIT License.
Everyone interacting in the Remont project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.
FAQs
Unknown package
We found that remont 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
Rspack launches Rslint, a fast TypeScript-first linter built on typescript-go, joining in on the trend of toolchains creating their own linters.
Security News
Hacker Demonstrates How Easy It Is To Steal Data From Popular Password Managers
Security News
Oxlint’s new preview brings type-aware linting powered by typescript-go, combining advanced TypeScript rules with native-speed performance.