Permalink
Browse files

Merge pull request #63 from torkale/master

modify packet to allow self defined pattern
  • Loading branch information...
2 parents ba53e40 + d920a6f commit 3ee45c09816eb56374bd45b469035193d1897603 @smith smith committed Feb 19, 2014
Showing with 41 additions and 5 deletions.
  1. +1 −0 .gitignore
  2. +12 −0 README.md
  3. +11 −5 lib/capistrano/notifier/statsd.rb
  4. +17 −0 spec/capistrano/notifier/statsd_spec.rb
View
@@ -16,3 +16,4 @@ test/tmp
test/version_tmp
tmp
.DS_Store
+.ruby-version
View
@@ -120,4 +120,16 @@ set :notifier_statsd_options, {
}
```
+You can define the pattern that will be used to define the key.
+In the example the key will be 'test.deployment.example'
+
+```rb
+set :application, 'example'
+set :stage, 'test'
+
+set :notifier_statsd_options, {
+ :pattern => "#{stage}.deployment.#{application}"
+}
+```
+
The `nc` ([Netcat](http://netcat.sourceforge.net/)) command is used to send messages to statsd and must be installed on the remote hosts. This is installed by default on most Unix machines.
@@ -38,11 +38,17 @@ def options
end
def packet
- if stage
- "#{application}.#{stage}.deploy:#{with}"
- else
- "#{application}.deploy:#{with}"
- end
+ "#{pattern}:#{with}"
+ end
+
+ def pattern
+ options.fetch(:pattern){
+ if stage
+ "#{application}.#{stage}.deploy"
+ else
+ "#{application}.deploy"
+ end
+ }
end
def port
@@ -78,4 +78,21 @@
end
end
end
+
+ context "with a pattern" do
+ before :each do
+ configuration.load do
+ set :application, 'example'
+ set :stage, 'test'
+ set :notifier_statsd_options, {
+ :pattern => "#{stage}.deployment.#{application}"
+ }
+ end
+ end
+
+ it "creates a packet" do
+ subject.send(:packet).should == "test.deployment.example:1|c"
+ end
+
+ end
end

0 comments on commit 3ee45c0

Please sign in to comment.