sys-filesystem 1.5.3 → 1.5.4

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: 9a57a854506446ec3daa4e4c9bc498d1126137ca6d0e91e3e40eb8e485754570
4
- data.tar.gz: d70416404fd036feba7471daf75dcc287a85c65682b0301959287dfd2a9cf3fb
3
+ metadata.gz: 43744bef5f8edef84a4b282c900460fd5aefb7f2d9650e5259d5b0f8a8fae97a
4
+ data.tar.gz: 6eddc2f29fb509209addc117e4a9ad4ff80e64f11cb71b9db54672dfefeba4eb
5
5
  SHA512:
6
- metadata.gz: 63fd54d82e90258625f04d9d71a53dd01b1ccce20200e556fd0920c79fd3b1ba20829b6b319a9465197da0706a9967ae191458cea0f0a28147d8d471cdadac4d
7
- data.tar.gz: 80b887d637c55b030cdeecca552a5abf844a7066d33ce109c355f45c64e20b6e91f8c6ab028f003dc95c30b827f250853975b76b2038fc677b6342a86e10edac
6
+ metadata.gz: 59800ffa5e85934f3cc4f360c6cde04168deb1d9b5790750f8584332d2fba5bdf2c8019d1e05261bd3ac71858c3488c8d80a65c2cf4fc4fb2c6db6e032cf2461
7
+ data.tar.gz: 001fb9676236d2916836e4690cfdaa8bfb838328c43e1c31fa07669f3da4bba3e814a35cc55122ca825fd7c22c90e24d8ea385bc3d9c70548363b8cfa4594def
checksums.yaml.gz.sig CHANGED
Binary file
data/CHANGES.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## 1.5.4 - 7-Sep-2025
2
+ * Added a fallback check for 64-bit Linux in case the config info doesn't
3
+ include "64" anywhere in it. Thanks go to Chris Hofstaedtler for the
4
+ report.
5
+
1
6
  ## 1.5.3 - 3-Oct-2024
2
7
  * Decided to unroll the changes in 1.5.2 because doing runtime compiler
3
8
  checks was making more people unhappy than happy, and I already had
data/README.md CHANGED
@@ -81,7 +81,7 @@ Apache-2.0
81
81
 
82
82
  ## Copyright
83
83
 
84
- (C) 2003-2024 Daniel J. Berger
84
+ (C) 2003-2025 Daniel J. Berger
85
85
  All Rights Reserved
86
86
 
87
87
  ## Warranty
data/Rakefile CHANGED
@@ -39,7 +39,10 @@ namespace :rubocop do
39
39
  end
40
40
 
41
41
  desc "Run the test suite"
42
- RSpec::Core::RakeTask.new(:spec)
42
+ RSpec::Core::RakeTask.new(:spec) do |t|
43
+ t.verbose = false
44
+ t.rspec_opts = '-f documentation'
45
+ end
43
46
 
44
47
  # Clean up afterwards
45
48
  Rake::Task[:spec].enhance do
@@ -16,7 +16,7 @@ module Sys
16
16
  # return objects of other types. Do not instantiate.
17
17
  class Filesystem
18
18
  # The version of the sys-filesystem library
19
- VERSION = '1.5.3'
19
+ VERSION = '1.5.4'
20
20
 
21
21
  # Stat objects are returned by the Sys::Filesystem.stat method. Here
22
22
  # we're adding universal methods.
@@ -16,7 +16,7 @@ module Sys
16
16
  ENV_JAVA['sun.arch.data.model'].to_i == 64
17
17
  else
18
18
  RbConfig::CONFIG['host_os'] =~ /linux/i &&
19
- (RbConfig::CONFIG['arch'] =~ /64/ || RbConfig::CONFIG['DEFS'] =~ /64/)
19
+ (RbConfig::CONFIG['arch'] =~ /64/ || RbConfig::CONFIG['DEFS'] =~ /64/ || [nil].pack('P').size == 8)
20
20
  end
21
21
  end
22
22
 
@@ -28,7 +28,7 @@ module Sys
28
28
  ENV_JAVA['sun.arch.data.model'].to_i == 64
29
29
  else
30
30
  RbConfig::CONFIG['host_os'] =~ /linux/i &&
31
- (RbConfig::CONFIG['arch'] =~ /64/ || RbConfig::CONFIG['DEFS'] =~ /64/)
31
+ (RbConfig::CONFIG['arch'] =~ /64/ || RbConfig::CONFIG['DEFS'] =~ /64/ || [nil].pack('P').size == 8)
32
32
  end
33
33
  end
34
34
 
@@ -155,7 +155,7 @@ module Sys
155
155
  ENV_JAVA['sun.arch.data.model'].to_i == 64
156
156
  else
157
157
  RbConfig::CONFIG['host_os'] =~ /linux/i &&
158
- (RbConfig::CONFIG['arch'] =~ /64/ || RbConfig::CONFIG['DEFS'] =~ /64/)
158
+ (RbConfig::CONFIG['arch'] =~ /64/ || RbConfig::CONFIG['DEFS'] =~ /64/ || [nil].pack('P').size == 8)
159
159
  end
160
160
  end
161
161
 
@@ -4,7 +4,7 @@ require 'sys-filesystem'
4
4
 
5
5
  RSpec.shared_examples Sys::Filesystem do
6
6
  example 'version number is set to the expected value' do
7
- expect(Sys::Filesystem::VERSION).to eq('1.5.3')
7
+ expect(Sys::Filesystem::VERSION).to eq('1.5.4')
8
8
  expect(Sys::Filesystem::VERSION).to be_frozen
9
9
  end
10
10
 
@@ -524,4 +524,218 @@ RSpec.describe Sys::Filesystem, :unix do
524
524
  expect(Sys::Filesystem::Functions.attached_functions[:statvfs64]).to be_nil
525
525
  end
526
526
  end
527
+
528
+ describe 'linux64? method' do
529
+ let(:functions_class) { Sys::Filesystem::Functions }
530
+
531
+ # Helper method to test linux64? with mocked config
532
+ def test_linux64_with_config(host_os, pointer_size, ruby_platform = nil, java_arch = nil)
533
+ # Mock RbConfig::CONFIG
534
+ allow(RbConfig::CONFIG).to receive(:[]).and_call_original
535
+ allow(RbConfig::CONFIG).to receive(:[]).with('host_os').and_return(host_os)
536
+
537
+ # When running under JRuby, we need to handle it differently
538
+ if RUBY_PLATFORM == 'java'
539
+ # Under JRuby, always mock ENV_JAVA since that's the path the code will take
540
+ if java_arch
541
+ # This is a JRuby-specific test
542
+ allow(ENV_JAVA).to receive(:[]).with('sun.arch.data.model').and_return(java_arch.to_s)
543
+ else
544
+ # This is meant to test regular Ruby logic, but under JRuby we need to mock ENV_JAVA
545
+ # to make it take the "regular Ruby" path by returning nil/empty
546
+ expected_arch = pointer_size == 8 ? '64' : '32'
547
+ allow(ENV_JAVA).to receive(:[]).with('sun.arch.data.model').and_return(expected_arch)
548
+ end
549
+ else
550
+ # Running under regular Ruby
551
+ # Determine arch and DEFS based on host_os for the new multi-check approach
552
+ if pointer_size == 8
553
+ # For 64-bit systems, make arch contain "64"
554
+ arch_value = host_os.include?('64') ? host_os : host_os + '64'
555
+ defs_value = '-DSOMETHING=1'
556
+ else
557
+ # For 32-bit systems, ensure neither arch nor DEFS contain "64"
558
+ arch_value = host_os.gsub(/64/, '32')
559
+ defs_value = '-DSOMETHING=1'
560
+ end
561
+
562
+ allow(RbConfig::CONFIG).to receive(:[]).with('arch').and_return(arch_value)
563
+ allow(RbConfig::CONFIG).to receive(:[]).with('DEFS').and_return(defs_value)
564
+
565
+ if ruby_platform == 'java'
566
+ # Mock RUBY_PLATFORM for JRuby tests
567
+ stub_const('RUBY_PLATFORM', 'java')
568
+
569
+ # Mock ENV_JAVA for JRuby
570
+ env_java_mock = double('ENV_JAVA')
571
+ allow(env_java_mock).to receive(:[]).with('sun.arch.data.model').and_return(java_arch.to_s)
572
+ stub_const('ENV_JAVA', env_java_mock)
573
+ else
574
+ # Mock the pack method for regular Ruby (last resort check)
575
+ packed_data = 'x' * pointer_size
576
+ allow_any_instance_of(Array).to receive(:pack).with('P').and_return(packed_data)
577
+ end
578
+ end
579
+
580
+ functions_class.send(:linux64?)
581
+ end
582
+
583
+ context 'with different Linux distributions on 64-bit architectures' do
584
+ let(:linux_distros) do
585
+ {
586
+ 'x86_64-linux-gnu' => 'Ubuntu/Debian x86_64',
587
+ 'x86_64-pc-linux-gnu' => 'Generic x86_64 Linux',
588
+ 'aarch64-linux-gnu' => 'ARM64 (Raspberry Pi 4, AWS Graviton)',
589
+ 's390x-linux-gnu' => 'IBM Z mainframe',
590
+ 'powerpc64le-linux-gnu' => 'POWER8/9 little-endian',
591
+ 'powerpc64-linux-gnu' => 'POWER8/9 big-endian',
592
+ 'mips64el-linux-gnuabi64' => 'MIPS64 little-endian',
593
+ 'alpha-linux-gnu' => 'DEC Alpha',
594
+ 'sparc64-linux-gnu' => 'SPARC64',
595
+ 'riscv64-linux-gnu' => 'RISC-V 64-bit'
596
+ }
597
+ end
598
+
599
+ it 'returns true for 64-bit Linux systems' do
600
+ linux_distros.each do |host_os, description|
601
+ result = test_linux64_with_config(host_os, 8)
602
+ expect(result).to be_truthy, "Expected linux64? to return true for #{host_os} (#{description})"
603
+ end
604
+ end
605
+ end
606
+
607
+ context 'with different Linux distributions on 32-bit architectures' do
608
+ let(:linux_32bit_distros) do
609
+ {
610
+ 'i386-linux-gnu' => '32-bit x86',
611
+ 'i486-linux-gnu' => '32-bit x86',
612
+ 'i586-linux-gnu' => '32-bit x86',
613
+ 'i686-linux-gnu' => '32-bit x86',
614
+ 'arm-linux-gnueabihf' => 'ARM 32-bit hard-float',
615
+ 'armv7l-linux-gnueabihf' => 'ARMv7 32-bit',
616
+ 'mips-linux-gnu' => 'MIPS 32-bit',
617
+ 'mipsel-linux-gnu' => 'MIPS 32-bit little-endian',
618
+ 'powerpc-linux-gnu' => 'PowerPC 32-bit',
619
+ 's390-linux-gnu' => 'IBM S/390 32-bit'
620
+ }
621
+ end
622
+
623
+ it 'returns false for 32-bit Linux systems' do
624
+ linux_32bit_distros.each do |host_os, description|
625
+ result = test_linux64_with_config(host_os, 4)
626
+ expect(result).to be_falsey, "Expected linux64? to return false for #{host_os} (#{description})"
627
+ end
628
+ end
629
+ end
630
+
631
+ context 'with non-Linux operating systems' do
632
+ let(:non_linux_os) do
633
+ {
634
+ 'darwin21.6.0' => 'macOS',
635
+ 'freebsd13.1' => 'FreeBSD',
636
+ 'openbsd7.2' => 'OpenBSD',
637
+ 'netbsd9.3' => 'NetBSD',
638
+ 'dragonfly6.4' => 'DragonFlyBSD',
639
+ 'solaris2.11' => 'Solaris',
640
+ 'aix7.2.0.0' => 'AIX',
641
+ 'mingw32' => 'Windows MSYS2',
642
+ 'cygwin' => 'Cygwin'
643
+ }
644
+ end
645
+
646
+ it 'returns false for non-Linux systems regardless of architecture' do
647
+ non_linux_os.each do |host_os, description|
648
+ # Test both 32-bit and 64-bit scenarios
649
+ [4, 8].each do |pointer_size|
650
+ result = test_linux64_with_config(host_os, pointer_size)
651
+ expect(result).to be_falsey,
652
+ "Expected linux64? to return false for #{host_os} (#{description}) with #{pointer_size * 8}-bit pointers"
653
+ end
654
+ end
655
+ end
656
+ end
657
+
658
+ context 'with JRuby on different platforms' do
659
+ it 'returns true for 64-bit Linux on JRuby' do
660
+ result = test_linux64_with_config('x86_64-linux-gnu', nil, 'java', 64)
661
+ expect(result).to be_truthy
662
+ end
663
+
664
+ it 'returns false for 32-bit Linux on JRuby' do
665
+ result = test_linux64_with_config('i386-linux-gnu', nil, 'java', 32)
666
+ expect(result).to be_falsey
667
+ end
668
+
669
+ it 'returns false for non-Linux systems on JRuby' do
670
+ result = test_linux64_with_config('darwin21.6.0', nil, 'java', 64)
671
+ expect(result).to be_falsey
672
+ end
673
+ end
674
+
675
+ context 'edge cases' do
676
+ it 'handles case-insensitive Linux detection' do
677
+ ['LINUX-gnu', 'Linux-gnu', 'linux-GNU'].each do |host_os|
678
+ result = test_linux64_with_config(host_os, 8)
679
+ expect(result).to be_truthy, "Expected linux64? to handle case-insensitive matching for #{host_os}"
680
+ end
681
+ end
682
+
683
+ it 'handles partial Linux matches in host_os string' do
684
+ ['some-linux-variant', 'embedded-linux-system', 'custom-linux-build'].each do |host_os|
685
+ result = test_linux64_with_config(host_os, 8)
686
+ expect(result).to be_truthy, "Expected linux64? to match partial Linux strings for #{host_os}"
687
+ end
688
+ end
689
+ end
690
+
691
+ context 'multi-check priority order', unless: RUBY_PLATFORM == 'java' do
692
+ it 'uses arch check first when arch contains 64' do
693
+ allow(RbConfig::CONFIG).to receive(:[]).and_call_original
694
+ allow(RbConfig::CONFIG).to receive(:[]).with('host_os').and_return('x86_64-linux-gnu')
695
+ allow(RbConfig::CONFIG).to receive(:[]).with('arch').and_return('x86_64-linux')
696
+ allow(RbConfig::CONFIG).to receive(:[]).with('DEFS').and_return('')
697
+
698
+ # Should not need to call pack method since arch check succeeds
699
+ expect_any_instance_of(Array).not_to receive(:pack)
700
+
701
+ expect(functions_class.send(:linux64?)).to be_truthy
702
+ end
703
+
704
+ it 'uses DEFS check when arch does not contain 64 but DEFS does' do
705
+ allow(RbConfig::CONFIG).to receive(:[]).and_call_original
706
+ allow(RbConfig::CONFIG).to receive(:[]).with('host_os').and_return('special-linux-gnu')
707
+ allow(RbConfig::CONFIG).to receive(:[]).with('arch').and_return('special-linux')
708
+ allow(RbConfig::CONFIG).to receive(:[]).with('DEFS').and_return('-D__LP64__=1')
709
+
710
+ # Should not need to call pack method since DEFS check succeeds
711
+ expect_any_instance_of(Array).not_to receive(:pack)
712
+
713
+ expect(functions_class.send(:linux64?)).to be_truthy
714
+ end
715
+
716
+ it 'falls back to pack method when neither arch nor DEFS contain 64' do
717
+ allow(RbConfig::CONFIG).to receive(:[]).and_call_original
718
+ allow(RbConfig::CONFIG).to receive(:[]).with('host_os').and_return('custom-linux-gnu')
719
+ allow(RbConfig::CONFIG).to receive(:[]).with('arch').and_return('custom-linux')
720
+ allow(RbConfig::CONFIG).to receive(:[]).with('DEFS').and_return('-DSOMETHING=1')
721
+
722
+ # Should call pack method as last resort
723
+ allow_any_instance_of(Array).to receive(:pack).with('P').and_return('12345678')
724
+
725
+ expect(functions_class.send(:linux64?)).to be_truthy
726
+ end
727
+
728
+ it 'returns false when all checks fail on 32-bit' do
729
+ allow(RbConfig::CONFIG).to receive(:[]).and_call_original
730
+ allow(RbConfig::CONFIG).to receive(:[]).with('host_os').and_return('custom-linux-gnu')
731
+ allow(RbConfig::CONFIG).to receive(:[]).with('arch').and_return('custom-linux')
732
+ allow(RbConfig::CONFIG).to receive(:[]).with('DEFS').and_return('-DSOMETHING=1')
733
+
734
+ # Pack method returns 4 bytes (32-bit)
735
+ allow_any_instance_of(Array).to receive(:pack).with('P').and_return('1234')
736
+
737
+ expect(functions_class.send(:linux64?)).to be_falsey
738
+ end
739
+ end
740
+ end
527
741
  end
@@ -2,7 +2,7 @@ require 'rubygems'
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = 'sys-filesystem'
5
- spec.version = '1.5.3'
5
+ spec.version = '1.5.4'
6
6
  spec.author = 'Daniel J. Berger'
7
7
  spec.email = 'djberg96@gmail.com'
8
8
  spec.homepage = 'https://github.com/djberg96/sys-filesystem'
@@ -31,7 +31,8 @@ Gem::Specification.new do |spec|
31
31
  'source_code_uri' => 'https://github.com/djberg96/sys-filesystem',
32
32
  'wiki_uri' => 'https://github.com/djberg96/sys-filesystem/wiki',
33
33
  'rubygems_mfa_required' => 'true',
34
- 'github_repo' => 'https://github.com/djberg96/sys-filesystem'
34
+ 'github_repo' => 'https://github.com/djberg96/sys-filesystem',
35
+ 'funding_uri' => 'https://github.com/sponsors/djberg96'
35
36
  }
36
37
 
37
38
  spec.description = <<-EOF
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,11 +1,10 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sys-filesystem
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.3
4
+ version: 1.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel J. Berger
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain:
11
10
  - |
@@ -35,7 +34,7 @@ cert_chain:
35
34
  ORVCZpRuCPpmC8qmqxUnARDArzucjaclkxjLWvCVHeFa9UP7K3Nl9oTjJNv+7/jM
36
35
  WZs4eecIcUc4tKdHxcAJ0MO/Dkqq7hGaiHpwKY76wQ1+8xAh
37
36
  -----END CERTIFICATE-----
38
- date: 2024-10-04 00:00:00.000000000 Z
37
+ date: 1980-01-02 00:00:00.000000000 Z
39
38
  dependencies:
40
39
  - !ruby/object:Gem::Dependency
41
40
  name: ffi
@@ -165,7 +164,7 @@ metadata:
165
164
  wiki_uri: https://github.com/djberg96/sys-filesystem/wiki
166
165
  rubygems_mfa_required: 'true'
167
166
  github_repo: https://github.com/djberg96/sys-filesystem
168
- post_install_message:
167
+ funding_uri: https://github.com/sponsors/djberg96
169
168
  rdoc_options: []
170
169
  require_paths:
171
170
  - lib
@@ -180,8 +179,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
180
179
  - !ruby/object:Gem::Version
181
180
  version: '0'
182
181
  requirements: []
183
- rubygems_version: 3.5.16
184
- signing_key:
182
+ rubygems_version: 3.6.9
185
183
  specification_version: 4
186
184
  summary: A Ruby interface for getting file system information.
187
185
  test_files:
metadata.gz.sig CHANGED
Binary file