{"id":19599356,"url":"https://github.com/harled/monocle","last_synced_at":"2025-07-13T02:04:47.389Z","repository":{"id":124481365,"uuid":"478576757","full_name":"harled/monocle","owner":"harled","description":"Esteemed insight for pundit exceptions.","archived":false,"fork":false,"pushed_at":"2025-03-04T18:10:48.000Z","size":3828,"stargazers_count":6,"open_issues_count":1,"forks_count":0,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-04-01T16:56:55.650Z","etag":null,"topics":["rails","ruby","ruby-gem","ruby-on-rails"],"latest_commit_sha":null,"homepage":"","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/harled.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","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-04-06T13:40:21.000Z","updated_at":"2025-03-04T18:10:49.000Z","dependencies_parsed_at":"2024-11-19T19:29:25.134Z","dependency_job_id":"a1afebc8-8b10-40bf-9d45-9e1e085d12df","html_url":"https://github.com/harled/monocle","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harled%2Fmonocle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harled%2Fmonocle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harled%2Fmonocle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harled%2Fmonocle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/harled","download_url":"https://codeload.github.com/harled/monocle/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251171441,"owners_count":21547112,"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":["rails","ruby","ruby-gem","ruby-on-rails"],"created_at":"2024-11-11T09:09:51.383Z","updated_at":"2025-04-27T16:32:05.261Z","avatar_url":"https://github.com/harled.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n\u003ch1 align=\"center\"\u003e\n  \u003cbr\u003e\n  \u003cimg src=\"monocle_logo.svg\" alt=\"Monocle\" width=\"200\"\u003e\n  \u003cbr\u003e\n  Monocle\n  \u003cbr\u003e\n\u003c/h1\u003e\n\nMonocle is a suite of [ViewComponents](https://github.com/github/view_component) to provide insights to your Buy on Rails application based on authorization exceptions generated by [Pundit](https://github.com/varvet/pundit).\n\nThis information can help improve security and useability. You and your team will be surprised to see what you can learn from 401 Unauthorized!\n\n\u003cimg src=\"monocle_dashboard.gif\" alt=\"Monocle Dashboard\"\u003e\n\n## Dependencies\nMonocle depends on the following libraries:\n\n* [ViewComponent](https://github.com/ViewComponent/view_component)\n* [Bootstrap](https://getbootstrap.com/docs/5.3/getting-started/introduction/)\n* [Groupdate](https://github.com/ankane/groupdate)\n* [ApexCharts](https://www.npmjs.com/package/apexcharts)\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\n# Gemfile\ngem 'monocle'\n```\n\nAnd then execute:\n\n    $ bundle install\n\nOr install it yourself as:\n\n    $ gem install monocle\n\nTo generate the migration and build the data model, run:\n\n```base\nrails generate monocle:authorization_exceptions\nrails db:migrate\n```\n\n## Usage\nOnce you have Monocle loaded you can render any of its view components. For example, you could render the `Monocle::ControllersOverTimeComponent` with:\n\n```erb\n\u003c%= render Monocle::ControllersOverTimeComponent.new(events: AuthorizationException.all) %\u003e\n```\n\nWith a full list of components here:\n|Component|Purpose|\n|---------|-------|\n|ControllersOverTimeComponent|Shows the number of events over time.|\n|HighestControllerActionCountComponent|Shows the controller endpoint which has caused the most authorization exceptions given the events passed in.|\n|ExceptionsByControllerComponent|Shows the number of events grouped by controller name.\n|ExceptionsByRequestComponent|Shows the number of events grouped by request.|\n|ExceptionsByUserComponent|Shows the number of events grouped by user id.|\n|ExceptionsSinceTimeAgoComponent|Shows the number of exceptions over a specified period of time and the percentage increase over time.|\n|TopTenUsersComponent|Shows the top ten users in terms of who caused most authorization exceptions.|\n|UsersAffectedSinceTimeAgoComponent|Shows the number of users affected over a given time period.|\n\nFor more information about each view component, including the method signature, look for the `.rb` files in the `app/components/monocle` directory.\n\n## Development\n\nMonocle development is made easy with vscode [devcontainers](https://containers.dev/). Once the repo has been checked out, open the project in a devcontainer and \nthen open a new terminal.\n\n```bash\n# install required packages\nbin/setup\n\n# install spec/sample packages\nbundle install --gemfile spec/sample/Gemfile\n\n# run test cases and ensure everything is passing\nrake spec\n\n# an interactive prompt that will allow you to experiment with monocle\nbin/console\n```\n\nTo install this gem onto your local machine, run `bundle exec rake install`. \n\n### Sample Application\n\nViewComponents are pretty hard to test without a Ruby on Rails application. This repository includes a sample application that makes it easy to see how a component renders and make quick adjustments.\n\nTo use the sample application: \n\n```bash\n# change directory to the sample project\ncd spec/sample\n\n# install packages (if not already done)\nbundle install\n\n# migrate the database\nrails db:migrate\n\n# seed data with mock exceptions (optionally pass count= environment variable for the number of records to create, default is 100)\nrails db:seed\n\n# run the server\nbundle exec rails server\n\n# open your browser to localhost:3000\n```\n\n\n## Release\n\nTo release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\nBug reports and pull requests are welcome on GitHub at https://github.com/harled/monocle. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.\n\n### Contribution Steps:\n\nWant to help us out? Here are some steps to make sure you are contributing\n\n1. Find an issue you like, or create a new issue here\nPlease ask for any questions or clarifications in the associated issues or in new issues! 🤔\n2. Assign yourself to the issue and create a branch , following GitHub Issue's naming scheme. 🛠️\nThe naming scheme should follow (#issueNumber-issue-name) ie. (#10-create-new-component)\n3. Get on your local machine and ensure you have the repo cloned. Checkout the branch you just made with git checkout branch-name and pull the latest merged changes from the repo with git pull origin main to make sure you have the most up-to-date code from the repo. 👩‍💻\n4. Add your amazing changes along with any documentation you feel would be useful. Then commit and push your changes. 🌟\n5. Go back to the repo on GitHub and create a pull request! Then wait for an admin of the repo to get back to your pull request, address any comments and once you are finally approved, merge your code into Monocle! 🎉\n\nIf you want some more tips on contributing to GitHub projects, check out this resource from Data School.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n\n## Code of Conduct\n\nEveryone interacting in the Monocle project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](CODE_OF_CONDUCT.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fharled%2Fmonocle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fharled%2Fmonocle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fharled%2Fmonocle/lists"}