mmap-ruby 0.1.0 → 0.1.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4fb151f030e0b0589643543db0b58b68ae8cec87809e9530f5c234279086f66e
4
- data.tar.gz: dbab0de3484efd158f45735baa60d1ecc9123ca7697235aac73d09e9c6099387
3
+ metadata.gz: 0cff047cba008954ea5ddce08477b84aff540d02ffcfe7b789d5f82438922b39
4
+ data.tar.gz: 1951e7040dce367873d893ef8a828482bdcfa5336a008250b19ebda67117f5bd
5
5
  SHA512:
6
- metadata.gz: dab2685661d12266b3ad9cc8ae852bdf90077b8d76e3d378538fb0448802c8da4e46d0e27c45173517c402b8c602fa8830cd5f195e98d43960192443ae11594d
7
- data.tar.gz: eebdf6617f5c2d1ae3c69841bac49a40b3737c4ee3bd00659072c4ceec306b1aff3a882a2466737a4d18265ec5f663c3ae882eae1c0503c7720bf8720d6bf4e3
6
+ metadata.gz: f9d22bd917cc5db3d365d37231a43c4de2057417bbe86c6dde208089c2c30a6f0246c4cdf0f07a59d83698d36281b7b8b7d5b1e2688b5989ffd2e27bcdf68755
7
+ data.tar.gz: 9017018659a935304f64cd2e3ea46c9fe7f77c97b94bccac57c1da823aca049d6b036a6b0f9e9a39b08f35a858eabe4f149b746dae7ef7b3e16ef721f17a1a83
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.1.1] - 2025-11-18
4
+
5
+ - Fix precompiled binaries being included in the gem files
6
+
3
7
  ## [0.1.0] - 2025-07-19
4
8
 
5
9
  - Rewrite tenderlove/mmap with modern Ruby support
data/README.md CHANGED
@@ -53,6 +53,115 @@ p mmap.size == 5 + 2 * PAGESIZE
53
53
  File.delete("aa")
54
54
  ```
55
55
 
56
+ ```
57
+ > bundle exec ruby examples/example.rb
58
+ true
59
+ true
60
+ true
61
+ true
62
+ true
63
+ true
64
+ OK: can't change the size of a fixed map
65
+ true
66
+ true
67
+ true
68
+ true
69
+ true
70
+ true
71
+ true
72
+ true
73
+ ```
74
+
75
+ **Benchmark (Producer-Consumer IPC with validation):**
76
+
77
+ Tests scenario where one process writes 1M small messages sequentially
78
+ while another process reads and validates each message as it arrives.
79
+ Simulates real-time data processing where consumer must validate each
80
+ item individually without bulk operations or synchronization.
81
+
82
+ ```ruby
83
+ # frozen_string_literal: true
84
+
85
+ require "mmap-ruby"
86
+
87
+ puts RUBY_DESCRIPTION
88
+ puts "mmap-ruby version #{MmapRuby::VERSION}"
89
+
90
+ t1 = Time.now
91
+
92
+ reader, writer = IO.pipe
93
+
94
+ fork do
95
+ reader.close
96
+ 1_000_000.times do
97
+ writer.write("aa\n")
98
+ end
99
+ writer.write("zz\n")
100
+ writer.close
101
+ end
102
+
103
+ writer.close
104
+
105
+ line = ""
106
+ loop do
107
+ begin
108
+ line = reader.read_nonblock(3)
109
+ break if line == "zz\n"
110
+ raise "Expected 'aa\n', got '#{line}'" unless line == "aa\n"
111
+ rescue IO::WaitReadable
112
+ end
113
+ end
114
+
115
+ reader.close
116
+
117
+ t2 = Time.now
118
+ puts "Time taken for IO.pipe: #{t2 - t1} seconds"
119
+
120
+ file = File.open("example.txt", "w+")
121
+ file.write("\0" * 3_000_003)
122
+ file.close
123
+
124
+ t3 = Time.now
125
+
126
+ mmap = Mmap.new(file.path, "rw")
127
+
128
+ fork do
129
+ 1_000_000.times do |i|
130
+ mmap[i * 3, 3] = "aa\n"
131
+ end
132
+ mmap[3_000_000, 3] = "zz\n"
133
+ end
134
+
135
+ line = ""
136
+ index = 0
137
+ loop do
138
+ line = mmap[index, 3]
139
+ index += 3
140
+
141
+ if line == "\0\0\0"
142
+ next
143
+ end
144
+
145
+ break if line == "zz\n"
146
+ raise "Expected 'aa\n', got '#{line}'" unless line == "aa\n"
147
+ end
148
+
149
+ mmap.unmap
150
+
151
+ t4 = Time.now
152
+ puts "Time taken for Mmap: #{t4 - t3} seconds"
153
+
154
+ File.delete("example.txt")
155
+ ```
156
+
157
+ ```
158
+ > bundle exec ruby examples/benchmark.rb
159
+ ruby 4.0.0dev (2025-11-10T10:12:35Z master 557eec792e) +YJIT +PRISM [arm64-darwin25]
160
+ mmap-ruby version 0.1.0
161
+ Time taken for IO.pipe: 1.215664 seconds
162
+ Time taken for Mmap: 0.139914 seconds
163
+ ```
164
+
56
165
  ## Installation
57
166
 
58
167
  Install the gem and add to the application's Gemfile by executing:
data/Rakefile ADDED
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "minitest/test_task"
5
+ require "rake/extensiontask"
6
+
7
+ GEMSPEC = Gem::Specification.load("mmap-ruby.gemspec")
8
+
9
+ Minitest::TestTask.create
10
+
11
+ Rake::ExtensionTask.new("mmap_ruby", GEMSPEC) do |ext|
12
+ ext.lib_dir = "lib/mmap-ruby"
13
+ end
14
+
15
+ task build: :compile
16
+ task default: %i[clobber compile test]
@@ -73,9 +73,9 @@ typedef struct {
73
73
 
74
74
  void *(*mmap_func)(void *, size_t, int, int, int, off_t) = mmap;
75
75
 
76
+ static VALUE rb_cMmap_index(int argc, VALUE *argv, VALUE self);
76
77
  static void mmap_update(mmap_t *str, long beg, long len, VALUE val);
77
78
  static void mmap_subpat_set(VALUE obj, VALUE re, int offset, VALUE val);
78
- static VALUE rb_cMmap_index(int argc, VALUE *argv, VALUE self);
79
79
  static void mmap_realloc(mmap_t *mmap, size_t len);
80
80
  static void mmap_expandf(mmap_t *mmap, size_t len);
81
81
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MmapRuby
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mmap-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Guy Decoux
@@ -22,18 +22,14 @@ extra_rdoc_files: []
22
22
  files:
23
23
  - CHANGELOG.md
24
24
  - README.md
25
+ - Rakefile
25
26
  - ext/mmap_ruby/extconf.rb
26
27
  - ext/mmap_ruby/mmap
27
28
  - ext/mmap_ruby/mmap_ruby.c
28
29
  - ext/mmap_ruby/mmap_ruby.h
29
30
  - lib/mmap-ruby.rb
30
31
  - lib/mmap-ruby/mmap.rb
31
- - lib/mmap-ruby/mmap_ruby.bundle
32
32
  - lib/mmap-ruby/version.rb
33
- - mmap-ruby.gemspec
34
- - tmp/arm64-darwin25/stage/CHANGELOG.md
35
- - tmp/arm64-darwin25/stage/README.md
36
- - tmp/arm64-darwin25/stage/mmap-ruby.gemspec
37
33
  homepage: https://github.com/joshuay03/mmap-ruby
38
34
  licenses:
39
35
  - https://www.ruby-lang.org/en/about/license.txt
@@ -55,7 +51,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
55
51
  - !ruby/object:Gem::Version
56
52
  version: '0'
57
53
  requirements: []
58
- rubygems_version: 3.6.9
54
+ rubygems_version: 4.0.0.dev
59
55
  specification_version: 4
60
56
  summary: mmap wrapper for Ruby
61
57
  test_files: []
Binary file
data/mmap-ruby.gemspec DELETED
@@ -1,23 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "lib/mmap-ruby/version"
4
-
5
- Gem::Specification.new do |spec|
6
- spec.name = "mmap-ruby"
7
- spec.version = MmapRuby::VERSION
8
- spec.authors = ["Guy Decoux", "Aaron Patterson", "Joshua Young"]
9
- spec.email = ["ts@moulon.inra.fr", "tenderlove@github.com", "djry1999@gmail.com"]
10
-
11
- spec.summary = "mmap wrapper for Ruby"
12
- spec.homepage = "https://github.com/joshuay03/mmap-ruby"
13
- spec.license = "https://www.ruby-lang.org/en/about/license.txt"
14
- spec.required_ruby_version = ">= 3.3.0"
15
-
16
- spec.metadata["documentation_uri"] = "https://joshuay03.github.io/mmap-ruby/"
17
- spec.metadata["source_code_uri"] = spec.homepage
18
- spec.metadata["changelog_uri"] = "#{spec.homepage}/blob/main/CHANGELOG.md"
19
-
20
- spec.files = Dir["lib/**/*", "ext/**/*", "**/*.{gemspec,md,txt}"]
21
- spec.require_paths = ["lib"]
22
- spec.extensions = ["ext/mmap_ruby/extconf.rb"]
23
- end
@@ -1,5 +0,0 @@
1
- ## [Unreleased]
2
-
3
- ## [0.1.0] - 2025-07-19
4
-
5
- - Rewrite tenderlove/mmap with modern Ruby support
@@ -1,92 +0,0 @@
1
- # MmapRuby
2
-
3
- ![Version](https://img.shields.io/gem/v/mmap-ruby)
4
- ![Build](https://img.shields.io/github/actions/workflow/status/joshuay03/mmap-ruby/.github/workflows/main.yml?branch=main)
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).
@@ -1,23 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "lib/mmap-ruby/version"
4
-
5
- Gem::Specification.new do |spec|
6
- spec.name = "mmap-ruby"
7
- spec.version = MmapRuby::VERSION
8
- spec.authors = ["Guy Decoux", "Aaron Patterson", "Joshua Young"]
9
- spec.email = ["ts@moulon.inra.fr", "tenderlove@github.com", "djry1999@gmail.com"]
10
-
11
- spec.summary = "mmap wrapper for Ruby"
12
- spec.homepage = "https://github.com/joshuay03/mmap-ruby"
13
- spec.license = "https://www.ruby-lang.org/en/about/license.txt"
14
- spec.required_ruby_version = ">= 3.3.0"
15
-
16
- spec.metadata["documentation_uri"] = "https://joshuay03.github.io/mmap-ruby/"
17
- spec.metadata["source_code_uri"] = spec.homepage
18
- spec.metadata["changelog_uri"] = "#{spec.homepage}/blob/main/CHANGELOG.md"
19
-
20
- spec.files = Dir["lib/**/*", "ext/**/*", "**/*.{gemspec,md,txt}"]
21
- spec.require_paths = ["lib"]
22
- spec.extensions = ["ext/mmap_ruby/extconf.rb"]
23
- end