Display a warning on stderr. Will ask question
if it is not nil.
Smushes all heredoc lines into one line
source = <<~'EOM' foo = <<~HEREDOC lol hehehe HEREDOC EOM lines = CleanDocument.new(source: source).join_heredoc!.lines expect(lines[0].to_s).to eq(source) expect(lines[1].to_s).to eq("")
Smushes logically “consecutive” lines
source = <<~'EOM' User. where(name: 'schneems'). first EOM lines = CleanDocument.new(source: source).join_consecutive!.lines expect(lines[0].to_s).to eq(source) expect(lines[1].to_s).to eq("")
The one known case this doesn’t handle is:
Ripper.lex <<~EOM a && b || c EOM
For some reason this introduces ‘on_ignore_newline` but with BEG type
Helper method for joining “groups” of lines
Input is expected to be type Array
<Array<CodeLine>>
The outer array holds the various “groups” while the inner array holds code lines.
All code lines are “joined” into the first line in their group.
To preserve document size, empty lines are placed in the place of the lines that were “joined”
Determines if the given line has a trailing slash
lines = CodeLine.from_source(<<~EOM) it "foo" \ EOM expect(lines.first.trailing_slash?).to eq(true)
Given an already existing block in the frontier, expand it to see if it contains our invalid syntax
do nothing
Checks the user
and password
.
If password
is not provided, then user
is split, using URI::Generic.split_userinfo
, to pull user
and +password.
See also URI::Generic.check_user
, URI::Generic.check_password
.
Protected setter for the user
component, and password
if available (with validation).
See also URI::Generic.userinfo=
.
Returns the userinfo ui
as [user, password]
if properly formatted as ‘user:password’.
Returns a proxy URI
. The proxy URI
is obtained from environment variables such as http_proxy, ftp_proxy, no_proxy, etc. If there is no proper proxy, nil is returned.
If the optional parameter env
is specified, it is used instead of ENV
.
Note that capitalized variables (HTTP_PROXY, FTP_PROXY, NO_PROXY, etc.) are examined, too.
But http_proxy and HTTP_PROXY is treated specially under CGI
environment. It’s because HTTP_PROXY may be set by Proxy: header. So HTTP_PROXY is not used. http_proxy is not used too if the variable is case insensitive. CGI_HTTP_PROXY can be used instead.
Returns the RFC822 e-mail text equivalent of the URL, as a String
.
Example:
require 'uri' uri = URI.parse("mailto:ruby-list@ruby-lang.org?Subject=subscribe&cc=myaddr") uri.to_mailtext # => "To: ruby-list@ruby-lang.org\nSubject: subscribe\nCc: myaddr\n\n\n"
Returns Regexp
that is default self.regexp[:ABS_URI_REF]
, unless schemes
is provided. Then it is a Regexp.union
with self.pattern[:X_ABS_URI]
.
Constructs the default Hash
of patterns.
Constructs the default Hash
of Regexp’s.