MAS GUI client in ruby - first commit

MAS GUI client, implemented in ruby - to be used as part of a Rails
application.  It's in a very early stage of development, but it connects
to the MAS server and does a couple basic requests.
environment, tools, ... - useful for testing, etc.
Added some contracts via ruby_contracts.
Refactoring - communication logic moved up.

Began the process of moving the main communication logic up from
MasClient to MasCommunicationServices, using the template method pattern
such that MasClient implements the socket-communication-specific part of
this logic.  Used the 'abstract' (abstract_method) gem/module to
document the abstract methods used by the template method; but I will
probably switch to a more explicit method (e.g., raise exception in an
abstract_method definition) that will allow pre/post conditions to be
specified and not use 'abstract'.
Communication logic refactoring finished

Finished the refactoring described in the previous commit - moving the main
communication logic up from MasClient to MasCommunicationServices by means
of the template method pattern. MasCommunicationServices now handles
essentially all of the communication logic (including obtaining/setting the
session key returned by the server) except for the actual creating, reading,
writing, and closing of the TCP socket, which is done in MasClient.  For
"abstract methods", the 'abstract' gem/module is no longer used.  This
allows pre/post-conditions (via ruby_contract) to be defined for the
abstract methods and checked in the implementations (in MasClient).

Also - a bit of cleanup - remove old code, etc.  And added the
.gitignore file.
host, port now public, new test script

MasClient: Made attrs host and port public.  socket is still private.

Added a (minitest) test script: /test/test_mas_client.rb.  All 3 tests
pass.
Added more needed functionality to MasCommunicationServices.

Added several new public 'request_*' methods, which request data from the
server and place the result into the appropriate (also newly added) public
attribute (indicators, period_types, tradable_data, ...).  Included a small
refactoring improvement: Each of the request_* routines now calls
'execute_request', which carries out the steps needed (begin_communication,
send, receive_response, end_communication, etc.) to request and receive the
data from the server.  This results, of course, in the request_* routines
consisting of usually about 3 lines instead of at least 10 lines, and
corresponding removal of duplicate code.  Note that execute_request has a
postcondition such that last_response_components is an array filled with the
processed result (server response); and it ensures that
last_response_components will contain only the processed response by first
setting it to nil (i.e., ensuring that last_response_components does not
contain old/stale data).  This means that the 'process_response' routine,
called by execute_request has to set last_response_components correctly, or,
if the (method) argument 'processor' is provided, it needs to do the same.

Also, changed the logic that checks the error status returned by the server
(via response_ok?) to raise an appropriate exception if the result is NOT
OK.
New tests of new request_* features, ...

MasCommunicationProtocol: cosmetic formatting improvements.

TimePeriodTypeConstants: Added intraday period-type constants (1-minute,
...).

test_mas_client: Added new tests to test the new request_* routines in
MasCommunicationServices/MasClient.
MasCommunicationServices implementation; test enhancement

MasCommunicationServices: Finished request_tradable_data implementation
(process response into an array of arrays - i.e., one outer-array
element for each time period (e.g., day) and one inner element for each
of: date, open, high, low, close, volume).  Added a 'logged_in' query
and 'logout' routine.  Added 'logged_in' as a precondition of some of
the public methods.  Etc.

Tests: Added some basic assertions in test_tradable_data to ensure that
the format of the first record is correct (date, prices, volume).  Wrote
a "logout" test.  Adapted the test script (with the help of supporting
files: startmas - script to start the mas server; mas_httprc and symbols -
mas configuration files; test_setup.rb - test setup script to set
environment variables specified in a file) to start the mas server (if
it's not already running) and then create a MasClient instance (which
causes a login-to-the-server) before any tests are run and store the new
object in a global variable.  Also, realizing that minitest runs the test in
a random order, I changed the 'setup' routine to, if the client has logged
out (i.e., logout test was run), log back in by recreating the client.
Cleanup, new test

Cleanup old-code/putss/old-comments from recent dev/debug work.  Test
output is now clean.  Added a test_indicator_data test - which is
skipped, until the feature is actually implemented; but I just realized
I misnamed the test.  Called it 'test_tradable_data', which duplicates
the name of an existing test.  Will fix in next commit.
correction: tradable -> indicator
request_indicator_data with test, ...

MasCommunicationServices: Added indicator_data attribute,
request_indicator_data method.  Bug fix: process_data_response - used by
request_tradable_data and request_indicator_data - was not stripping the
end-of-message character (last character of the response string) off
before splitting the response into an array.  Bug fix: process_data_response
was setting @tradable_data from the processed input; but
request_indicator_data was also calling process_data_response (in addition
to request_tradable_data) and it needs @indicator_data to be set.  The
solution was to delete the code in process_data_response that sets
@tradable_data and put that logic in request_tradable_data (@tradable_data)
and request_indicator_data (@indicator_data).  Corrected some incorrect method-
header comments.

startmas: 'sleep 1' after starting the mas server to allow it to
startup/initialize before the test script starts communicating with the
server.

test_mas_client.rb: Added a test for request_indicator_data.  Extended
test_tradable_data and test_indicator_data to check the validity of the
last data record, as well as the first.  test_indicator_data: got rid of
'yearly' period type for now, since it causes empty indicators.  Extending
the date-range for data requests could fix this.
Tools for creating indicators/generators

cci, cci_signals, indicators, market_analyzers, parabolic-sar: "macl"
scripts to create indicators and tradable analyzers (indicators_persist
and generators_persist files) for the MAS server - to be used in tests.

make_indicators - bash script to feed the above files to macl, which
connects to the server and creates the ordered indicators/analyzers.
tradable analysis functionality

MasCommunicationServices: Added 'request_analyzers' and 'request_analysis',
to obtain available tradable-event generators and request analysis using
one or more of these generators, respectively.  Added current_start_date,
current_end_date - to be used for this analysis if no date arguments are
passed to 'request_analysis'.  Also, added a couple needed pre- or
post-conditions.

test_mas_client.rb: Added tests for the new functionality described above.
tradable analyzer abstraction

New class for encapsulating the tradable analyzers (AKA tradable-event
generators) concept - currently, just a name and id.  The id is used in
'request_analysis' (described in the previous commit [for
MasCommunicationServices]) to tell the server which analyzer(s) to use.
Cleanup of analysis-functionality residue

MasCommunicationServices: changed name of attributes:
current_[start|end]_date -> analysis_[start|end]_date - since they're
used for 'request_analysis'.  Deleted some comments and
debugging-related code that was used to develop the
'request_analyzers'/'request_analysis' functionality.

test_mas_client.rb: Removed a couple print statements.
fixed: feature name changed
Finished 'request_analysis' with new TradableEvent class.

Added TradableEvent class and used it to finish the implementation of
'request_analysis' in MasCommunicationServices.  'request_analysis' creates
one TradableEvent for each line in the server's response and uses the event
id (3rd tab-separated field) to associate the new TradableEvent with the
correct TradableAnalyzer (and, by extension, the particular
tradable-event-generator on the server side that generated the event).  The
resulting array of "TradableEvent"s is found in the new attribute
'analysis_result'.  Completed 'test_analysis' in the test script to obtain
the generated events and assert that they are, indeed, "TradableEvent"s.

Also - in the test script, added a "destructor" routine via
define_finalizer that logs $client (global MasClient variable) out to
prevent leaving an open session, with an unused session-key, on the server
side.
Cleanup

Removed old commented-out debugging code, etc.
Use of constant for date-field separator

Changed request_analysis to use a constant for the date-field separator
(ANALYSIS_REQ_DATE_FIELD_SEPARATOR - added in MasCommunicationProtocol),
instead of being hard-coded - for better maintainability.