You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

mmap-ruby

Package Overview
Dependencies
Maintainers
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mmap-ruby

0.1.0
bundlerRubygems
Version published
Maintainers
3
Created
Source

MmapRuby

Version Build

mmap wrapper for Ruby.

A modern fork of https://github.com/tenderlove/mmap.

Docs: https://joshuay03.github.io/mmap-ruby

Example:

# frozen_string_literal: true

require "mmap-ruby"

PAGESIZE = 4096

file = File.open("aa", "w")
file.write("\0" * PAGESIZE)
file.write("test")
file.write("\0" * PAGESIZE)
file.close

mmap = Mmap.new("aa", "rw", offset: 0)
p mmap.size == "test".size + (2 * PAGESIZE)
p mmap.scan(/[a-z.]+/) == ["test"]
p mmap.index("test") == PAGESIZE
p mmap.rindex("test") == PAGESIZE
p mmap.sub!(/[a-z.]+/, "toto") == mmap
p mmap.scan(/[a-z.]+/) == ["toto"]
begin
  mmap.sub!(/[a-z.]+/, "alpha")
  puts "not OK, must give an error"
rescue
  puts "OK: #$!"
end
mmap.munmap

mmap = Mmap.new("aa", "rw")
p mmap.index("toto") == PAGESIZE
p mmap.sub!(/([a-z.]+)/, "alpha") == mmap
p $& == "toto"
p $1 == "toto"
p mmap.index("toto") == nil
p mmap.index("alpha") == PAGESIZE
p mmap.size == 5 + 2 * PAGESIZE
mmap.gsub!(/\0/, "X")
p mmap.size == 5 + 2 * PAGESIZE

File.delete("aa")

Installation

Install the gem and add to the application's Gemfile by executing:

bundle add mmap-ruby

If bundler is not being used to manage dependencies, install the gem by executing:

gem install mmap-ruby

Development

After checking out the repo, run bin/setup to install dependencies. Then, run bundle exec rake 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 the created tag, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/[joshuay03]/mmap-ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.

License

The gem is available as open source under the terms of the Ruby license.

Code of Conduct

Everyone interacting in the MmapRuby project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.

FAQs

Package last updated on 19 Jul 2025

Did you know?

Socket

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.

Install

Related posts