ruby代写: COSC2675 Rapid Application Development

COSC2675 Rapid Application Development

Computer Science and Information Technology School of Science, RMIT

Assignment 1 – Semester 1 2018 ( DUE on 1st April )

Introduction
This assignment is worth 10% towards your final grade. You are required to write at least two

scripts in Ruby. It is designed to:

  • Practise your knowledge of Ruby programming;
  • Practise installation and use of Ruby Gems;
  • Practise string/text processing;

    This assignment can be completed individually or in a group of 2. Academic Integrity

    The submitted assignment must be your own work. No marks will be awarded for any parts, which are not created by you. More on http://www.rmit.edu.au/academicintegrity.

    Plagiarism is treated very seriously at RMIT. Plagiarism includes copying code directly from other students, internet or other resources without proper reference. Sometimes, students study and work on assignments together and submit similar files which may be regarded as plagiarism. Please note that you should always create your own assignment even if you have very similar ideas.

    Plagiarism-detection tools may be used for all submissions. Penalties will be applied in cases of plagiarism.

    Part 1

  • ●  RubyGems is a package manager for the Ruby programming language that provides a standard format for distributing Ruby programs and libraries (in a self-contained format called a “gem”).
  • ●  In part 1, you need to install two gems, which are required for other parts of Assignment 1. You may use other relevant gems.

nokogiri

o https://github.com/sparklemotion/nokogiri

ruby-lint

o https://github.com/YorickPeterse/ruby-lint

● once you have installed all of them, you can check using

o o

gem list -i nokogiri

=> true => true

gem list -i ruby-lint

NOTE: Do not move to Part 2 if you haven’t successfully installed these two gems.

● The minimum version of ruby for this course is , you can use to check your system ruby version

2.0.0

ruby -v

ruby -v
ruby 2.3.2p217 (2016-11-15 revision 56796) [x86_64-darwin16]

● For more information on how to install your ruby locally, follow these links. Alternatively, you can use ruby manager to manage different versions of ruby

  • ●  ruby manager: https://www.ruby-lang.org/en/documentation/installation/#managers
  • ●  ruby installation: https://www.ruby-lang.org/en/documentation/installation/

Part 2

  • ●  You will need gem to make a useful command line application.
  • ●  Write a script called

nokogiri

o e.g. is your student id, so name your file

s3123456

{:your_student_number}_p2.rb

s3123456_p2.rb

● When the script is called >>

ruby s3123456_p2.rb

, its output should look like:

Commands:
s3123456_p2.rb -xml [filename] # Load a XML file
s3123456_p2.rb help [COMMAND] # Describe available commands or one specific command

● Extracting time information from plain text such as emails is a very useful functionality, but still remains as a challenge. You can see examples in Gmail. Gmail underlines date and time in attempt to create calendar events automatically. As you can see, the result is often mixed. There are many scenarios that Gmail cannot handle well. Your task here is to write a script to achieve similar and even better performance than Gmail event extractor.

An XML file “emails.xml” will be provided which contains several emails. Below is an example email which shows send, date/time, subject, utc time and the body:

<record>
<id>17</id>
<first_name>Vern</first_name> <last_name>Dabernott</last_name> <email>vdabernottg@theguardian.com</email> <gender>Male</gender> <ip_address>155.168.41.66</ip_address> <send_date>2017-06-20T18:49:03Z</send_date> <email_body>1;DROP TABLE users</email_body> <email_title>real-time</email_title>

</record>

● Your Ruby program is expected to accept any XML files in that format

● Your Ruby program is expected to extract all the information for each particular record

● Your Ruby program should not crash or exit at any point given the input record is invalid or malformed

● Your Ruby can accept keyword search for ip address and return records in JSON format

s123456_p3.rb

ruby –ip 10.10.10.10

{ “id”: 2,
“first_name”: “Morgen”,
“last_name”: “Woolbrook”,
“email”: “mwoolbrook1@google.co.jp”, “gender”:
“Female”,
“ip_address”: “10.10.10.10”, “send_date”: “2018-01-27T14:27:06Z”, “email_body”: “􏱄􏱅􏱆􏱇􏱈􏱉􏱊􏱋􏱌􏱆􏱍”, “email_title”: “web-enabled”
},




… # to continue until the end

list

● Your Ruby can accept keyword search for name and return records for email_body corresponding email records.

s123456_p3.rb

ruby –name Alex

{ “id”: 102,
“first_name”: “Alex”,
“last_name”: “Louey”,
“email”: “alex.louey@google.co.jp”, “gender”:
“Female”,
“ip_address”: “100.212.3.12”, “send_date”: “2018-01-27T14:27:06Z”, “email_body”: “ghost in the shell”, “email_title”: “watch now!”
},




… # to continue until the end

list

The search is always case insensitive.

● Do not move to Part 3 unless you have successfully finished Part 2.

Part 3

● In Part 3, you will extend the Part 2 program. Your ruby script {:your_student_number}_p3.rb supports arguments to limit the search only for a certain period of time, such as below. (Write your assumptions in the code when necessary)

–before 2013-10 => before October 2013 -after 2015 => after year 2015

  • ●  The “before” and the “after” can be combined or used separately. If the “before” time is earlier than the “after” time, then an error message will appear.
  • ●  In addition, the script also supports days (such as Wed, wed, Wednesday, wednesday … )

-day Wed => searching for Wednesday records only.

Part 4 (Group Option)

For group submission, this option is mandatory. Individuals attempted this option will NOT receive any bonus marks. A group cannot have more than 2 members.

● Write a ruby script {:your_student_number}_p4.rb which requires api-key. The api-key should follow the rules below:

o must be at least 8 characters
o must include at least one number
o must include at least one letter
o your script always needs an api-key

o if you provide any invalid api key, your script should terminate immediately

ruby s3123456_p4.rb –api-key=”alex’key” Invalid API Key, operation abort…

list

● If any valid is provided, then your script should read through the xml file and list the first 20 entries in JSON format.

api-key

ruby s3123456_p4.rb –api-key=”124FAfg$11s”

————–

{

list

“id”: 20,

“first_name”: “Angelica”,

“last_name”: “Alebrooke”,

“email”: “aalebrookej@wordpress.org”,

“gender”: “Female”,

“ip_address”: “209.164.123.51”,

“send_date”: “2018-02-15T01:25:46Z”,

“email_body”: “-1E2”,

“email_title”: “pricing structure”

}, {

“id”: 21,

“first_name”: “Cesar”,

“last_name”: “Ethridge”,

“email”: “cethridgek@apache.org”,

“gender”: “Male”,

“ip_address”: “221.155.16.217”,

“send_date”: “2017-08-15T16:36:21Z”,

“email_body”: “1E+02”,

“email_title”: “Public-key”

},

● Your script also supports option

format

which is to specify the one-line format as following:

ruby s3123456_p4.rb –api-key=”124FAfg$11s” –format oneline
{ “id”: 2, “first_name”: “Morgen”, “last_name”: “Woolbrook”, “email”:

“mwoolbrook1@google.co.jp”, “gender”: “Female”, “ip_address”: “97.54.135.234”, “send_date”: “2018-01-27T14:27:06Z”, “email_body”: “􏱄􏱅􏱆 􏱇􏱈􏱉􏱊􏱋􏱌􏱆􏱍”, “email_title”: “web-enabled” },

list

● In addition your script should check with a list of mappings between emails to SMS and MMS carriers. A sample mapping file “sms_mms_gateway.json” is provided. If there is a match, then the carrier will be included in the json output. For example

“sms_carrier”: ”United States: Verizon Wireless”

for someone with an email address xxxxxx@vtext.com, and “mms_carrier”: “France: Bouygues Telecom”
for someone with an email address xxxxx@mms.bouyguestelecom.fr.

Part 5

● Using ruby-lint to lint your code

o Install the ruby-lint gem https://github.com/YorickPeterse/ruby-lint

o Make sure you have zero lint warnings for your own code. (Some gems may intrigue lint warnings.)

o ruby-lint .rb
o ruby-lint s3123456_p3.rb
o ruby-lint s3123456_p4.rb # group submission only

s3123456_p2

Submission

– Check Canvas for update.

– This assignment will be using bitbucket to host all your script files

o https://bitbucket.org/

o Foranindividualsubmission,createaprivatereponamedas RAD18_Assign_1_indiv_{studentNumber}

o Foragroupsubmission,createaprivatereponamedas RAD18_Assign_1_group_{studentNumber_small}_{studentNumber_large}

ONLY ONE submission for each group is needed. For duplicate group submissions, we will randomly select one to mark.

o Makeabranchcalled“submission”

▪ We will use this branch to mark your assignment

o Invitethefollowingpeopleasdefaultreviewerstoyourproject

▪ junliang.jiang@rmit.edu.au
▪ anto.dominic@rmit.edu.au (TBC) ▪ andy.song@rmit.edu.au

o Makeapullrequesttomergeyourbranchsubmissiontobranchmaster

▪ include the following default reviewers (to ensure our access)

● junliang.jiang@rmit.edu.au
● anto.dominic@rmit.edu.au (TBC) ● andy.song@rmit.edu.au

o The due date: midnight of the 1st of April.

o A final submission before 27th March 0:00am will receive 20% bonus mark.

o Thisassignmentwillattractadditionalmarksforlabdemonstration.

o Foraprofessionaldeveloperwithnoknowledgeofnotogiri,theestimated workload is less than 12 hours per person.

– Warning

o YouwillreceiveZEROmarkifyoudon’thostyourassignmentinbitbucketbefore the due day.

o YouwillreceiveZEROmarkifyourscriptsfailtorunby

s3123456_p2

>> ruby .rb
>> ruby s3123456_p3.rb
>> ruby s3123456_p4.rb # group submission only