Skip to content

Commit

Permalink
Add support to Ruby 2.6.x, to expand supported CIs.
Browse files Browse the repository at this point in the history
  • Loading branch information
rogerluan committed Aug 6, 2022
1 parent d3d2dbe commit 71289d3
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
matrix:
os: [ubuntu-latest, macos-latest]
# Due to https://github.com/actions/runner/issues/849, we have to use quotes for '3.0'
ruby: ['2.7', '3.0', '3.1', head]
ruby: ['2.6', '2.6.9', '2.7', '3.0', '3.1', head]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
matrix:
os: [ubuntu-latest, macos-latest]
# Due to https://github.com/actions/runner/issues/849, we have to use quotes for '3.0'
ruby: ['2.7', '3.0', '3.1', head]
ruby: ['2.6', '2.6.9', '2.7', '3.0', '3.1', head]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
AllCops:
TargetRubyVersion: 2.7
TargetRubyVersion: 2.6
NewCops: enable

Style/StringLiterals:
Expand Down
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.1.1
1 change: 1 addition & 0 deletions lib/arkana/encoder.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# frozen_string_literal: true

require "arkana/helpers/string"
require "arkana/helpers/enumerable"

# The encoder is responsible for finding the env vars for given keys, encoding them, and creating Secrets based on the generated data.
module Encoder
Expand Down
16 changes: 16 additions & 0 deletions lib/arkana/helpers/enumerable.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# frozen_string_literal: true

# Enumerable extensions and utilities.
module Enumerable
# NOTE: This is a backport of Ruby 2.7 filter_map. This method can be deleted when the minimum target Ruby version is 2.7
# We're not gating against redefining the method (e.g. via `unless Enumerable.method_defined? :filter_map`) because this
# would reduce the code coverage when analysing code coverage on Ruby versions >= 2.7
def filter_map
return to_enum(:filter_map) unless block_given?

each_with_object([]) do |item, res|
processed = yield(item)
res << processed if processed
end
end
end
11 changes: 9 additions & 2 deletions spec/swift_code_generator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,15 @@
let(:swift_package_dir) { File.join(config.result_path, config.import_name) }
let(:interface_swift_package_dir) { File.join(config.result_path, "#{config.import_name}Interfaces") }

def path(...)
Pathname.new(File.join(...))
# NOTE: Can't use:
# def path(...)
# Pathname.new(File.join(...))
# end
# Until the minimum target version is Ruby 2.7
def path(arg1, arg2, arg3 = nil)
arg1and2 = File.join(arg1, arg2)
return Pathname.new(arg1and2) unless arg3
return Pathname.new(File.join(arg1and2, arg3)) if arg3
end

it "should generate all necessary directories and files" do
Expand Down

0 comments on commit 71289d3

Please sign in to comment.