{"id":25430699,"url":"https://github.com/camilo-j/clivia-generator","last_synced_at":"2025-05-14T13:14:13.868Z","repository":{"id":77152821,"uuid":"582146116","full_name":"Camilo-J/Clivia-generator","owner":"Camilo-J","description":"Trivia game which asks ten random questions, and the user needs to choose the correct answer. Also, the user’s result will be saved and shown in the ranking.","archived":false,"fork":false,"pushed_at":"2022-12-25T21:41:50.000Z","size":9,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-17T03:41:23.065Z","etag":null,"topics":["api","oop","ruby"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Camilo-J.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-12-25T21:40:37.000Z","updated_at":"2023-02-02T00:00:10.000Z","dependencies_parsed_at":null,"dependency_job_id":"725ec7e7-30a4-4525-9fbb-9ff9afae160f","html_url":"https://github.com/Camilo-J/Clivia-generator","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Camilo-J%2FClivia-generator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Camilo-J%2FClivia-generator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Camilo-J%2FClivia-generator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Camilo-J%2FClivia-generator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Camilo-J","download_url":"https://codeload.github.com/Camilo-J/Clivia-generator/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254149995,"owners_count":22022853,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","oop","ruby"],"created_at":"2025-02-17T03:40:24.578Z","updated_at":"2025-05-14T13:14:13.863Z","avatar_url":"https://github.com/Camilo-J.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CLIvia generator\n\n## Start the program\n\nWhen the program starts, we will initialize the scores filename, the array of\nquestions, and the user's score.\n\nThe filename value is `scores.json` by default, but the user can pass a custom\nfilename as a command-line argument. For example\n`ruby clivia_generator.rb custom_scores.json`\n\n```\nruby clivia_generator.rb\n###################################\n#   Welcome to Clivia Generator   #\n###################################\nrandom | scores | exit\n\u003e\n```\n\n- Error message when invalid option: \"Invalid option\"\n\n## When \"random\" is selected\n\nYou should load **10** random questions from the API. Once they are loaded you\nwill show each of them **one by one**, allowing the user to select one of the\noptions.\n\nAnswers could come encoded with some special characters, use the\n[HTMLEntities](https://www.rubydoc.info/gems/htmlentities/4.3.2/HTMLEntities)\ngem to decode it, and show the text as expected.\n\n```\n###################################\n#   Welcome to Clivia Generator   #\n###################################\nrandom | scores | exit\n\u003e random\nCategory: History | Difficulty: medium\nQuestion: What was the capital of South Vietnam before the Vietnam War?\n1. Ho Chi Minh City\n2. Hue\n3. Saigon\n4. Hanoi\n\u003e \n```\n\nThe base_uri of the request is https://opentdb.com/, need more detail\non the API? Look at [here](https://opentdb.com/api_config.php)\n\nOnce the user gives an answer you should compare it with the correct answer\ndelivered by the API. Then give the user a correct or incorrect response\nmessage. If the user's answer was incorrect, you will show the correct answer.\nFinally, if the user's answer was correct we will increase their score by 10.\n\n```\n...\nCategory: History | Difficulty: medium\nQuestion: What was the capital of South Vietnam before the Vietnam War?\n1. Ho Chi Minh City\n2. Hue\n3. Saigon\n4. Hanoi\n\u003e 1\nHo Chi Minh City... Incorrect!\nThe correct answer was: Saigon\n```\n\nThen, continue showing the next questions you reach the end of the questions\narray.\n\n```\n...\n\u003e 1\nHo Chi Minh City... Incorrect!\nThe correct answer was: Saigon\nCategory: Entertainment: Musicals \u0026 Theatres | Difficulty: hard\nQuestion: In Les Misérables, who is Prison Code 24601?\n1. Javert\n2. Jean Claude Van Damme\n3. Jean Valjean\n4. Marius Pontmercy\n\u003e\n```\n\nOnce we get to the end of the questions, we will show the message\n`Well done! Your score is {score}` and then we will prompt the user to persist\nthe score.\n\n```\n...\nSeptember 2nd, 1945... Incorrect!\nThe correct answer was: May 9th, 1945\nCategory: Entertainment: Video Games | Difficulty: medium\nQuestion: In the Resident Evil series, Leon S. Kennedy is a member of STARS.\n1. True\n2. False\n\u003e 1\nTrue... Incorrect!\nThe correct answer was: False\nWell done! Your score is 30\n--------------------------------------------------\nDo you want to save your score? (y/n)\n```\n\nIf user types `n` or `N`, then the program will go back to the actions menu\n\n```\n...\nWell done! Your score is 30\n--------------------------------------------------\nDo you want to save your score? (y/n)\n\u003e n\n###################################\n#   Welcome to Clivia Generator   #\n###################################\nrandom | scores | exit\n\u003e\n```\n\n- Error message when invalid option: \"Invalid option\"\n\nIf the user types `y` or `Y`, then the program will prompt the user to assign a\nname to the score.\n\nOnce the name is given by the user, we will append the recent score to the file\npointed by the filename we declared at initialization, **this file should be a\nJSON and should start empty**.\n\nIn case the user didn't type a name, we will add the score as `\"Anonymous\"` to\nthe scores' file.\n\nFinally, show back the welcome message with the options menu.\n\n```\n...\nWell done! Your score is 30\n--------------------------------------------------\nDo you want to save your score? (y/n)\n\u003e y\nType the name to assign to the score\n\u003e Codeable\n###################################\n#   Welcome to Clivia Generator   #\n###################################\nrandom | scores | exit\n\u003e\n```\n\n\u003caside\u003e 💡 In case you are using JSON.parse within `File.read` to grab scores\ndata from the declared file, rescue `Errno::ENOENT` to take care of the error\nwhen the file is empty to be able to keep going. \u003c/aside\u003e\n\n## When scores action is selected\n\nLast but not least, when scores action is selected you should show the scores\nthat were saved previously, these scores should be shown in order from top to\nbottom and inside a table that includes the title `Top Scores`, and the headings\n`Name` ****and `Score`.\n\nOnce the table is shown, we will prompt the user with the welcome menu again so\nthey can keep going with another Clivia.\n\n```\n...\n###################################\n#   Welcome to Clivia Generator   #\n###################################\nrandom | scores | exit\n\u003e scores\n+-----------+-------+\n|    Top Scores     |\n+-----------+-------+\n| Name      | Score |\n+-----------+-------+\n| Deyvi     | 40    |\n| Diego     | 40    |\n| Wences    | 30    |\n| Anonymous | 20    |\n+-----------+-------+\n###################################\n#   Welcome to Clivia Generator   #\n###################################\nrandom | scores | exit\n\u003e\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcamilo-j%2Fclivia-generator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcamilo-j%2Fclivia-generator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcamilo-j%2Fclivia-generator/lists"}