forked from ajsharp/campfire_notifier
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 087cc55
Showing
10 changed files
with
133 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Gem::Specification.new do |s| | ||
s.name = 'campfire-notifier' | ||
s.version = '0.1.0' | ||
s.summary = 'A simple gem to send a simple message to campfire.' | ||
s.files = Dir['lib/**/*.rb'] | ||
end | ||
|
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
= Campfire Notifier | ||
|
||
Most of the time when I want to use the Campfire API, I just want to send it | ||
a simple message. So, I created a stupid simple way to send a message to | ||
Campfire. | ||
|
||
I've include a command line tool as well to make it really easy to use this | ||
with low-ish level system tools (i.e. cron). | ||
|
||
== Install | ||
|
||
gem install campfire_notifier | ||
|
||
== Settings | ||
|
||
Put your campfire subdomain, the room id (not the name) to which you want to | ||
send a message, and your API token, which you can find on your campfire user | ||
edit page. | ||
|
||
See here for more details: http://developer.37signals.com/campfire/index | ||
|
||
== Requirements | ||
|
||
Nothing! This baby uses gem bundler, so you shouldn't need to install | ||
any other gems. | ||
|
||
Still, just in case: | ||
* HTTParty | ||
* json_pure | ||
|
||
|
||
== Potential Uses | ||
|
||
* Deployment notifications | ||
* CI Build notifications | ||
* Git hooks | ||
* Cron jobs | ||
* Annoying your co-workers | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/usr/bin/env ruby | ||
|
||
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + "/../lib")) | ||
require 'campfire_notifier' | ||
|
||
CampfireNotifier.speak(ARGV[0]) unless ARGV[0].nil? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
require 'yaml' | ||
|
||
require 'rubygems' | ||
require 'httparty' | ||
require 'json' | ||
|
||
class CampfireNotifier | ||
include HTTParty | ||
|
||
def self.config | ||
@config ||= YAML.load_file(File.expand_path(File.dirname(__FILE__)) + "/../settings.yml") | ||
end | ||
|
||
base_uri "http://#{config['subdomain']}.campfirenow.com" | ||
headers 'Content-type' => 'application/json' | ||
basic_auth config["token"], 'x' | ||
format :json | ||
|
||
def self.speak(message) | ||
post "/room/#{config['room_id']}/speak.json", :body => { :message => { :body => message, :type => 'Textmessage' } }.to_json | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
token: b916b9434bb4158b461b8a4f8f3342f7d2f2fd67 | ||
room_id: 244651 | ||
subdomain: optimis |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
require 'spec_helper' | ||
|
||
describe CampfireNotifier, ".config" do | ||
before :each do | ||
@config = CampfireNotifier.config | ||
end | ||
|
||
it "should load some configuration settings" do | ||
@config.should be_instance_of Hash | ||
end | ||
|
||
it "should set the subdomain option" do | ||
@config['subdomain'].should_not be_blank | ||
end | ||
|
||
it "should set the room name" do | ||
@config['room_id'].should_not be_blank | ||
end | ||
|
||
it "should set the token" do | ||
@config['token'].should_not be_blank | ||
end | ||
end | ||
|
||
describe CampfireNotifier, ".speak" do | ||
before :each do | ||
CampfireNotifier.stub(:speak).and_return("hello") | ||
end | ||
|
||
it "should submit a request to the campfire api" do | ||
CampfireNotifier.should respond_to :speak | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"rooms":[{"name":"General","created_at":"2009/10/12 14:30:16 +0000","updated_at":"2009/10/17 08:49:16 +0000","topic":"","id":111111,"membership_limit":12}]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--colour | ||
--format | ||
s | ||
--diff |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
$:.unshift(File.dirname(__FILE__) + '/../lib') | ||
$:.unshift(File.dirname(__FILE__)) | ||
|
||
|
||
require 'rubygems' | ||
require 'spec' | ||
require 'spec/autorun' | ||
|
||
require 'fakeweb' | ||
|
||
require 'campfire_notifier' | ||
|
||
|
||
fixtures = File.dirname(File.expand_path(__FILE__)) + "/fixtures" | ||
|
||
FakeWeb.allow_net_connect = false | ||
FakeWeb.register_uri(:get, "http://example.campfirenow.com/rooms.json", :body => File.read("#{fixtures}/rooms.json")) | ||
|