
Security News
/Research
Wallet-Draining npm Package Impersonates Nodemailer to Hijack Crypto Transactions
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
A dead simple decorator for Ruby
This gem groups the functionality I used to implement in every Rails project I had so I thought of packaging it into a gem and get over with it. Also, see Build your own decorator pattern.
Add this line to your application's Gemfile:
gem 'geckorate'
And then execute:
$ bundle
Or install it yourself as:
$ gem install geckorate
First, you need to add app/decorators
to your app load path:
# config/application.rb
module MyApp
class Application < Rails::Application
...
config.autoload_paths << Rails.root.join('app/decorators')
end
end
Now, define your decorator as such:
# app/decorators/post_decorator.rb
class PostDecorator < Geckorate::Decorator
def decorate(options = {})
{
title: title,
username: user.name
}.as_json
end
end
And initialize it in your controller and use it for your view:
# app/controllers/posts_contrller.rb
class PostsController < ApplicationController
def show
post = Post.find(params[:id])
decorated_post = PostDecorator.new(post).decorate
render json: { post: decorated_post }
end
end
decorate_collection(collection, options = {})
for
decorating collectionsPostDecorator.decorate_collection(Post.all)
returns an array of
decorated Post objectsoptions
hash can hold parameters to control the decoration:
:class_name
: the name of the decorator class without the Decorator
part:method
: the method to use for decorating the collectionCurrently, there are two methods for pagination; one for Kaminari
decorate_kaminari_collection(collection, options = {})
and another for will_paginate
decorate_will_paginate_collection(collection, options = {})
. The returned hash from both
methods looks like this:
{
page: 1,
per_page: 25,
total: 100,
records: [{...}, {...}]
}
After checking out the repo, run bin/setup
to install dependencies. Then, run
rake test
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/aonemd/geckorate.
The gem is available as open source under the terms of the MIT License.
FAQs
Unknown package
We found that geckorate 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
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.