README.md in captain_hoog-1.1.1 vs README.md in captain_hoog-2.0.0
- old
+ new
@@ -1,8 +1,8 @@
# CaptainHoog
-[![Build Status](https://travis-ci.org/GateprotectGmbH/captain_hoog.svg)](https://travis-ci.org/GateprotectGmbH/captain_hoog)
+[![Build Status](https://travis-ci.org/GateprotectGmbH/captain_hoog.svg)](https://travis-ci.org/GateprotectGmbH/captain_hoog) [![Code Climate](https://codeclimate.com/github/GateprotectGmbH/captain_hoog/badges/gpa.svg)](https://codeclimate.com/github/GateprotectGmbH/captain_hoog)
Okay. That's not such a funny gem name. But it's a reference to Git and the subject
of the gem: the Git Hooks.
<img src="http://dyxygd30hex7h.cloudfront.net/sites/www.prismaticart.com/files/PRISMATIC_ADAM.jpg" height="450">
@@ -24,14 +24,18 @@
## Usage
### Install the hook
```
-githoog install --type <GIT_HOOK_TYPE> --plugins_dir <PATH_TO_PLUGINS> --project_dir <PATH_TO_PROJECT>
+hoog install --type <GIT_HOOK_TYPE> --plugins_dir <PATH_TO_PLUGINS> --project_dir <PATH_TO_PROJECT>
```
+Captain Hoog will install also a global ```.hoog``` directory in ```$HOME```. It will
+also pull the default hookins. If you don't want to have this pulled, use the ```--skip-hookins``` flags.
+
**Please note:** ```<PATH_TO_PLUGINS>``` and ```<PATH_TO_PROJECT>``` must be given as absolute paths.
+```<PATH_TO_PLUGINS>``` and ```<PATH_TO_PROJECT>``` are also optional.
Also make sure to run this from your git repository's root folder.
```GIT_HOOK_TYPE``` may be something like this
* pre-commit (default)
@@ -58,11 +62,11 @@
### Removing the hook
Remove a hook by using the
```
-githoog remove --type <GIT_HOOK_TYPE>
+hoog remove --type <GIT_HOOK_TYPE>
```
command.
where ```<GIT_HOOK_TYPE>``` is ```pre-commit``` by default.
@@ -124,10 +128,14 @@
# Must return a boolean value.
end
pre.message do
# Define a message string here that is shown if the test fails.
+ # The message is printed out in red per default. If you don't want
+ # a color pass color: :none to the helper method. Or if you want a
+ # specific color, the color as symbol:
+ # pre.message(color: :none) do ....
end
end
```
@@ -163,10 +171,24 @@
end
```
+Within all expressions you can use the ```env``` variable which provides you the
+context the plugin is run in:
+
+```rb
+git.describe 'output the plugin context' do |pre|
+
+ pre.run do
+ puts env.context # might be 'pre-commit, pre-push etc ...
+ end
+
+end
+
+```
+
**Plugin file structure**
A common way to organize plugins is:
```
@@ -195,26 +217,26 @@
end
```
## Test Support
-### Sandbox
+### Sandbox
For testing purposes, Captain Hoog uses some kind of sandboxing. You're able to use the sandbox directly (you have to do this by now for any other test frameworks than RSpec).
-Using the sandbox is easy:
+Using the sandbox is easy:
```ruby
sandbox = CaptainHoog::Test::Sandbox.new(plugin_code, cfg)
sandbox.run
# then have full access to the plugin by using sandbox.plugin
-```
+```
-You have to pass the plugin as String or File object and a configuration hash to the sandbox.
+You have to pass the plugin as String or File object and a configuration hash to the sandbox.
The configuration hash might consist of a global (the ```env```) and a plugin specific configuration (marked by using the plugins name as key).
-Example:
+Example:
```rb
plugin_code = <<-PLUGIN
git.describe 'foo' do |hook|
hook.helper :foo_helper do
@@ -243,15 +265,15 @@
}
}
sandbox = CaptainHoog::Test::Sandbox.new(plugin_code, cfg)
sandbox.run
sandbox.plugin.result[:test] # => true
-sandbox.plugin.foo_helper # => 12
+sandbox.plugin.foo_helper # => 12
sandbox.plugin.result[:message] # => Fun
```
-**Note** that the sandbox will not provide you some fake file system.
+**Note** that the sandbox will not provide you some fake file system.
### Frameworks
Captain Hoog provides some small DSL for testing plugins if you're using RSpec. For the use of MiniTest (or any other testing framework, see the section below.)
@@ -261,29 +283,29 @@
```rb
require 'captain_hoog/test'
```
-There is no configuration needed, Captain Hoog will detect if you're using Rspec.
+There is no configuration needed, Captain Hoog will detect if you're using Rspec.
-Then - as usual - add a ```describe``` block. Within this block you have access to a block helper:
+Then - as usual - add a ```describe``` block. Within this block you have access to a block helper:
```rb
-with_plugin :<PLUGIN_NAME>, config: <HASH>, silence: <true|false> do
+with_plugin :<PLUGIN_NAME>, config: <HASH>, silence: <true|false> do
# ....
end
```
-|Argument| Description|
+|Argument| Description|
|:-------|:-----------|
|PLUGIN_NAME | Plugin - as String or File object (given as a ```let``` or method) |
|config | plugin configuration, see **Sandbox** section for details. |
|silence | Truthy or falsy value, silences the plugin output |
-With ```with_plugin``` you have full access to the Captain Hoog plugin by using ```plugin```.
+With ```with_plugin``` you have full access to the Captain Hoog plugin by using ```plugin```.
-A full example:
+A full example:
```rb
require 'rspec'
require 'captain_hoog/test'
@@ -330,11 +352,11 @@
end
end
end
```
-### Other Test Frameworks (MiniTest, TestUnit ...)
+### Other Test Frameworks (MiniTest, TestUnit ...)
You have to use the sandbox directly. See an example using MiniTest below.
```rb
gem 'minitest'
@@ -381,8 +403,8 @@
end
```
## Last stuff
-Init and written by Daniel Schmidt (daniel.schmidt@gateprotect.com)
+Init and written by Daniel Schmidt (daniel-a.schmidt@rohde-schwarz.com)
Image "Captain Hook" © 2012 Brian Patterson