PrettyPrint::SingleLine
is used by PrettyPrint.singleline_format
It is passed to be similar to a PrettyPrint
object itself, by responding to:
but instead, the output has no line breaks
Raised when a hash-based tuple has an invalid key.
A tuple is the elementary object in Rinda
programming. Tuples may be matched against templates if the tuple and the template are the same size.
TupleSpaceProxy
allows a remote Tuplespace to appear as local.
An SimpleRenewer
allows a TupleSpace
to check if a TupleEntry
is still alive.
A TupleEntry
is a Tuple
(i.e. a possible entry in some Tuplespace) together with expiry and cancellation data.
TupleBag
is an unordered collection of tuples. It is the basis of Tuplespace.
The Tuplespace manages access to the tuples it contains, ensuring mutual exclusion requirements are met.
The sec
option for the write, take, move, read and notify methods may either be a number of seconds or a Renewer object.
An error that indicates we weren’t able to fetch some data from a source
Signals that a remote operation cannot be conducted, probably due to not being connected (or just not finding host).
The installer installs the files contained in the .gem into the Gem.home.
Gem::Installer
does the work of putting files in all the right places on the filesystem including unpacking the gem into its gem dir, installing the gemspec in the specifications dir, storing the cached gem in the cache dir, and installing either wrappers or symlinks for executables.
The installer invokes pre and post install hooks. Hooks can be added either through a rubygems_plugin.rb file in an installed gem or via a rubygems/defaults/#{RUBY_ENGINE}.rb or rubygems/defaults/operating_system.rb file. See Gem.pre_install
and Gem.post_install
for details.
This Gem::StreamUI
subclass records input and output to StringIO
for retrieval during tests.
Represents a gem of name name
at version
of platform
. These wrap the data returned from the indexes.
RemoteFetcher
handles the details of fetching gems and gem information from a remote source.
SilentUI
is a UI choice that is absolutely silent.
Parses and sanitizes source into a lexically aware document
Internally the document is represented by an array with each index containing a CodeLine
correlating to a line from the source code.
There are three main phases in the algorithm:
Sanitize/format input source
Search for invalid blocks
Format invalid blocks into something meaninful
This class handles the first part.
The reason this class exists is to format input source for better/easier/cleaner exploration.
The CodeSearch
class operates at the line level so we must be careful to not introduce lines that look valid by themselves, but when removed will trigger syntax errors or strange behavior.
## Join Trailing slashes
Code with a trailing slash is logically treated as a single line:
1 it "code can be split" \ 2 "across multiple lines" do
In this case removing line 2 would add a syntax error. We get around this by internally joining the two lines into a single “line” object
## Logically Consecutive lines
Code that can be broken over multiple lines such as method calls are on different lines:
1 User. 2 where(name: "schneems"). 3 first
Removing line 2 can introduce a syntax error. To fix this, all lines are joined into one.
## Heredocs
A heredoc is an way of defining a multi-line string. They can cause many problems. If left as a single line, Ripper
would try to parse the contents as ruby code rather than as a string. Even without this problem, we still hit an issue with indentation
1 foo = <<~HEREDOC 2 "Be yourself; everyone else is already taken."" 3 ― Oscar Wilde 4 puts "I look like ruby code" # but i'm still a heredoc 5 HEREDOC
If we didn’t join these lines then our algorithm would think that line 4 is separate from the rest, has a higher indentation, then look at it first and remove it.
If the code evaluates line 5 by itself it will think line 5 is a constant, remove it, and introduce a syntax errror.
All of these problems are fixed by joining the whole heredoc into a single line.
## Comments and whitespace
Comments can throw off the way the lexer tells us that the line logically belongs with the next line. This is valid ruby but results in a different lex output than before:
1 User. 2 where(name: "schneems"). 3 # Comment here 4 first
To handle this we can replace comment lines with empty lines and then re-lex the source. This removal and re-lexing preserves line index and document size, but generates an easier to work with document.