Returns a Gem::StubSpecification
for default gems
Loads the default specifications. It should be called only once.
Removes spec
from the known specs.
Returns the full path to an executable named name
in this gem.
Returns the full path to the cached gem for this spec.
The default value for specification attribute name
The default (generated) file name of the gem. See also spec_name
.
spec.file_name # => "example-1.0.gem"
Files in the Gem under one of the require_paths
Return a NameTuple that represents this Specification
Return a string containing a Ruby code representation of the given object.
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.
Main work method
The scan_while
method takes a block that yields lines above and below the block. If the yield returns true, the @before_index or @after_index are modified to include the matched line.
In addition to yielding individual lines, the internals of this object give a mini DSL to handle common situations such as stopping if we’ve found a keyword/end mis-match in one direction or the other.
Return the currently matched lines as a ‘CodeBlock`
When a ‘CodeBlock` is created it will gather metadata about itself, so this is not a free conversion. Avoid allocating more CodeBlock’s than needed
Remove comments
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