Skip to content

Commit 1968685

Browse files
committed
*: Ruby 2.0 compatibility branch
This branch is a special compatibility branch for Ruby 2.0, 2.1, and 2.2. It represents the last version of ruby-macho to support these older Rubies.
1 parent c62f6eb commit 1968685

File tree

7 files changed

+25
-60
lines changed

7 files changed

+25
-60
lines changed

.travis.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
language: ruby
22
rvm:
3+
- 2.0
4+
- 2.1
5+
- 2.2
36
- 2.3
47
- 2.4
58
- 2.5
@@ -8,5 +11,4 @@ sudo: false
811
before_install:
912
- gem update --system # https://github.com/travis-ci/travis-ci/issues/8978
1013
script:
11-
- bundle exec rake
12-
- bundle exec rubocop -D lib/
14+
- ./run-tests

Gemfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@ group :test do
55
gem "codecov", require: false, group: :test
66
gem "minitest"
77
gem "rake"
8-
gem "rubocop"
8+
9+
gem "rubocop" if RUBY_VERSION >= "2.2"
910
end

Gemfile.lock

Lines changed: 0 additions & 48 deletions
This file was deleted.

lib/macho.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# The primary namespace for ruby-macho.
1313
module MachO
1414
# release version
15-
VERSION = "2.1.0".freeze
15+
VERSION = "1.3.0".freeze
1616

1717
# Opens the given filename as a MachOFile or FatFile, depending on its magic.
1818
# @param filename [String] the file being opened

lib/macho/fat_file.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,11 @@ def self.new_from_machos(*machos, fat64: false)
3939
# put the smaller alignments further forwards in fat macho, so that we do less padding
4040
machos = machos.sort_by(&:segment_alignment)
4141

42-
bin = +""
42+
bin = if String.instance_methods.include? :+@
43+
+""
44+
else
45+
""
46+
end
4347

4448
bin << Headers::FatHeader.new(magic, machos.size).serialize
4549
offset = Headers::FatHeader.bytesize + (machos.size * fa_klass.bytesize)

lib/macho/utils.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def self.padding_for(size, alignment)
2727
# @return [String] the null string (or empty string, for `size = 0`)
2828
# @raise [ArgumentError] if a non-positive nullpad is requested
2929
def self.nullpad(size)
30-
raise ArgumentError, "size < 0: #{size}" if size.negative?
30+
raise ArgumentError, "size < 0: #{size}" if size < 0
3131

3232
"\x00" * size
3333
end

run-tests

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/sh
1+
#!/usr/bin/env bash
22

33
die() {
44
echo "Error: $*" >&2
@@ -24,11 +24,17 @@ if ! bundle check ; then
2424
fi
2525
echo
2626

27-
# Run rubocop.
28-
echo ">> Running style enforcement."
29-
bundle exec rubocop -DES
30-
result="$?"
31-
echo
27+
read -r major minor < <(ruby -e 'puts RUBY_VERSION' | awk -F. '{ print $1, $2 }')
28+
29+
if [[ "${major}" -eq 2 && "${minor}" -ge 2 ]]; then
30+
# Run rubocop.
31+
echo ">> Running style enforcement."
32+
bundle exec rubocop -DES lib/
33+
result="$?"
34+
echo ">> Done: ${result}."
35+
else
36+
echo ">> Older ruby, skipping style enforcement."
37+
fi
3238

3339
echo ">> Done: ${result}."
3440

0 commit comments

Comments
 (0)