Skip to content

Commit

Permalink
Merge pull request #323 from metricfu/fixes/escape-warnings
Browse files Browse the repository at this point in the history
Make metric_fu compatible with Ruby 3.0
  • Loading branch information
bronzdoc authored Nov 4, 2021
2 parents 1ffbcdf + b470400 commit d491690
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby

name: Ruby
name: Test

on:
push:
Expand All @@ -19,7 +19,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
ruby-version: ['2.5', '2.6', '2.7']
ruby-version: ['2.5', '2.6', '2.7', '3.0']

steps:
- uses: actions/checkout@v2
Expand Down
3 changes: 2 additions & 1 deletion lib/metric_fu/formatter/html.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ def open_in_browser?
# The directory path where the 'index.html' we want to open is
# stored
def show_in_browser(dir)
uri = URI.join(URI.escape("file://#{dir}/"), "index.html")
parser = URI::Parser.new
uri = URI.join(parser.escape("file://#{dir}/"), "index.html")
Launchy.open(uri) if open_in_browser?
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/metric_fu/utility.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ def rm_rf(*args)
FileUtils.rm_rf(*args)
end

def mkdir_p(*args)
FileUtils.mkdir_p(*args)
def mkdir_p(dir, **args)
FileUtils.mkdir_p(dir, **args)
end

def glob(*args)
Expand Down
6 changes: 4 additions & 2 deletions spec/metric_fu/formatter/html_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ def directory(name)
allow(MetricFu.configuration).to receive(:is_cruise_control_rb?).and_return(false)
formatter = MetricFu::Formatter::HTML.new
path = MetricFu.run_path.join(directory("output_directory"))
uri = URI.join(URI.escape("file://#{path}/"), "index.html")
parser = URI::Parser.new
uri = URI.join(parser.escape("file://#{path}/"), "index.html")
expect(Launchy).to receive(:open).with(uri)
formatter.finish
formatter.display_results
Expand Down Expand Up @@ -125,7 +126,8 @@ def directory(name)
allow(MetricFu.configuration).to receive(:is_cruise_control_rb?).and_return(false)
formatter = MetricFu::Formatter::HTML.new(output: @output)
path = MetricFu.run_path.join("#{directory('base_directory')}/#{@output}")
uri = URI.join(URI.escape("file://#{path}/"), "index.html")
parser = URI::Parser.new
uri = URI.join(parser.escape("file://#{path}/"), "index.html")
expect(Launchy).to receive(:open).with(uri)
formatter.finish
formatter.display_results
Expand Down

0 comments on commit d491690

Please sign in to comment.