Skip to content

Commit 9bceeca

Browse files
authored
Merge pull request #5 from VitalConnectInc/bug/2-ruby3-fixes
Bug/2 ruby3 fixes
2 parents 1f24002 + a8b4b95 commit 9bceeca

File tree

6 files changed

+212
-4
lines changed

6 files changed

+212
-4
lines changed

.github/workflows/supported.yml

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Supported Ruby Matrix
2+
3+
env:
4+
K_SOUP_COV_DO: false
5+
6+
on:
7+
push:
8+
branches:
9+
- 'master'
10+
tags:
11+
- '!*' # Do not execute on tags
12+
pull_request:
13+
branches:
14+
- '*'
15+
# Allow manually triggering the workflow.
16+
workflow_dispatch:
17+
18+
permissions:
19+
contents: read
20+
21+
# Cancels all previous workflow runs for the same branch that have not yet completed.
22+
concurrency:
23+
# The concurrency group contains the workflow name and the branch name.
24+
group: "${{ github.workflow }}-${{ github.ref }}"
25+
cancel-in-progress: true
26+
27+
jobs:
28+
test:
29+
name: Specs - Ruby ${{ matrix.ruby }}${{ matrix.name_extra || '' }}
30+
if: "!contains(github.event.commits[0].message, '[ci skip]') && !contains(github.event.commits[0].message, '[skip ci]')"
31+
env: # $BUNDLE_GEMFILE must be set at the job level, so it is set for all steps
32+
BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}.gemfile
33+
runs-on: ubuntu-latest
34+
strategy:
35+
matrix:
36+
include:
37+
- ruby: "3.3"
38+
rubygems: latest
39+
bundler: latest
40+
gemfile: vanilla
41+
- ruby: "3.2"
42+
rubygems: latest
43+
bundler: latest
44+
gemfile: vanilla
45+
#- Ruby 3.1 tests are run by coverage.yml
46+
steps:
47+
- name: Checkout
48+
uses: actions/checkout@v4
49+
- name: Setup Ruby & RubyGems
50+
uses: ruby/setup-ruby@v1
51+
with:
52+
ruby-version: "${{ matrix.ruby }}"
53+
rubygems: "${{ matrix.rubygems }}"
54+
bundler: "${{ matrix.bundler }}"
55+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
56+
- name: Run tests
57+
run: bundle exec rake test

Gemfile

+1
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ source 'https://rubygems.org'
44
gemspec
55

66
gem 'rake'
7+
gem 'byebug'

bin/bundle

+109
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
#!/usr/bin/env ruby
2+
# frozen_string_literal: true
3+
4+
#
5+
# This file was generated by Bundler.
6+
#
7+
# The application 'bundle' is installed as part of a gem, and
8+
# this file is here to facilitate running it.
9+
#
10+
11+
require "rubygems"
12+
13+
m = Module.new do
14+
module_function
15+
16+
def invoked_as_script?
17+
File.expand_path($0) == File.expand_path(__FILE__)
18+
end
19+
20+
def env_var_version
21+
ENV["BUNDLER_VERSION"]
22+
end
23+
24+
def cli_arg_version
25+
return unless invoked_as_script? # don't want to hijack other binstubs
26+
return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update`
27+
bundler_version = nil
28+
update_index = nil
29+
ARGV.each_with_index do |a, i|
30+
if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN
31+
bundler_version = a
32+
end
33+
next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/
34+
bundler_version = $1
35+
update_index = i
36+
end
37+
bundler_version
38+
end
39+
40+
def gemfile
41+
gemfile = ENV["BUNDLE_GEMFILE"]
42+
return gemfile if gemfile && !gemfile.empty?
43+
44+
File.expand_path("../Gemfile", __dir__)
45+
end
46+
47+
def lockfile
48+
lockfile =
49+
case File.basename(gemfile)
50+
when "gems.rb" then gemfile.sub(/\.rb$/, ".locked")
51+
else "#{gemfile}.lock"
52+
end
53+
File.expand_path(lockfile)
54+
end
55+
56+
def lockfile_version
57+
return unless File.file?(lockfile)
58+
lockfile_contents = File.read(lockfile)
59+
return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/
60+
Regexp.last_match(1)
61+
end
62+
63+
def bundler_requirement
64+
@bundler_requirement ||=
65+
env_var_version ||
66+
cli_arg_version ||
67+
bundler_requirement_for(lockfile_version)
68+
end
69+
70+
def bundler_requirement_for(version)
71+
return "#{Gem::Requirement.default}.a" unless version
72+
73+
bundler_gem_version = Gem::Version.new(version)
74+
75+
bundler_gem_version.approximate_recommendation
76+
end
77+
78+
def load_bundler!
79+
ENV["BUNDLE_GEMFILE"] ||= gemfile
80+
81+
activate_bundler
82+
end
83+
84+
def activate_bundler
85+
gem_error = activation_error_handling do
86+
gem "bundler", bundler_requirement
87+
end
88+
return if gem_error.nil?
89+
require_error = activation_error_handling do
90+
require "bundler/version"
91+
end
92+
return if require_error.nil? && Gem::Requirement.new(bundler_requirement).satisfied_by?(Gem::Version.new(Bundler::VERSION))
93+
warn "Activating bundler (#{bundler_requirement}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_requirement}'`"
94+
exit 42
95+
end
96+
97+
def activation_error_handling
98+
yield
99+
nil
100+
rescue StandardError, LoadError => e
101+
e
102+
end
103+
end
104+
105+
m.load_bundler!
106+
107+
if m.invoked_as_script?
108+
load Gem.bin_path("bundler", "bundle")
109+
end

bin/console

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/env ruby
2+
# frozen_string_literal: true
3+
4+
require "bundler/setup"
5+
require "ruby-openid"
6+
7+
# You can add fixtures and/or initialization code here to make experimenting
8+
# with your gem easier. You can also use a different console, if you like.
9+
10+
require "irb"
11+
IRB.start(__FILE__)

bin/rake

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env ruby
2+
# frozen_string_literal: true
3+
4+
#
5+
# This file was generated by Bundler.
6+
#
7+
# The application 'rake' is installed as part of a gem, and
8+
# this file is here to facilitate running it.
9+
#
10+
11+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
12+
13+
bundle_binstub = File.expand_path("bundle", __dir__)
14+
15+
if File.file?(bundle_binstub)
16+
if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
17+
load(bundle_binstub)
18+
else
19+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
20+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
21+
end
22+
end
23+
24+
require "rubygems"
25+
require "bundler/setup"
26+
27+
load Gem.bin_path("rake", "rake")

lib/openid/urinorm.rb

+7-4
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,20 @@
33
module OpenID
44

55
module URINorm
6+
VALID_URI_SCHEMES = ['http','https'].freeze
67
public
78
def URINorm.urinorm(uri)
89
uri = URI.parse(uri)
910

1011
raise URI::InvalidURIError.new('no scheme') unless uri.scheme
12+
1113
uri.scheme = uri.scheme.downcase
12-
unless ['http','https'].member?(uri.scheme)
13-
raise URI::InvalidURIError.new('Not an HTTP or HTTPS URI')
14-
end
14+
raise URI::InvalidURIError.new('Not an HTTP or HTTPS URI') unless VALID_URI_SCHEMES.member?(uri.scheme)
15+
16+
raise URI::InvalidURIError.new('no host') if uri.host.nil? # For Ruby 2.7
17+
18+
raise URI::InvalidURIError.new('no host') if uri.host.empty? # For Ruby 3+
1519

16-
raise URI::InvalidURIError.new('no host') unless uri.host
1720
uri.host = uri.host.downcase
1821

1922
uri.path = remove_dot_segments(uri.path)

0 commit comments

Comments
 (0)