Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
TooTallNate committed Apr 29, 2024
1 parent 948a6a5 commit 7e54050
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 5 deletions.
15 changes: 10 additions & 5 deletions packages/ruby/src/install-ruby.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function getLatestRubyVersion(): RubyVersion {
const selection = allOptions.find(isInstalled);
if (!selection) {
throw new NowBuildError({
code: 'RUBY_NOT_FOUND',
code: 'RUBY_INVALID_VERSION',
link: 'http://vercel.link/ruby-version',
message: `Unable to find any supported Ruby versions.`,
});
Expand Down Expand Up @@ -60,7 +60,7 @@ function getRubyPath(meta: Meta, gemfileContents: string) {
// The array is already in order so return the first
// match which will be the newest version.
selection = o;
return intersects(o.range, strVersion) && isInstalled(o);
return intersects(o.range, strVersion);
});
if (!found) {
throw new NowBuildError({
Expand All @@ -69,12 +69,17 @@ function getRubyPath(meta: Meta, gemfileContents: string) {
link: 'http://vercel.link/ruby-version',
});
}
if (isDiscontinued(selection)) {
const discontinued = isDiscontinued(selection);
if (discontinued || !isInstalled(selection)) {
const latest = getLatestRubyVersion();
const intro = `Found \`Gemfile\` with discontinued Ruby version: \`${line}.\``;
const intro = `Found \`Gemfile\` with ${
discontinued ? 'discontinued' : 'invalid'
} Ruby version: \`${line}.\``;
const hint = `Please set \`ruby "~> ${latest.range}"\` in your \`Gemfile\` to use Ruby ${latest.range}.`;
throw new NowBuildError({
code: 'RUBY_DISCONTINUED_VERSION',
code: discontinued
? 'RUBY_DISCONTINUED_VERSION'
: 'RUBY_INVALID_VERSION',
link: 'http://vercel.link/ruby-version',
message: `${intro} ${hint}`,
});
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# frozen_string_literal: true

source "https://rubygems.org"

ruby "~> 3.3.x"

gem "cowsay", "~> 0.3.0"
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
GEM
remote: https://rubygems.org/
specs:
cowsay (0.3.0)

PLATFORMS
x86_64-linux

DEPENDENCIES
cowsay (~> 0.3.0)

RUBY VERSION
ruby 2.5.5p157

BUNDLED WITH
2.2.22
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
require 'cowsay'

Handler = Proc.new do |req, res|
name = req.query['name'] || 'World'

res.status = 200
res['Content-Type'] = 'text/text; charset=utf-8'
res.body = Cowsay.say("Hello #{name}", 'cow')
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"engines": {
"node": "18.x"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"version": 2,
"builds": [{ "src": "index.rb", "use": "@vercel/ruby" }]
}

0 comments on commit 7e54050

Please sign in to comment.