
Security News
CISA’s 2025 SBOM Guidance Adds Hashes, Licenses, Tool Metadata, and Context
CISA’s 2025 draft SBOM guidance adds new fields like hashes, licenses, and tool metadata to make software inventories more actionable.
This gem helps you manage actions with collections in a chainable way. The idea is that you use your favorite collection actions like filter or map with procs, blocks or lambdas that receive one or more parameters. Also you get a paginate method for free ;)
Add this line to your application's Gemfile:
gem 'firuta'
Or install it yourself as:
$ gem install firuta
After installing the gem, you can use it anywhere:
require 'firuta'
# First define your reusable procs or lambdas
BETWEEN = ->(element, min, max) { element > min && element < max }
MULTIPLY_BY = ->(element, number) { element * number }
NATURAL_SORT = ->(x, y) { x <=> y }
IDENTITY = ->(element) { element }
# Then create a collection to apply your actions
collection = [10, 2, 3, 4, 5, 1, 10, -1]
# Then define your reusable applier
applier = Firuta.new
.filter(BETWEEN, with: [0, 10])
.map(MULTIPLY_BY, with: 3)
.sort(NATURAL_SORT)
.uniq(IDENTITY)
# Finally apply your actions
puts applier
.apply(collection)
.to_s #=> [3, 6, 9, 12, 15]
# Then you can change the collection and reuse everything
collection = [100, 2, 30, 4, -5, 1, 10, -1]
puts applier
.apply(collection)
.to_s #=> [3, 6, 12]
# Also paginate the collection
puts applier
.paginate(with: { page: 1, page_size: 2 })
.apply(collection)
.to_s #=> [12]
All the Firuta actions can receive parameters and blocks in different ways. You can use Procs or lambdas, choose the one you like the most:
collection = [1, 2, 3]
EXAMPLE_LAMBDA = ->(element, a, b, c) { element }
PARAMS = ['a', 'b', 'c']
puts Firuta.new
.filter(EXAMPLE_LAMBDA, PARAMS)
.filter(EXAMPLE_LAMBDA, with: PARAMS)
.filter(function: EXAMPLE_LAMBDA, with: PARAMS)
.filter(with: PARAMS) { |element, a, b, c| element }
.apply(collection)
.to_s #=> [1, 2, 3]
The find
and reduce
actions are considered final (because they transform the collection into something else). Those actions need to be defined at the end of the chain or else an exception will be raised.
require 'firuta'
BETWEEN = ->(element, min, max) { element > min && element < max }
REDUCER = ->(acc, element) { acc + element }
collection = [10, 2, 3, 4, 5, 1, 10, -1]
puts Firuta.new
.filter(BETWEEN, with: [0, 10])
.reduce(REDUCER, with: 0)
.apply(collection) #=> 15
begin
puts Firuta.new
.reduce(REDUCER, with: 0)
.filter(BETWEEN, with: [0, 10]) # Raises
.apply(collection)
rescue Firuta::Errors::MoreThanOneTerminalCommand => e
puts e #=> Firuta::Errors::MoreThanOneTerminalCommand
end
git checkout -b my-new-feature
)git commit -am 'Add some feature'
)rubocop -R lib spec --format simple
)bundle exec rspec
)git push origin my-new-feature
)FAQs
Unknown package
We found that firuta 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
CISA’s 2025 draft SBOM guidance adds new fields like hashes, licenses, and tool metadata to make software inventories more actionable.
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.