The type of documents that need to be accessed are
2. Word (.doc or.docx)
To shorten the search path, the user would also enter the root directory where the search begins. An example of the Ruby Rails implementation is shown below
The project is to be delivered in several phases:
Write Ruby code and answer following questions. Upload rb files (with comments) on Moodle:
Q1. Create a text file named Story.txt, type the following statements into the file and save it:
Once upon a time, there was a little boy who went on a great adventure.
Unfortunately, nothing happened. The End
Next, create a Ruby program named StoryCheck.rband add the program logic needed to perform the following tasks:
§ Verify that the fileexists.
§ If the file does not exist, display an errormessage.
§ If the file exists, read it and test whether it contains the phrase “a littleboy”
§ If it does display the contents of the text file otherwise display phrase notfound.
Q2. Create a Ruby program file named DirChecker.rband add the program logic needed to perform the following tasks:
§ Prompt the user to type the path and name of a folder whose contents will bedisplayed.
§ Capture and analyze user input to determine whether the specified folderexists.
§ Tell the user whether or not the folderexists.
§ If the folder exists, prompt the user to press Enter in order to view the folder’s contents.
§ If the folder does not exist, display an errormessage.
In phase 2, an initial prototype is required. This prototype will
1. Request two user inputs - a term/word/phrase and a directory from the user throughcommand prompt.
2. Search for user input term/word/phrase in all text documents (.txt) in the specified directory and sub- directories (user inputdirectory).
3. Output the list of names of the documents containing the user given term/word/phrase and portion of content of the text document. You can add information like total number of documents containing the term/phrase or total number of occurrence of the term/phrase in a specificdocument.
4. Display the appropriate message/information, if there is no match found for the given term/word/phrase in all text documents in the givendirectory.
5. Require no fancy user interface. User input will be provided through command prompt .Itcan be implemented entirely in Ruby withoutrails.
6. Implemented by using classes, objects, methods andconstructor.
This phase extends phase 2 by adding the capacity to search term/word/phrase in word documents and pdf documents as well as text documents. Please note, Ruby gems are required to implement Phase 3 (i.e. download from https://rubygems.org/, installing the gem, using ‘require’ in code and calling the appropriate method of the gem ). Hint: Read the related gem documentation to identify the parameters and output of different methods provided by the gem.
Add appropriate comments e.g Name, Student ID, functionality of a variable, brief explanation of logic
This prototype will then be transported to a rails framework with a user interface similar to the example below.
1. The user will provide the input through web page in rails. Web page should contain two text fields (1. Word/phrase and 2. Root directory) and a search button in an HTMLform.
2. Search results will be display on web page (same or different) aswell.
3. In this phase for every match found, the filename including the full path will be printed to the browser and a portion of content of the document will be printed into a text-area (these will be added dynamically according to the number of matchesfound).
4. Add appropriate comments e.gName, Student ID, functionality of a variable, brief explanation of logic