{"action":"created","comment":{"url":"https://api.github.com/repos/bundler/bundler-site/pulls/comments/191787284","pull_request_review_id":124428649,"id":191787284,"diff_hunk":"@@ -0,0 +1,228 @@\n+---\n+title: How to write a Bundler plugin\n+---\n+\n+.container.guide\n+  %h1#how-to-write-a-bundler-plugin\n+    How to write a Bundler plugin\n+\n+  %h2#what-is-a-plugin\n+    What is a plugin?\n+\n+  .contents\n+    .bullet\n+      .description\n+        Bundler plugins are specialized gems that are aimed at integrating and extending Bundler's functionality.\n+\n+        This guide aims to be a getting started guide about writing these plugins.\n+\n+  %h2#why-would-i-use-a-plugin\n+    Why would I use a plugin?\n+\n+  .contents\n+    .bullet\n+      .description\n+      Plugins are able to integrate with and extend Bundler. Currently, plugins are able to:\n+\n+      %p\n+        Currently, a plugin is able to:\n+\n+      %ul\n+        %li\n+          Add commands to Bundler (e.g. <code>bundle my_command</code>)\n+        %li\n+          Add a special handler to install a gem (e.g. Mercurial or SVN)\n+        %li\n+          Add functionality to specific hook points:\n+\n+          %ul\n+\n+            %li\n+              A list of all available hooks, their descriptions, and their block arguments are available\n+\n+              = link_to 'in the plugin/events.rb file.', 'https://github.com/bundler/bundler/blob/master/lib/bundler/plugin/events.rb'\n+\n+            %li\n+              Note: Make sure to check out the <code>events.rb</code> file at the version of bundler you are using.\n+\n+\n+  %h2#using-a-plugin\n+    Using a Plugin\n+\n+  .contents\n+    .bullet\n+      .description\n+\n+      %h4#install_from_command\n+        Install a Plugin from a command\n+\n+      %p\n+        Plugins can be install from RubyGems (default) or from a Git server. To use a gem on your machine, you can run <code>bundler plugin install <gem_name></code>. Once the plugin is installed, the commands will be available for use and the hooks will be automatically registered with Bundler.\n+\n+      %p\n+        Run <code>bundler plugin help install</code> for more details help and instructions on installing from Git.\n+\n+      %h4#install_from_command\n+        Install a Plugin from your Gemfile\n+\n+      %p\n+        You can also specify a plugin in your Gemfile\n+\n+      :code\n+        # lang: ruby\n+        plugin 'my_plugin' # Installs from Rubygems\n+        plugin 'my_plugin', path: '/path/to/plugin' # Installs from a path\n+        plugin 'my_plugin', git: 'https://github.com:repo/my_plugin.git' # Installs from Git\n+  %h2#getting-started-with-development\n+    Getting started with development\n+\n+  .contents\n+    .bullet\n+      .description\n+      To make a Bundler plugin, you need to create a specialized gem. Follow these steps to build the base gem:\n+\n+      %h3#create-a-gem\n+        1. Create a Gem\n+\n+      = link_to 'Create a gem using this guide', './guides/creating_gem.html'\n+      \n+      %h3#plugins_rb\n+        2. plugins.rb\n+\n+      %p\n+        A <code>plugins.rb</code> file is located at the top level of your gem and is the entrypoint Bundler will use to call your plugin. This is a Ruby file that defines your commands, hooks, and other code. Often, you may just require the gem's upper-most lib file.\n+\n+      %p\n+        For example, if your gem is called \"my_plugin\", you might have a file at <code>lib/my_plugin.rb</code> which contains the highest level namespace for your gem. Your <code>plugins.rb</code> file might be:\n+\n+        :code\n+          # lang: ruby\n+          require 'my_plugin'\n+      %p\n+        The <code>lib/my_plugin.rb</code> file would include other require statements, hooks, and commands similar to a normal gem.\n+      %h3#developing_your_plugin_commands\n+        3. Developing your Plugin: Making Bundler Commands\n+\n+      %p\n+        Bundler commands allow you to extend the Bundler interface with additional functionality.\n+\n+      %p\n+        To add a Bundler command, you need to make a class that registers itself (or another class) as a command. For example, to add support for a <code>bundler my_command</code> command, you might have a class like so:\n+\n+      :code\n+        # lang: ruby\n+        class MyCommand < Bundler::Plugin::API\n+          # Register this class as a handler for the `my_command` command\n+          command \"my_command\"\n+\n+          # The exec method will be called with the `command` and the `args`.\n+          # This is where you should handle all logic and functionality\n+          def exec(command, args)\n+            puts \"You called \" + command + \" with args: \" + args.inspect\n+          end\n+        end\n+      or\n+\n+      :code\n+        # lang: ruby\n+        module MyCommand\n+          # Register this class as a handler for the `my_command` command\n+          Bundler::Plugin::API.command('my_command', self)\n+\n+          # The exec method will be called with the `command_name` and the `args`.\n+          # This is where you should handle all logic and functionality\n+          def exec(command_name, args)\n+            puts \"You called \" + command_name + \" with args: \" + args.inspect\n+          end\n+        end\n+      %p\n+        There are two important parts for a command to be registered to Bundler:\n+\n+      %ol\n+        %li\n+          <code>Bundler::Plugin::API.command(COMMAND_NAME, CLASS)</code> or <code>command 'COMMAND_NAME'</code> is called, depending on the method used (see examples above)\n+        %li\n+          The class defines the instance method <code>exec(command_name, args)</code>\n+\n+      %h3#developing_your_plugin_hooks\n+        4. Developing your Plugin: Using Bundler Hooks\n+\n+      %p\n+        To interface with various parts of Bundler, you can use a hook. Hooks will let you inject some functionality at specific events by registering to listen for specific things to happen. To listen to an event, you need to add a hook for it and provide a block.\n+\n+      %p\n+        For example, for a <code>before-install-all</code> hook you must give a block that has an argument for an Array of <code>Bundler::Dependency</code> objects","path":"source/v1.16/guides/bundler_plugins.html.haml","position":154,"original_position":154,"commit_id":"cd3b4e3010dab29ce6a4d97666c9ded0a5660e1f","original_commit_id":"cd3b4e3010dab29ce6a4d97666c9ded0a5660e1f","user":{"login":"rubymorillo","id":3386562,"avatar_url":"https://avatars0.githubusercontent.com/u/3386562?v=4","gravatar_id":"","url":"https://api.github.com/users/rubymorillo","html_url":"https://github.com/rubymorillo","followers_url":"https://api.github.com/users/rubymorillo/followers","following_url":"https://api.github.com/users/rubymorillo/following{/other_user}","gists_url":"https://api.github.com/users/rubymorillo/gists{/gist_id}","starred_url":"https://api.github.com/users/rubymorillo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rubymorillo/subscriptions","organizations_url":"https://api.github.com/users/rubymorillo/orgs","repos_url":"https://api.github.com/users/rubymorillo/repos","events_url":"https://api.github.com/users/rubymorillo/events{/privacy}","received_events_url":"https://api.github.com/users/rubymorillo/received_events","type":"User","site_admin":true},"body":"add a colon after \"objects\"","created_at":"2018-05-30T14:22:58Z","updated_at":"2018-05-30T14:22:58Z","html_url":"https://github.com/bundler/bundler-site/pull/380#discussion_r191787284","pull_request_url":"https://api.github.com/repos/bundler/bundler-site/pulls/380","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/bundler/bundler-site/pulls/comments/191787284"},"html":{"href":"https://github.com/bundler/bundler-site/pull/380#discussion_r191787284"},"pull_request":{"href":"https://api.github.com/repos/bundler/bundler-site/pulls/380"}}},"pull_request":{"url":"https://api.github.com/repos/bundler/bundler-site/pulls/380","id":190464271,"html_url":"https://github.com/bundler/bundler-site/pull/380","diff_url":"https://github.com/bundler/bundler-site/pull/380.diff","patch_url":"https://github.com/bundler/bundler-site/pull/380.patch","issue_url":"https://api.github.com/repos/bundler/bundler-site/issues/380","number":380,"state":"open","locked":false,"title":"Add plugin docs to guides","user":{"login":"jules2689","id":3074765,"avatar_url":"https://avatars2.githubusercontent.com/u/3074765?v=4","gravatar_id":"","url":"https://api.github.com/users/jules2689","html_url":"https://github.com/jules2689","followers_url":"https://api.github.com/users/jules2689/followers","following_url":"https://api.github.com/users/jules2689/following{/other_user}","gists_url":"https://api.github.com/users/jules2689/gists{/gist_id}","starred_url":"https://api.github.com/users/jules2689/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jules2689/subscriptions","organizations_url":"https://api.github.com/users/jules2689/orgs","repos_url":"https://api.github.com/users/jules2689/repos","events_url":"https://api.github.com/users/jules2689/events{/privacy}","received_events_url":"https://api.github.com/users/jules2689/received_events","type":"User","site_admin":false},"body":"Thanks so much for the contribution!\r\nTo make reviewing this PR a bit easier, please fill out answers to the following questions.\r\n\r\n### What was the end-user problem that led to this PR?\r\n\r\nThere were no docs on `bundler plugin`\r\n\r\n### What was your diagnosis of the problem?\r\n\r\nThere were simply no docs\r\n\r\n### What is your fix for the problem, implemented in this PR?\r\n\r\nI wrote the docs\r\n\r\n![screenshot of the docs](https://user-images.githubusercontent.com/3074765/40524099-a1393a00-5fa6-11e8-85de-74513b932875.png)\r\n","created_at":"2018-05-25T02:06:56Z","updated_at":"2018-05-30T14:22:58Z","closed_at":null,"merged_at":null,"merge_commit_sha":"cdf5d2198713c08fedaab2f339ce675be4f6772b","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/bundler/bundler-site/pulls/380/commits","review_comments_url":"https://api.github.com/repos/bundler/bundler-site/pulls/380/comments","review_comment_url":"https://api.github.com/repos/bundler/bundler-site/pulls/comments{/number}","comments_url":"https://api.github.com/repos/bundler/bundler-site/issues/380/comments","statuses_url":"https://api.github.com/repos/bundler/bundler-site/statuses/cd3b4e3010dab29ce6a4d97666c9ded0a5660e1f","head":{"label":"bundler:jules2689/plugins","ref":"jules2689/plugins","sha":"cd3b4e3010dab29ce6a4d97666c9ded0a5660e1f","user":{"login":"bundler","id":1137638,"avatar_url":"https://avatars0.githubusercontent.com/u/1137638?v=4","gravatar_id":"","url":"https://api.github.com/users/bundler","html_url":"https://github.com/bundler","followers_url":"https://api.github.com/users/bundler/followers","following_url":"https://api.github.com/users/bundler/following{/other_user}","gists_url":"https://api.github.com/users/bundler/gists{/gist_id}","starred_url":"https://api.github.com/users/bundler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bundler/subscriptions","organizations_url":"https://api.github.com/users/bundler/orgs","repos_url":"https://api.github.com/users/bundler/repos","events_url":"https://api.github.com/users/bundler/events{/privacy}","received_events_url":"https://api.github.com/users/bundler/received_events","type":"Organization","site_admin":false},"repo":{"id":587923,"name":"bundler-site","full_name":"bundler/bundler-site","owner":{"login":"bundler","id":1137638,"avatar_url":"https://avatars0.githubusercontent.com/u/1137638?v=4","gravatar_id":"","url":"https://api.github.com/users/bundler","html_url":"https://github.com/bundler","followers_url":"https://api.github.com/users/bundler/followers","following_url":"https://api.github.com/users/bundler/following{/other_user}","gists_url":"https://api.github.com/users/bundler/gists{/gist_id}","starred_url":"https://api.github.com/users/bundler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bundler/subscriptions","organizations_url":"https://api.github.com/users/bundler/orgs","repos_url":"https://api.github.com/users/bundler/repos","events_url":"https://api.github.com/users/bundler/events{/privacy}","received_events_url":"https://api.github.com/users/bundler/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/bundler/bundler-site","description":"The Bundler documentation website","fork":false,"url":"https://api.github.com/repos/bundler/bundler-site","forks_url":"https://api.github.com/repos/bundler/bundler-site/forks","keys_url":"https://api.github.com/repos/bundler/bundler-site/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bundler/bundler-site/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bundler/bundler-site/teams","hooks_url":"https://api.github.com/repos/bundler/bundler-site/hooks","issue_events_url":"https://api.github.com/repos/bundler/bundler-site/issues/events{/number}","events_url":"https://api.github.com/repos/bundler/bundler-site/events","assignees_url":"https://api.github.com/repos/bundler/bundler-site/assignees{/user}","branches_url":"https://api.github.com/repos/bundler/bundler-site/branches{/branch}","tags_url":"https://api.github.com/repos/bundler/bundler-site/tags","blobs_url":"https://api.github.com/repos/bundler/bundler-site/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bundler/bundler-site/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bundler/bundler-site/git/refs{/sha}","trees_url":"https://api.github.com/repos/bundler/bundler-site/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bundler/bundler-site/statuses/{sha}","languages_url":"https://api.github.com/repos/bundler/bundler-site/languages","stargazers_url":"https://api.github.com/repos/bundler/bundler-site/stargazers","contributors_url":"https://api.github.com/repos/bundler/bundler-site/contributors","subscribers_url":"https://api.github.com/repos/bundler/bundler-site/subscribers","subscription_url":"https://api.github.com/repos/bundler/bundler-site/subscription","commits_url":"https://api.github.com/repos/bundler/bundler-site/commits{/sha}","git_commits_url":"https://api.github.com/repos/bundler/bundler-site/git/commits{/sha}","comments_url":"https://api.github.com/repos/bundler/bundler-site/comments{/number}","issue_comment_url":"https://api.github.com/repos/bundler/bundler-site/issues/comments{/number}","contents_url":"https://api.github.com/repos/bundler/bundler-site/contents/{+path}","compare_url":"https://api.github.com/repos/bundler/bundler-site/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bundler/bundler-site/merges","archive_url":"https://api.github.com/repos/bundler/bundler-site/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bundler/bundler-site/downloads","issues_url":"https://api.github.com/repos/bundler/bundler-site/issues{/number}","pulls_url":"https://api.github.com/repos/bundler/bundler-site/pulls{/number}","milestones_url":"https://api.github.com/repos/bundler/bundler-site/milestones{/number}","notifications_url":"https://api.github.com/repos/bundler/bundler-site/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bundler/bundler-site/labels{/name}","releases_url":"https://api.github.com/repos/bundler/bundler-site/releases{/id}","deployments_url":"https://api.github.com/repos/bundler/bundler-site/deployments","created_at":"2010-03-31T03:48:40Z","updated_at":"2018-05-22T12:43:49Z","pushed_at":"2018-05-27T22:49:12Z","git_url":"git://github.com/bundler/bundler-site.git","ssh_url":"git@github.com:bundler/bundler-site.git","clone_url":"https://github.com/bundler/bundler-site.git","svn_url":"https://github.com/bundler/bundler-site","homepage":"https://bundler.io","size":21897,"stargazers_count":76,"watchers_count":76,"language":"HTML","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":130,"mirror_url":null,"archived":false,"open_issues_count":24,"license":null,"forks":130,"open_issues":24,"watchers":76,"default_branch":"master"}},"base":{"label":"bundler:master","ref":"master","sha":"86e0d2352b3716129388266ec7c3c16f37920198","user":{"login":"bundler","id":1137638,"avatar_url":"https://avatars0.githubusercontent.com/u/1137638?v=4","gravatar_id":"","url":"https://api.github.com/users/bundler","html_url":"https://github.com/bundler","followers_url":"https://api.github.com/users/bundler/followers","following_url":"https://api.github.com/users/bundler/following{/other_user}","gists_url":"https://api.github.com/users/bundler/gists{/gist_id}","starred_url":"https://api.github.com/users/bundler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bundler/subscriptions","organizations_url":"https://api.github.com/users/bundler/orgs","repos_url":"https://api.github.com/users/bundler/repos","events_url":"https://api.github.com/users/bundler/events{/privacy}","received_events_url":"https://api.github.com/users/bundler/received_events","type":"Organization","site_admin":false},"repo":{"id":587923,"name":"bundler-site","full_name":"bundler/bundler-site","owner":{"login":"bundler","id":1137638,"avatar_url":"https://avatars0.githubusercontent.com/u/1137638?v=4","gravatar_id":"","url":"https://api.github.com/users/bundler","html_url":"https://github.com/bundler","followers_url":"https://api.github.com/users/bundler/followers","following_url":"https://api.github.com/users/bundler/following{/other_user}","gists_url":"https://api.github.com/users/bundler/gists{/gist_id}","starred_url":"https://api.github.com/users/bundler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bundler/subscriptions","organizations_url":"https://api.github.com/users/bundler/orgs","repos_url":"https://api.github.com/users/bundler/repos","events_url":"https://api.github.com/users/bundler/events{/privacy}","received_events_url":"https://api.github.com/users/bundler/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/bundler/bundler-site","description":"The Bundler documentation website","fork":false,"url":"https://api.github.com/repos/bundler/bundler-site","forks_url":"https://api.github.com/repos/bundler/bundler-site/forks","keys_url":"https://api.github.com/repos/bundler/bundler-site/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bundler/bundler-site/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bundler/bundler-site/teams","hooks_url":"https://api.github.com/repos/bundler/bundler-site/hooks","issue_events_url":"https://api.github.com/repos/bundler/bundler-site/issues/events{/number}","events_url":"https://api.github.com/repos/bundler/bundler-site/events","assignees_url":"https://api.github.com/repos/bundler/bundler-site/assignees{/user}","branches_url":"https://api.github.com/repos/bundler/bundler-site/branches{/branch}","tags_url":"https://api.github.com/repos/bundler/bundler-site/tags","blobs_url":"https://api.github.com/repos/bundler/bundler-site/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bundler/bundler-site/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bundler/bundler-site/git/refs{/sha}","trees_url":"https://api.github.com/repos/bundler/bundler-site/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bundler/bundler-site/statuses/{sha}","languages_url":"https://api.github.com/repos/bundler/bundler-site/languages","stargazers_url":"https://api.github.com/repos/bundler/bundler-site/stargazers","contributors_url":"https://api.github.com/repos/bundler/bundler-site/contributors","subscribers_url":"https://api.github.com/repos/bundler/bundler-site/subscribers","subscription_url":"https://api.github.com/repos/bundler/bundler-site/subscription","commits_url":"https://api.github.com/repos/bundler/bundler-site/commits{/sha}","git_commits_url":"https://api.github.com/repos/bundler/bundler-site/git/commits{/sha}","comments_url":"https://api.github.com/repos/bundler/bundler-site/comments{/number}","issue_comment_url":"https://api.github.com/repos/bundler/bundler-site/issues/comments{/number}","contents_url":"https://api.github.com/repos/bundler/bundler-site/contents/{+path}","compare_url":"https://api.github.com/repos/bundler/bundler-site/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bundler/bundler-site/merges","archive_url":"https://api.github.com/repos/bundler/bundler-site/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bundler/bundler-site/downloads","issues_url":"https://api.github.com/repos/bundler/bundler-site/issues{/number}","pulls_url":"https://api.github.com/repos/bundler/bundler-site/pulls{/number}","milestones_url":"https://api.github.com/repos/bundler/bundler-site/milestones{/number}","notifications_url":"https://api.github.com/repos/bundler/bundler-site/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bundler/bundler-site/labels{/name}","releases_url":"https://api.github.com/repos/bundler/bundler-site/releases{/id}","deployments_url":"https://api.github.com/repos/bundler/bundler-site/deployments","created_at":"2010-03-31T03:48:40Z","updated_at":"2018-05-22T12:43:49Z","pushed_at":"2018-05-27T22:49:12Z","git_url":"git://github.com/bundler/bundler-site.git","ssh_url":"git@github.com:bundler/bundler-site.git","clone_url":"https://github.com/bundler/bundler-site.git","svn_url":"https://github.com/bundler/bundler-site","homepage":"https://bundler.io","size":21897,"stargazers_count":76,"watchers_count":76,"language":"HTML","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":130,"mirror_url":null,"archived":false,"open_issues_count":24,"license":null,"forks":130,"open_issues":24,"watchers":76,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/bundler/bundler-site/pulls/380"},"html":{"href":"https://github.com/bundler/bundler-site/pull/380"},"issue":{"href":"https://api.github.com/repos/bundler/bundler-site/issues/380"},"comments":{"href":"https://api.github.com/repos/bundler/bundler-site/issues/380/comments"},"review_comments":{"href":"https://api.github.com/repos/bundler/bundler-site/pulls/380/comments"},"review_comment":{"href":"https://api.github.com/repos/bundler/bundler-site/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/bundler/bundler-site/pulls/380/commits"},"statuses":{"href":"https://api.github.com/repos/bundler/bundler-site/statuses/cd3b4e3010dab29ce6a4d97666c9ded0a5660e1f"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"rubymorillo"}}