Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ruby 3.3 #4070

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.2.3
3.3.5
2 changes: 0 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ gem 'allowy', '>= 2.1.0'
gem 'clockwork', require: false
gem 'cloudfront-signer'
gem 'digest-xxhash'
gem 'em-http-request', '~> 1.1'
gem 'eventmachine', '~> 1.2.7'
gem 'fluent-logger'
gem 'googleapis-common-protos', '>= 1.3.12'
Expand All @@ -32,7 +31,6 @@ gem 'public_suffix'
gem 'puma'
gem 'rake'
gem 'redis'
gem 'rfc822'
gem 'rubyzip', '>= 1.3.0'
gem 'sequel', '~> 5.85'
gem 'sequel_pg', require: 'sequel'
Expand Down
13 changes: 0 additions & 13 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ GEM
coderay (1.1.3)
concurrent-ruby (1.3.4)
connection_pool (2.4.1)
cookiejar (0.3.3)
crack (1.0.0)
bigdecimal
rexml
Expand All @@ -148,14 +147,6 @@ GEM
domain_name (0.6.20240107)
drb (2.2.1)
e2mmap (0.1.0)
em-http-request (1.1.7)
addressable (>= 2.3.4)
cookiejar (!= 0.3.1)
em-socksify (>= 0.3)
eventmachine (>= 1.0.3)
http_parser.rb (>= 0.6.0)
em-socksify (0.3.2)
eventmachine (>= 1.0.0.beta.4)
erubi (1.13.0)
eventmachine (1.2.7)
excon (0.112.0)
Expand Down Expand Up @@ -275,7 +266,6 @@ GEM
http-cookie (1.0.5)
domain_name (~> 0.5)
http-form_data (2.3.0)
http_parser.rb (0.6.0)
httpclient (2.8.3)
i18n (1.14.6)
concurrent-ruby (~> 1.0)
Expand Down Expand Up @@ -435,7 +425,6 @@ GEM
reverse_markdown (2.1.1)
nokogiri
rexml (3.3.9)
rfc822 (0.1.5)
roodi (5.0.0)
ruby_parser (~> 3.2, >= 3.2.2)
rspec (3.13.0)
Expand Down Expand Up @@ -609,7 +598,6 @@ DEPENDENCIES
codeclimate-test-reporter (>= 1.0.8)
debug (~> 1.9)
digest-xxhash
em-http-request (~> 1.1)
eventmachine (~> 1.2.7)
fluent-logger
fog-aliyun
Expand Down Expand Up @@ -651,7 +639,6 @@ DEPENDENCIES
railties (~> 7.2.1)
rake
redis
rfc822
roodi
rspec (~> 3.13.0)
rspec-collection_matchers
Expand Down
7 changes: 0 additions & 7 deletions lib/sequel_plugins/vcap_validations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,5 @@ def validates_url(attr, opts={})

validates_format(URI::DEFAULT_PARSER.make_regexp(%w[http https]), attr, message: opts.fetch(:message, :url))
end

# Validates that an attribute is a valid email address
#
# @param [Symbol] The attribute to validate
def validates_email(attr)
validates_format(RFC822::EMAIL_REGEXP_WHOLE, attr, message: :email) if send(attr)
end
end
end
2 changes: 0 additions & 2 deletions lib/vcap/rest_api/message.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
require 'vcap/json_message'
require 'rfc822'

module VCAP
module RestAPI
Expand Down Expand Up @@ -58,7 +57,6 @@ def self.schema_doc(schema)

URL = UrlDecorator.new(URI::DEFAULT_PARSER.make_regexp(%w[http https]))
HTTPS_URL = HttpsUrlDecorator.new(URI::DEFAULT_PARSER.make_regexp('https'))
EMAIL = EmailDecorator.new(RFC822::EMAIL_REGEXP_WHOLE)
GIT_URL = GitUrlDecorator.new(URI::DEFAULT_PARSER.make_regexp(%w[http https git]))

# The block will be evaluated in the context of the schema validator used
Expand Down
60 changes: 0 additions & 60 deletions lib/vcap/services/api/async_requests.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# Copyright (c) 2009-2011 VMware, Inc.
require 'eventmachine'
require 'em-http-request'
require 'httpclient'

require 'vcap/services/api/const'
Expand All @@ -13,38 +11,6 @@ module Api
end

module VCAP::Services::Api
class AsyncHttpRequest
class << self
def new(url, token, verb, timeout, msg=VCAP::Services::Api::EMPTY_REQUEST)
req = {
head: {
VCAP::Services::Api::GATEWAY_TOKEN_HEADER => token,
'Content-Type' => 'application/json'
},
body: msg.encode
}
if timeout
EM::HttpRequest.new(url, inactivity_timeout: timeout).send(verb.to_sym, req)
else
EM::HttpRequest.new(url).send(verb.to_sym, req)
end
end

def request(url, token, verb, timeout, msg=VCAP::Services::Api::EMPTY_REQUEST)
req = new(url, token, verb, timeout, msg)
f = Fiber.current
req.callback { f.resume(req) }
req.errback { f.resume(req) }
http = Fiber.yield
raise UnexpectedResponse.new("Error sending request #{msg.extract.to_json} to gateway #{@url}: #{http.error}") unless http.error.empty?

code = http.response_header.status.to_i
body = http.response
[code, body]
end
end
end

module SynchronousHttpRequest
def self.request(url, token, verb, _timeout, msg=VCAP::Services::Api::EMPTY_REQUEST)
header = {
Expand All @@ -57,30 +23,4 @@ def self.request(url, token, verb, _timeout, msg=VCAP::Services::Api::EMPTY_REQU
[msg.code, msg.body]
end
end

class AsyncHttpMultiPartUpload
class << self
def new(url, timeout, multipart, head={})
req = {
head: head,
body: '',
multipart: multipart
}

if timeout
EM::HttpRequest.new(url, inactivity_timeout: timeout).post req
else
EM::HttpRequest.new(url).post req
end
end

def fibered(url, timeout, multipart, head={})
req = new(url, timeout, multipart, head)
f = Fiber.current
req.callback { f.resume(req) }
req.errback { f.resume(req) }
Fiber.yield
end
end
end
end
9 changes: 0 additions & 9 deletions spec/unit/lib/ext/validation_error_message_overrides_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,6 @@
end
end

context 'with a custom readable_regexp for an email' do
let(:regexp) { VCAP::RestAPI::Message::EMAIL }

it 'generates a readable message' do
expected_emsg = 'must be a valid email'
expect { subject.fail!(regexp, object) }.to raise_error(Membrane::SchemaValidationError, /#{expected_emsg}/)
end
end

context 'with a custom readable_regexp for a git URL' do
let(:regexp) { VCAP::RestAPI::Message::GIT_URL }

Expand Down
41 changes: 0 additions & 41 deletions spec/unit/lib/sequel_plugins/vcap_validations_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,45 +63,4 @@ def self.define_validations(&)
end
end
end

describe 'validates_email' do
before do
@c.define_validations { validates_email(:val) }
end

it 'allows a valid email' do
@m.val = '[email protected]'
expect(@m).to be_valid
end

it 'does not allow an email with no domain' do
@m.val = 'some_guy'
expect(@m).not_to be_valid
end

it 'does not allow an email with no user' do
@m.val = '@somedomain.com'
expect(@m).not_to be_valid
end

it 'does not allow a malformed email with multiple @' do
@m.val = 'foo@[email protected]'
expect(@m).not_to be_valid
end

it 'allows a nil email' do
@m.val = nil
expect(@m).to be_valid
end

it 'does not allow an empty email' do
@m.val = ''
expect(@m).not_to be_valid
end

it 'does not allow an email with only spaces' do
@m.val = ' '
expect(@m).not_to be_valid
end
end
end