Skip to content

Commit 3004011

Browse files
authored
Merge pull request #120 from fatkodima/remove-eol-rubies
Remove EOL Rubies
2 parents 02b0cff + 997156b commit 3004011

6 files changed

Lines changed: 17 additions & 41 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
name: Ruby ${{ matrix.ruby }}
1111
strategy:
1212
matrix:
13-
ruby: ["2.6", "2.7", "3.0", "3.1", "3.2", "3.3"]
13+
ruby: ["3.1", "3.2", "3.3"]
1414
steps:
1515
- uses: actions/checkout@v4
1616
- uses: ruby/setup-ruby@v1

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Changelog
22

3+
- Remove EOL Rubies: < 3.1 are no longer supported (use an earlier version of the gem if needed)
4+
35
## 1.0.2 - 17-06-2024
46

57
- Add ability to profile commands via CLI @fatkodima

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ A memory profiler for Ruby
77

88
## Requirements
99

10-
Ruby(MRI) Version 2.5.0 and above.
10+
Ruby(MRI) Version 3.1.0 and above.
1111

1212
## Installation
1313

lib/memory_profiler/helpers.rb

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ class Helpers
66
def initialize
77
@gem_guess_cache = Hash.new
88
@location_cache = Hash.new { |h, k| h[k] = Hash.new.compare_by_identity }
9-
@class_name_cache = Hash.new.compare_by_identity
109
@string_cache = Hash.new
1110
end
1211

@@ -30,34 +29,17 @@ def lookup_location(file, line)
3029
end
3130

3231
KERNEL_CLASS_METHOD = Kernel.instance_method(:class)
33-
if UnboundMethod.method_defined?(:bind_call)
34-
def object_class(obj)
35-
klass = obj.class rescue nil
36-
unless Class === klass
37-
# attempt to determine the true Class when .class returns something other than a Class
38-
klass = KERNEL_CLASS_METHOD.bind_call(obj)
39-
end
40-
klass
41-
end
42-
else
43-
def object_class(obj)
44-
klass = obj.class rescue nil
45-
unless Class === klass
46-
# attempt to determine the true Class when .class returns something other than a Class
47-
klass = KERNEL_CLASS_METHOD.bind(obj).call
48-
end
49-
klass
32+
def object_class(obj)
33+
klass = obj.class rescue nil
34+
unless Class === klass
35+
# attempt to determine the true Class when .class returns something other than a Class
36+
klass = KERNEL_CLASS_METHOD.bind_call(obj)
5037
end
38+
klass
5139
end
5240

53-
if Object.name.frozen? # Since Ruby 2.7 Module#name no longer allocate a new string
54-
def lookup_class_name(klass)
55-
((klass.is_a?(Class) && klass.name) || '<<Unknown>>').to_s
56-
end
57-
else
58-
def lookup_class_name(klass)
59-
@class_name_cache[klass] ||= ((klass.is_a?(Class) && klass.name) || '<<Unknown>>').to_s
60-
end
41+
def lookup_class_name(klass)
42+
((klass.is_a?(Class) && klass.name) || '<<Unknown>>').to_s
6143
end
6244

6345
def lookup_string(obj)

memory_profiler.gemspec

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ Gem::Specification.new do |spec|
1010
spec.version = MemoryProfiler::VERSION
1111
spec.authors = ["Sam Saffron"]
1212
spec.email = ["sam.saffron@gmail.com"]
13-
spec.description = %q{Memory profiling routines for Ruby 2.5+}
14-
spec.summary = %q{Memory profiling routines for Ruby 2.5+}
13+
spec.description = %q{Memory profiling routines for Ruby 3.1+}
14+
spec.summary = %q{Memory profiling routines for Ruby 3.1+}
1515
spec.homepage = "https://github.com/SamSaffron/memory_profiler"
1616
spec.license = "MIT"
1717

1818
spec.executables = ["ruby-memory-profiler"]
1919
spec.files = Dir["README.md", "CHANGELOG.md", "LICENSE.txt", "lib/**/*", "bin/ruby-memory-profiler"]
2020

21-
spec.required_ruby_version = ">= 2.5.0"
21+
spec.required_ruby_version = ">= 3.1.0"
2222
end

test/test_reporter.rb

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -232,15 +232,7 @@ def test_no_strings_retained_report
232232
end
233233
end
234234

235-
if RUBY_VERSION < '3'
236-
# 3 times "0", 2 times for interpolated strings
237-
total_allocated = 5 * (3 + 2 + 2 + 2)
238-
unique = 20
239-
elsif RUBY_VERSION < '3.1'
240-
# 3 times "0", 2 times for short interpolated strings, 3 times for long interpolated strings
241-
total_allocated = 5 * (3 + 2 + 3 + 3)
242-
unique = 20
243-
elsif RUBY_VERSION < '3.3'
235+
if RUBY_VERSION < '3.3'
244236
# 2 times for short interpolated strings, 3 times for long interpolated strings
245237
total_allocated = 5 * (2 + 3 + 3)
246238
unique = 15
@@ -262,7 +254,7 @@ def test_symbols_report
262254
string.to_sym
263255
end
264256

265-
strings_allocated = RUBY_VERSION < '3' ? 2 : 1
257+
strings_allocated = 1
266258
assert_equal(strings_allocated + 1, results.total_allocated)
267259
assert_includes(0..1, results.total_retained)
268260
assert_equal(1, results.strings_allocated.size)

0 commit comments

Comments
 (0)