Skip to content

Commit

Permalink
Supported Ruby 2.6
Browse files Browse the repository at this point in the history
  • Loading branch information
route committed May 12, 2022
1 parent 9d27ae0 commit ad05497
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
fail-fast: false
matrix:
gemfile: [websocket-driver-0.6.x, websocket-driver-0.7.x]
ruby: [2.7, 3.0, 3.1]
ruby: [2.6, 2.7, 3.0, 3.1]
runs-on: ubuntu-latest
env:
FERRUM_PROCESS_TIMEOUT: 20
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

Layout/FirstArrayElementIndentation:
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ a block with this page, after which the page is closed.
### Changed

- Use `Concurrent::MVar` as `execution_id` in `Ferrum::Frame`
- Min Ruby version >= 2.7
- Min Ruby version is 2.6 and 3.0 is supported
- `Ferrum::Page#bypass_csp` accepts hash as argument `enabled: true` by default
- `Ferrum::Context#has_target?` -> `Ferrum::Context#target?`
- We now start looking for Chrome first instead of Chromium, the order for checking binaries has changed
Expand Down
2 changes: 1 addition & 1 deletion ferrum.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Gem::Specification.new do |s|
"rubygems_mfa_required" => "true"
}

s.required_ruby_version = ">= 2.7.0"
s.required_ruby_version = ">= 2.6.0"

s.add_runtime_dependency "addressable", "~> 2.5"
s.add_runtime_dependency "concurrent-ruby", "~> 1.1"
Expand Down
8 changes: 5 additions & 3 deletions lib/ferrum/browser/binary.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,16 @@ def prepare_paths
end

def lazy_find(cmds)
cmds.lazy.filter_map do |cmd, path, ext|
cmd = File.expand_path("#{cmd}#{ext}", path) unless File.absolute_path?(cmd)
cmds.lazy.map do |cmd, path, ext|
absolute_path = File.absolute_path(cmd)
is_absolute_path = absolute_path == cmd
cmd = File.expand_path("#{cmd}#{ext}", path) unless is_absolute_path

next unless File.executable?(cmd)
next if File.directory?(cmd)

cmd
end
end.reject(&:nil?)
end
end
end
Expand Down
4 changes: 4 additions & 0 deletions spec/browser/binary_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ class Browser
expect(Binary.find(%w[bin4])).to eq(bin4_exe)
end

it "finds binary with absolute path" do
expect(Binary.find(bin4_exe)).to eq(bin4_exe)
end

it "finds binary without ext" do
ENV["PATHEXT"] = ".com;.exe"

Expand Down

0 comments on commit ad05497

Please sign in to comment.