{"id":15468634,"url":"https://github.com/workgena/sp_test_ruby","last_synced_at":"2025-10-11T21:30:45.768Z","repository":{"id":46178508,"uuid":"423106856","full_name":"workgena/sp_test_ruby","owner":"workgena","description":"Practice","archived":true,"fork":false,"pushed_at":"2021-11-09T09:35:03.000Z","size":317,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-29T04:36:05.274Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/workgena.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-10-31T09:42:49.000Z","updated_at":"2024-06-27T06:41:03.000Z","dependencies_parsed_at":"2022-09-22T07:01:01.275Z","dependency_job_id":null,"html_url":"https://github.com/workgena/sp_test_ruby","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/workgena/sp_test_ruby","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/workgena%2Fsp_test_ruby","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/workgena%2Fsp_test_ruby/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/workgena%2Fsp_test_ruby/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/workgena%2Fsp_test_ruby/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/workgena","download_url":"https://codeload.github.com/workgena/sp_test_ruby/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/workgena%2Fsp_test_ruby/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279008860,"owners_count":26084518,"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","status":"online","status_checked_at":"2025-10-11T02:00:06.511Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2024-10-02T01:41:47.953Z","updated_at":"2025-10-11T21:30:45.466Z","avatar_url":"https://github.com/workgena.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# sp_test_ruby\n\n* main - implementation with Array data structure\n* [Pull Request #1](https://github.com/workgena/sp_test_ruby/pull/1) - implementation with Hash data structure\n\n## How to run\n\n```\n$ ./parser.rb webserver.log\n  -- or --\n$ ruby parser.rb webserver.log\n```\n\n## Example output\n\n`$ ./parser.rb webserver.log`\n\n```\n\u003e list of webpages with most page views ordered from most pages views to less page views\n  /about/2             90   visits\n  /contact             89   visits\n  /index               82   visits\n  /about               81   visits\n  /help_page/1         80   visits\n  /home                78   visits\n\n\u003e list of webpages with most unique page views also ordered\n  /index               23   unique views\n  /home                23   unique views\n  /contact             23   unique views\n  /help_page/1         23   unique views\n  /about/2             22   unique views\n  /about               21   unique views\n```\n\n## Explanations\n\n- I've chose `File.each_line` to reduce memory usage\n- Core Data Structure to store \"pages\" is Array. It's not efficient, and can be replaced with HashMap in the future. HashMap makes insertion faster, but require conversion to Array when sorting. This change should be easy - #1\n- Why sort_by() + reverse() - [performance is acceptable](https://stackoverflow.com/a/2651028), can be changed just to sort_by with a block\n- `printf \"%-20s %-4s visits\\n\"` is not robust solution, but don't want to spend to match time on it\n\n## TODOs\n\n- Check performance with bigger files, compare to HashMap data structure\n- Security: prevent reading files from other directories\n- GitHub Action for RSpec and Rubocpo\n- Wrap every class with module (e.g. `WebserverLogReader::`)\n\n## Coverage snapshot\n\n![coverage_snapshot](./coverage_snapshot.png)\n\n- parser.rb\n- lib/formatter/cli_by_unique_views.rb\n- lib/formatter/cli_by_views.rb\n\nThose files are not covered, because they are related to presentation, not the logic. But mainly - lack of time.\n\n\n### Development\n\nInstall, run tests, run linter, run script itself\n\n```\n$ bundle\n$ bundle exec rspec\n$ bundle exec rubocop -a\n$ ruby parser.rb webserver.log\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fworkgena%2Fsp_test_ruby","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fworkgena%2Fsp_test_ruby","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fworkgena%2Fsp_test_ruby/lists"}