This repository contains a Thor task which, given a dictionary, generates two output files, 'sequences.txt' and 'words.txt'.
- sequences.txt contains every sequence of four letters (A-z) that appears in exactly one word of the dictionary, one sequence per line.
- words.txt contains the corresponding words that contain the sequences, in the same order, again one per line.
- Ruby 2.2.0.
-
Clone this repository:
git clone git@github.com:sbsurf/words-test.git
-
cd into the newly-created words-test directory, and install the gems by running
bundle install
or simplybundle
. You may want to create and use a new gemset before installing the gems. -
Still in the app directory, you can run
thor list
to see the list of Thor tasks. You should see the hello_labs:parser:parse task. This is the command you will run after completing the initial set up steps.
- By default, the task will use the input/dictionary.txt file (included). If you'd like to use a different file, download or create it before running the task.
-
The easiest way to run the task is with default options:
thor hello_labs:parser:parse
- This assumes that:
- The input file input/dictionary.txt exists and is not empty.
- There are no output/sequences.txt or output/words.txt files yet.
- This assumes that:
-
Pass in task parameters in order to specify a different input file, to change the default output directory, or to force the script to overwrite existing output files. To see the expected parameters and their default values, run:
thor help hello_labs:parser:parse
-
For more information on Thor, visit https://github.com/erikhuda/thor/wiki.
- To run the test suite, simply use the Rspec command:
bundle exec rspec
or simply:
rspec
- The tests use mocking where it makes sense, and cover:
- File creation logic
- Option switch logic
- Dictionary parsing algorithm. The file found at spec/input/dictionary.txt, which contains various test cases, is used for this purpose.