Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
DeclarativeGrid is a simple, flexible and extensible datagrid/table generator.
In Version 0.1.0, block-style instantization is formally deprecated, it will be removed on the next release (0.2.0)
grid = MemberGrid.new { records }
Please pass records as an argument instead
grid = MemberGrid.new(records)
in models/member_grid.rb
class MemberGrid < DeclarativeGrid::Base
# Columns
#
column(:name)
column(:birthday) {|r| (r.birthdate) }
column(:gender, header: 'Sex')
# Renderers
#
# with builtin render class: DeclarativeGrid::Renderers::Csv
renderer :csv
#
# with builtin render class: DeclarativeGrid::Renderers::Html
renderer :html
#
# with selected columns
renderer :csv_selected, class: :csv, columns: [:gender, :name]
#
# with custom renderer class
renderer :xls, class: XlsRenderer
#
end
in member.rb
class Member < Struct.new(:name, :gender, :birthdate)
end
example code:
members = [
Member.new('Adam Jensen', 'Male', Date.new(1993,3,9)),
Member.new('Altaïr Ibn-La\'Ahad', 'Male', Date.new(1165,1,11)),
Member.new('Ezio Auditore da Firenze', 'Male', Date.new(1459,6,24)),
Member.new('Desmond Miles', 'Male', Date.new(1987,3,13))
]
@grid = MemberGrid.new(members)
puts "== sample 1 =="
puts @grid.renderer(:csv).to_string
puts "== sample 2 =="
puts @grid.renderer(:csv_selected).to_string
puts "== sample 3 =="
io = StringIO.new
@grid.renderer(:csv_selected).perform(io)
puts io.string
result:
== sample 1 ==
Name,Birthday,Sex
Adam Jensen,1993-03-09,Male
Altaïr Ibn-La'Ahad,1165-01-11,Male
Ezio Auditore da Firenze,1459-06-24,Male
Desmond Miles,1987-03-13,Male
== sample 2 ==
Sex,Name
Male,Adam Jensen
Male,Altaïr Ibn-La'Ahad
Male,Ezio Auditore da Firenze
Male,Desmond Miles
== sample 3 ==
Sex,Name
Male,Adam Jensen
Male,Altaïr Ibn-La'Ahad
Male,Ezio Auditore da Firenze
Male,Desmond Miles
Add this line to your application's Gemfile:
gem 'declarative_grid'
And then execute:
$ bundle
Or install it yourself as:
$ gem install declarative_grid
If you want to work with ActiveRecord, like this:
grid = MemberGrid.new(Enumerator.new(Member.where(is_good: true), :find_each))
If you want shorter code:
grid = MemberGrid.new Member
or
grid = MemberGrid.new Member.where(is_good: true)
The library will automatically wrap the records with Enumerator, preventing from massive flooding.
Note that ActiveRecord#all (prior to 4.0) returns an Array instead of ActiveRecord::Relation. Please avoid using it.
$ rake spec
git checkout -b my-new-feature
)git commit -am 'Add some feature'
)git push origin my-new-feature
)FAQs
Unknown package
We found that declarative_grid 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.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.