{"id":18605591,"url":"https://github.com/lolcommits/lolcommits-sample_plugin","last_synced_at":"2026-02-15T19:08:15.738Z","repository":{"id":56882184,"uuid":"78373029","full_name":"lolcommits/lolcommits-sample_plugin","owner":"lolcommits","description":"Example code for lolcommits plugin development","archived":false,"fork":false,"pushed_at":"2025-02-16T23:45:05.000Z","size":117,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-11-08T15:22:10.971Z","etag":null,"topics":["fun","git","git-addons","humor","lolcommits","lolcommits-plugin","ruby","selfie","webcam"],"latest_commit_sha":null,"homepage":"https://lolcommits.github.io/","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lolcommits.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","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,"zenodo":null}},"created_at":"2017-01-08T21:56:10.000Z","updated_at":"2024-12-29T23:57:28.000Z","dependencies_parsed_at":"2025-04-11T06:06:05.365Z","dependency_job_id":"7fc11b29-6556-459b-8969-3d3b24e7f84b","html_url":"https://github.com/lolcommits/lolcommits-sample_plugin","commit_stats":{"total_commits":77,"total_committers":1,"mean_commits":77.0,"dds":0.0,"last_synced_commit":"0639b6d12a9638a0528afd21c4f829243f2384e4"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/lolcommits/lolcommits-sample_plugin","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lolcommits%2Flolcommits-sample_plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lolcommits%2Flolcommits-sample_plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lolcommits%2Flolcommits-sample_plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lolcommits%2Flolcommits-sample_plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lolcommits","download_url":"https://codeload.github.com/lolcommits/lolcommits-sample_plugin/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lolcommits%2Flolcommits-sample_plugin/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29487404,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-15T15:33:17.885Z","status":"ssl_error","status_checked_at":"2026-02-15T15:32:53.698Z","response_time":118,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["fun","git","git-addons","humor","lolcommits","lolcommits-plugin","ruby","selfie","webcam"],"created_at":"2024-11-07T02:22:13.130Z","updated_at":"2026-02-15T19:08:15.697Z","avatar_url":"https://github.com/lolcommits.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Lolcommits Sample Plugin\n\n[![CI](https://img.shields.io/github/actions/workflow/status/lolcommits/lolcommits-sample_plugin/ci.yml?branch=main\u0026style=flat\u0026label=CI)](https://github.com/lolcommits/lolcommits-sample_plugin/actions/workflows/ci.yml)\n[![Gem](https://img.shields.io/gem/v/lolcommits-sample_plugin.svg?style=flat)](http://rubygems.org/gems/lolcommits-sample_plugin)\n[![Depfu](https://img.shields.io/depfu/lolcommits/lolcommits-sample_plugin.svg?style=flat)](https://depfu.com/github/lolcommits/lolcommits-sample_plugin)\n\n[lolcommits](https://lolcommits.github.io/) takes a snapshot with your webcam\nevery time you git commit code, and archives a lolcat style image with it. Git\nblame has never been so much fun!\n\nLolcommit plugins allow developers to add features by running code before or\nafter snapshots are taken. Installed plugin gems are automatically loaded before\nthe capturing process starts.\n\nThis gem showcases an example plugin. It prints short messages to the screen\nbefore and after every lolcommit. After configuring the plugin to be enabled,\nyou'll see something like this for a capture:\n\n    ✨  Say cheese 😁 !\n    *** Preserving this moment in history.\n    📸  Snap\n    wow! 9e6303c at /path/to/lolcommit.jpg is your best looking commit yet!\n    (it was an image!)\n\nUse this repo to jump-start development on your own plugin. It has tests, docs\nand hooks with useful tools; CI, Rdoc etc.\n\n## Developing your own plugin\n\nFirst, there are some things your gem *must* do to be loaded and executed:\n\n* The gem name must have a `lolcommits-` prefix.\n* Require `lolcommits` in your `gemspec` file as a development\n  dependency.\n* Include a class that inherits from `Lolcommits::Plugin::Base` (this\n  will be the entry point to your plugin from the lolcommits gem).\n* This main plugin class must meet the requirements explained below.\n\n### Your Plugin Class\n\nYou plugin class must have a namespace and path that matches your gem name and\nbe in the gem's `LOAD_PATH`.\n\n    # for a gem named lolcommits-zapier you should have a plugin class:\n    class Lolcommits::Plugin::Zapier \u003c Lolcommits::Plugin::Base\n      ...\n    end\n    # at lib/lolcommits/plugin/zapier.rb\n    # required in a file at lib/lolcommits/zapier.rb\n\n    # or a gem named lolcommits-super_awesome should have a plugin class:\n    class Lolcommits::Plugin::SuperAwesome \u003c Lolcommits::Plugin::Base\n      ...\n    end\n    # at lib/lolcommits/plugin/super_awesome.rb\n    # required in a file at lib/lolcommits/super_awesome.rb\n\nThe following methods can be overridden to execute code during the capture\nprocess:\n\n* `run_pre_capture` - executes before the capture starts, at this point\n  you could alter the commit message/sha text.\n* `run_post_capture` - executes immediately after the camera captures,\n  use this hook to manipulate the image (e.g. resize, apply filters,\n  annotate).\n* `run_capture_ready` - executes after all `run_post_capture` hooks have\n  ran, at this point we consider the capture to be ready for exporting\n  or sharing.\n\n### Plugin configuration\n\nAvailable options can be defined in an Array (`@options` instance var) and/or a\nHash (by overriding the `default_options` method).\n\nBy default (on initialize), `@options` will be set to `[:enabled]`. This option\nis mandatory since `enabled?` checks `configuration[:enabled] == true` before\nany capture hooks can run.\n\nUsing a Hash to define default options allows you to:\n\n- fall back to default values (or nil) if the user enters nothing when\n  prompted\n- define nested options (the user is prompted for each nested option\n  key)\n\n`configure_option_hash` will iterate over all options prompting the user for\ninput while building the configuration Hash.\n\nLolcommits will save this Hash to a YAML file. During the capture process the\nconfiguration is loaded, parsed and available in the plugin class as\n`configuration`. Or if you want to fall back to default values, you should use\nthe `config_option` method to dig into the Hash.\n\nAlternatively you can override these methods to fully customise the\nconfiguration process.\n\n* `def configure_options!` - by default this prompts the user for option\n  values (based on option names in the `@options` array and/or\n  `default_options`) and returns a Hash that will be persisted.\n* `def enabled?` - by default checks if `configuration[:enabled] ==\n  true` to determine if the plugin should run.\n* `def valid_configuration?`- checks the persisted config Hash is valid.\n\nBy default a plugin will only run it's capture hooks if:\n\n* `valid_configuration?` returns true\n* `enabled?` returns true\n\nA `parse_user_input` method is available to help parse strings from STDIN to\nRuby objects (e.g. boolean, integer or nil).\n\nDuring plugin configuration, your plugin class will be initialized with the\noptional `config` argument (and no runner). This allows you to read the existing\nsaved options during configuration. E.g. to show existing options back to the\nuser, allowing you to ask if they want to keep or change an option if\nreconfiguring.\n\n__NOTE__: If your plugin does not require configuration and should be enabled by\ndefault (on gem install) you could override the `enabled?` method to always\nreturn `true`. Simply uninstalling the gem will disable the plugin.\n\nFor more help, check out [the\ndocumentation](http://www.rubydoc.info/github/lolcommits/lolcommits-sample_plugin/Lolcommits/Plugin/SamplePlugin)\nfor this plugin, or take a look at [other\nlolcommit_plugins](https://github.com/search?q=topic%3Alolcommits-plugin+org%3Alolcommits\u0026type=Repositories)\nin the wild.\n\n### The Lolcommits 'runner'\n\nThe only required argument for your plugin class initializer is a\n[Lolcommits::Runner](https://github.com/lolcommits/lolcommits/blob/master/lib/lolcommits/runner.rb)\ninstance. By default, the base plugin initializer will set this in the `runner`\ninstance var for use in your plugin's code.\n\n* `runner.message` - the commit message\n* `runner.sha` - the sha for the current commit\n* `runner.vcs_info` - a reference to the\n  [Lolcommits::VCSInfo](https://github.com/lolcommits/lolcommits/blob/master/lib/lolcommits/vcs_info.rb)\n  instance\n* `runner.config` - a reference to the\n  [Lolcommits::Configuration](https://github.com/lolcommits/lolcommits/blob/master/lib/lolcommits/configuration.rb)\n  instance\n* `runner.overlay` - blank transparent PNG (`MiniMagick::Image` instance)\n* `runner.lolcommits_path` - the processed lolcommit file path (jpg, mp4 or gif)\n* `runner.lolcommits_gif_path` - the processed lolcommit animated gif path (may be `nil`)\n* `runner.capture_video` - `true` when a video capture was generated\n* `runner.capture_gif` - `true` when an animated gif capture was generated\n* `runner.capture_image` - `true` when an image (jpg) was captured, false for gifs/videos\n\nAfter the capturing process completes, (i.e. in `run_post_capture` or\n`run_capture_ready` hooks) use `runner.lolcommit_path` to access the lolcommit\nfile (jpg, mp4 or gif).\n\n__NOTE__: it is possible for both an animated gif *AND* video to be generated,\nin this case `lolcommits_path` points to the `mp4` video and\n`runner.lolcommits_gif_path` points to the animated `gif`.\n\nTake a look at\n[Lolcommits::Runner](https://github.com/lolcommits/lolcommits/blob/master/lib/lolcommits/runner.rb)\nfor more details.\n\n#### Overlay PNG\n\nAfter capturing (and resizing), the\n[runner](https://github.com/lolcommits/lolcommits/blob/master/lib/lolcommits/runner.rb)\nprovides a blank (transparent) PNG for plugins to manipulate. It matches the\nwidth and height of the lolcommit capture.\n\nTo make use of this `runner.overlay`, reference it in any `post_capture` hook.\nYou can use any `MiniMagick::Image`\n[utility](http://rubydoc.info/github/minimagick/minimagick) method. For example\nthe [lolcommits-loltext](https://github.com/lolcommits/lolcommits-loltext)\nplugin annotates text, a border and overlay colour\n[here](https://github.com/lolcommits/lolcommits-loltext/blob/master/lib/lolcommits/plugin/loltext.rb#L74).\n\nAfter all `post_capture` hooks finish, this overlay PNG is composited on top of\nthe snapshot and the final lolcommit file is available at\n`runner.lolcommit_path` for `capture_ready` hooks to use.\n\n### Testing your plugin\n\nTo make test setup easier, the lolcommits gem includes these helpers to\nwork with command line IO and Git.\n\n    # add one (or both) of these to your plugin's test_helper file\n    require 'lolcommits/test_helpers/git_repo'\n    require 'lolcommits/test_helpers/fake_io'\n\n    # and include either (or both) modules in your test\n    include Lolcommits::TestHelpers::GitRepo\n    include Lolcommits::TestHelpers::FakeIO\n\nUse the following methods to manage a test repo:\n\n    setup_repo               # create the test repo\n    commit_repo_with_message # perform a git commit in the test repo\n    last_commit              # commit info for the last test repo commit\n    teardown_repo            # destroy the test repo\n    in_repo(\u0026block)          # run lolcommits within the test repo\n\nFor STDIN and capturing IO use the `fake_io_capture` method.\n\n    # capture the output of the `configure_options` method, sending the\n    # string input 'true' (followed by a carriage return) to STDIN:\n    output = fake_io_capture(inputs: %w(true)) do\n      configured_plugin_options = plugin.configure_options!\n    end\n\nFor more examples take a look at the [tests in this\nrepo](https://github.com/lolcommits/lolcommits-sample_plugin/blob/master/test/lolcommits/plugin/sample_plugin_test.rb).\n\n### General advice\n\n* Use this gem as a starting point, renaming files, classes etc.\n* For more examples, take a look at other published [lolcommit\n  plugins](https://github.com/lolcommits).\n* If you feel something is missing (or out of date) in this guide. Post\n  an\n  [issue](https://github.com/lolcommits/lolcommits-sample_plugin/issues).\n\n---\n\n## Requirements\n\n* Ruby \u003e= 3.1\n* A webcam\n* [ImageMagick](http://www.imagemagick.org)\n* [ffmpeg](https://www.ffmpeg.org) (optional) for animated gif capturing\n\n## Installation\n\nFollow the [install\nguide](https://github.com/lolcommits/lolcommits#installation) for lolcommits\nfirst. Then run the following:\n\n    $ gem install lolcommits-sample_plugin\n\nNext configure and enable this plugin with:\n\n    $ lolcommits --config -p sample_plugin\n    # set enabled to `true` and configure other options as you like\n\nThat's it! Every lolcommit now comes with it's own emoji themed commentary!\n\n## Development\n\nCheck out this repo and run `bin/setup`, this will install dependencies and\ngenerate docs. Run `bundle exec rake` to run all tests.\n\nYou can also run `bin/console` for an interactive prompt that will allow you to\nexperiment with the gem code.\n\n## Tests\n\nMiniTest is used for testing. Run the test suite with:\n\n    $ rake test\n\n## Docs\n\nGenerate docs for this gem with:\n\n    $ rake rdoc\n\n## Troubles?\n\nIf you think something is broken or missing, please raise a new\n[issue](https://github.com/lolcommits/lolcommits-sample_plugin/issues).  Take a\nmoment to check it hasn't been raised in the past (and possibly closed).\n\n## Contributing\n\nBug [reports](https://github.com/lolcommits/lolcommits-sample_plugin/issues) and\n[pull requests](https://github.com/lolcommits/lolcommits-sample_plugin/pulls)\nare welcome on GitHub.\n\nWhen submitting pull requests, remember to add tests covering any new behaviour,\nand ensure all tests are passing on CI. Read the [contributing\nguidelines](https://github.com/lolcommits/lolcommits-sample_plugin/blob/master/CONTRIBUTING.md)\nfor more details.\n\nThis project is intended to be a safe, welcoming space for collaboration, and\ncontributors are expected to adhere to the [Contributor\nCovenant](http://contributor-covenant.org) code of conduct.  See\n[here](https://github.com/lolcommits/lolcommits-sample_plugin/blob/master/CODE_OF_CONDUCT.md)\nfor more details.\n\n## License\n\nThe gem is available as open source under the terms of\n[LGPL-3](https://opensource.org/licenses/LGPL-3.0).\n\n## Links\n\n* [CI](https://github.com/lolcommits/lolcommits-sample_plugin/actions/workflows/ci.yml)\n* [RDoc](https://rubydoc.info/gems/lolcommits-sample_plugin)\n* [Issues](http://github.com/lolcommits/lolcommits-sample_plugin/issues)\n* [Report a bug](http://github.com/lolcommits/lolcommits-sample_plugin/issues/new)\n* [Gem](http://rubygems.org/gems/lolcommits-sample_plugin)\n* [GitHub](https://github.com/lolcommits/lolcommits-sample_plugin)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flolcommits%2Flolcommits-sample_plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flolcommits%2Flolcommits-sample_plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flolcommits%2Flolcommits-sample_plugin/lists"}