Returns the full path to this spec’s gemspec file. eg: /usr/local/lib/ruby/gems/1.8/specifications/mygem-1.0.gemspec
Display a warning on stderr. Will ask question
if it is not nil.
Display an error message in a location expected to get error messages. Will ask question
if it is not nil.
Remove comments and whitespace only lines
replace with empty newlines
source = <<~'EOM' # Comment 1 puts "hello" # Comment 2 puts "world" EOM lines = CleanDocument.new(source: source).lines expect(lines[0].to_s).to eq("\n") expect(lines[1].to_s).to eq("puts "hello") expect(lines[2].to_s).to eq("\n") expect(lines[3].to_s).to eq("puts "world")
Important: This must be done before lexing.
After this change is made, we lex the document because removing comments can change how the doc is parsed.
For example:
values = LexAll.new(source: <<~EOM)) User. # comment where(name: 'schneems') EOM expect( values.count {|v| v.type == :on_ignored_nl} ).to eq(1)
After the comment is removed:
values = LexAll.new(source: <<~EOM)) User. where(name: 'schneems') EOM expect( values.count {|v| v.type == :on_ignored_nl} ).to eq(2)
Used to hide lines
The search alorithm will group lines into blocks then if those blocks are determined to represent valid code they will be hidden
Returns default port.
Returns default port.
Returns the user component after URI
decoding.
Returns the password component after URI
decoding.
Calls the given block once for each key
, value
pair in the database. Deletes all entries for which the block returns true.
Returns self
.
Invoked by Kernel#sleep
and Mutex#sleep and is expected to provide an implementation of sleeping in a non-blocking way. Implementation might register the current fiber in some list of “which fiber wait until what moment”, call Fiber.yield
to pass control, and then in close
resume the fibers whose wait period has elapsed.
Reads the file from pathname, then parses it like ::parse
, returning the root node of the abstract syntax tree.
SyntaxError
is raised if pathname’s contents are not valid Ruby syntax.
RubyVM::AbstractSyntaxTree.parse_file("my-app/app.rb") # => #<RubyVM::AbstractSyntaxTree::Node:SCOPE@1:0-31:3>
See ::parse
for explanation of keyword argument meaning and usage.
Synonym for CGI.escapeElement(str)