mmap-ruby 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CHANGELOG.md +5 -0
- data/README.md +92 -0
- data/ext/mmap_ruby/extconf.rb +10 -0
- data/ext/mmap_ruby/mmap +0 -0
- data/ext/mmap_ruby/mmap_ruby.c +2804 -0
- data/ext/mmap_ruby/mmap_ruby.h +21 -0
- data/lib/mmap-ruby/mmap.rb +49 -0
- data/lib/mmap-ruby/mmap_ruby.bundle +0 -0
- data/lib/mmap-ruby/version.rb +5 -0
- data/lib/mmap-ruby.rb +6 -0
- data/mmap-ruby.gemspec +23 -0
- data/tmp/arm64-darwin25/stage/CHANGELOG.md +5 -0
- data/tmp/arm64-darwin25/stage/README.md +92 -0
- data/tmp/arm64-darwin25/stage/mmap-ruby.gemspec +23 -0
- metadata +61 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 4fb151f030e0b0589643543db0b58b68ae8cec87809e9530f5c234279086f66e
|
4
|
+
data.tar.gz: dbab0de3484efd158f45735baa60d1ecc9123ca7697235aac73d09e9c6099387
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: dab2685661d12266b3ad9cc8ae852bdf90077b8d76e3d378538fb0448802c8da4e46d0e27c45173517c402b8c602fa8830cd5f195e98d43960192443ae11594d
|
7
|
+
data.tar.gz: eebdf6617f5c2d1ae3c69841bac49a40b3737c4ee3bd00659072c4ceec306b1aff3a882a2466737a4d18265ec5f663c3ae882eae1c0503c7720bf8720d6bf4e3
|
data/CHANGELOG.md
ADDED
data/README.md
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
# MmapRuby
|
2
|
+
|
3
|
+

|
4
|
+

|
5
|
+
|
6
|
+
[`mmap`](https://en.wikipedia.org/wiki/Mmap) wrapper for Ruby.
|
7
|
+
|
8
|
+
A modern fork of https://github.com/tenderlove/mmap.
|
9
|
+
|
10
|
+
**Docs:** https://joshuay03.github.io/mmap-ruby
|
11
|
+
|
12
|
+
**Example:**
|
13
|
+
|
14
|
+
```ruby
|
15
|
+
# frozen_string_literal: true
|
16
|
+
|
17
|
+
require "mmap-ruby"
|
18
|
+
|
19
|
+
PAGESIZE = 4096
|
20
|
+
|
21
|
+
file = File.open("aa", "w")
|
22
|
+
file.write("\0" * PAGESIZE)
|
23
|
+
file.write("test")
|
24
|
+
file.write("\0" * PAGESIZE)
|
25
|
+
file.close
|
26
|
+
|
27
|
+
mmap = Mmap.new("aa", "rw", offset: 0)
|
28
|
+
p mmap.size == "test".size + (2 * PAGESIZE)
|
29
|
+
p mmap.scan(/[a-z.]+/) == ["test"]
|
30
|
+
p mmap.index("test") == PAGESIZE
|
31
|
+
p mmap.rindex("test") == PAGESIZE
|
32
|
+
p mmap.sub!(/[a-z.]+/, "toto") == mmap
|
33
|
+
p mmap.scan(/[a-z.]+/) == ["toto"]
|
34
|
+
begin
|
35
|
+
mmap.sub!(/[a-z.]+/, "alpha")
|
36
|
+
puts "not OK, must give an error"
|
37
|
+
rescue
|
38
|
+
puts "OK: #$!"
|
39
|
+
end
|
40
|
+
mmap.munmap
|
41
|
+
|
42
|
+
mmap = Mmap.new("aa", "rw")
|
43
|
+
p mmap.index("toto") == PAGESIZE
|
44
|
+
p mmap.sub!(/([a-z.]+)/, "alpha") == mmap
|
45
|
+
p $& == "toto"
|
46
|
+
p $1 == "toto"
|
47
|
+
p mmap.index("toto") == nil
|
48
|
+
p mmap.index("alpha") == PAGESIZE
|
49
|
+
p mmap.size == 5 + 2 * PAGESIZE
|
50
|
+
mmap.gsub!(/\0/, "X")
|
51
|
+
p mmap.size == 5 + 2 * PAGESIZE
|
52
|
+
|
53
|
+
File.delete("aa")
|
54
|
+
```
|
55
|
+
|
56
|
+
## Installation
|
57
|
+
|
58
|
+
Install the gem and add to the application's Gemfile by executing:
|
59
|
+
|
60
|
+
```bash
|
61
|
+
bundle add mmap-ruby
|
62
|
+
```
|
63
|
+
|
64
|
+
If bundler is not being used to manage dependencies, install the gem by executing:
|
65
|
+
|
66
|
+
```bash
|
67
|
+
gem install mmap-ruby
|
68
|
+
```
|
69
|
+
|
70
|
+
## Development
|
71
|
+
|
72
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bundle exec rake` to run the tests.
|
73
|
+
You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
74
|
+
|
75
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the
|
76
|
+
version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version,
|
77
|
+
push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
78
|
+
|
79
|
+
## Contributing
|
80
|
+
|
81
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[joshuay03]/mmap-ruby. This project is
|
82
|
+
intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the
|
83
|
+
[code of conduct](https://github.com/[joshuay03]/mmap-ruby/blob/main/CODE_OF_CONDUCT.md).
|
84
|
+
|
85
|
+
## License
|
86
|
+
|
87
|
+
The gem is available as open source under the terms of the [Ruby license](https://www.ruby-lang.org/en/about/license.txt).
|
88
|
+
|
89
|
+
## Code of Conduct
|
90
|
+
|
91
|
+
Everyone interacting in the MmapRuby project's codebases, issue trackers, chat rooms and mailing lists is expected to
|
92
|
+
follow the [code of conduct](https://github.com/[joshuay03]/mmap-ruby/blob/main/CODE_OF_CONDUCT.md).
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "mkmf"
|
4
|
+
|
5
|
+
# Makes all symbols private by default to avoid unintended conflict
|
6
|
+
# with other gems. To explicitly export symbols you can use RUBY_FUNC_EXPORTED
|
7
|
+
# selectively, or entirely remove this flag.
|
8
|
+
append_cflags("-fvisibility=hidden")
|
9
|
+
|
10
|
+
create_makefile("mmap_ruby/mmap_ruby")
|
data/ext/mmap_ruby/mmap
ADDED
File without changes
|