Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Added support of room_id option #3

Merged
merged 1 commit into from

2 participants

@kirs
Collaborator

Instead of room option, you can pass the room_id if your room name contains some special characters.

@technicalpickles

Sorry for slow response, maintaining open source is hard :sweat:

This looks like a good addition. Off hand, do you have any examples of said special cases? I'd also like to see some updated docs to specify room_id and specs to confirm it working.

I added support for multiple rooms awhile back, so this isn't going to merge cleanly anymore.

lib/capistrano/campfire.rb
((7 lines not shown))
campfire = ::Tinder::Campfire.new account,
:token => token,
:ssl => ssl,
:ssl_verify => ssl_verify
- campfire.find_room_by_name(room_name)
+ if room_name
+ campfire.find_room_by_name(room_name)
+ else
@technicalpickles Owner

Now that you can specify by room_name or room_id, should make this elsif room_id, with an else clause that raises an error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@kirs
Collaborator

@technicalpickles for example room name can be in russian or in chinese and it would be not so clear to find_room_by_name("название моей комнаты")

@technicalpickles

Makes sense. That may be an upstream bug for tinder and/or Campfire too, since that should just work.

@kirs
Collaborator
@technicalpickles

@kirs gah, sorry again :( I added you as a collaborator if you'd like to merge. If you want to send the email on your rubygems account, I can add you for pushing releases.

@kirs
Collaborator

Thanks! Here is my rubygems account: https://rubygems.org/profiles/Kirs

@technicalpickles

Added, thanks!

@kirs kirs merged commit 2164f2b into technicalpickles:master
@kirs kirs deleted the kirs:room-id-support branch
@kirs
Collaborator

@technicalpickles BTW, why do we need capistrano-tinder.gemspec in this repo?

@technicalpickles
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 16, 2013
  1. @kirs

    room_id option

    kirs authored
This page is out of date. Refresh to see the latest.
View
17 README.rdoc
@@ -11,13 +11,13 @@ Install it the usual way:
And here's a quick example for your `config/deploy.rb`:
require 'capistrano/campfire'
-
+
set :campfire_options, :account => 'zim',
:room => 'World Conquest',
:token => '001000101110101001011112',
:ssl => true
-
-
+
+
task :ohai do
campfire_room.speak 'o hai'
end
@@ -26,7 +26,7 @@ And here's a quick example for your `config/deploy.rb`:
You can also be posting to multiple campfire rooms/accounts.
require 'capistrano/campfire'
-
+
set :campfire_options, :rooms => [{
:account => 'zim',
:room => 'World Conquest',
@@ -37,15 +37,18 @@ You can also be posting to multiple campfire rooms/accounts.
:token => '2001000101110101001011110',
}],
:ssl => true
-
-
+
+
task :ohai do
campfire_rooms.speak 'o hai'
end
+Instead of `room` option, you can pass the `room_id` if your room name contains some special characters.
+
+
== Note on Patches/Pull Requests
-
+
* Fork the project.
* Make your feature addition or bug fix.
* Add tests for it. This is important so I don't break it in a
View
10 lib/capistrano/campfire.rb
@@ -19,13 +19,21 @@ def initialize(campfire_options)
ssl = room_options[:ssl] || campfire_options[:ssl]
ssl_verify = room_options[:ssl_verify] || campfire_options[:ssl_verify]
room_name = room_options[:room] || campfire_options[:room]
+ room_id = room_options[:room] || campfire_options[:room_id]
campfire = ::Tinder::Campfire.new account,
:token => token,
:ssl => ssl,
:ssl_verify => ssl_verify
- campfire.find_room_by_name(room_name)
+
+ if room_name
+ campfire.find_room_by_name(room_name)
+ elsif room_id
+ campfire.find_room_by_id(room_id)
+ else
+ raise "Please, specify room name or room_id for your Campfire room"
+ end
end
end
View
38 spec/capistrano-campfire_spec.rb
@@ -16,6 +16,44 @@
configuration.campfire_options.should == {}
end
+
+ context "with configuration for a single room (by room_id)" do
+ before do
+ configuration.set :campfire_options, {
+ :account => "awesomellc",
+ :token => "yyz123",
+ :ssl => true,
+ :room_id => 1
+ }
+
+ @campfire = stub("campfire")
+ ::Tinder::Campfire.should_receive(:new).with("awesomellc", :token => "yyz123", :ssl => true, :ssl_verify => nil).and_return(@campfire)
+
+ @room = stub("room")
+ @campfire.should_receive(:find_room_by_id).with(1).and_return(@room)
+
+ end
+
+ it "speaks in a single room using `campfire_room.speak`" do
+ @room.should_receive(:speak).with("IMPENDING DOOM")
+
+ configuration.campfire_room.speak "IMPENDING DOOM"
+ end
+
+ it "pastes in a single room using `campfire_room.paste`" do
+ @room.should_receive(:paste).with("IMPENDING DOOM")
+
+ configuration.campfire_room.paste "IMPENDING DOOM"
+ end
+
+ it "plays in a single room using `campfire_room.play`" do
+ @room.should_receive(:play).with("IMPENDING DOOM")
+
+ configuration.campfire_room.play "IMPENDING DOOM"
+ end
+
+ end
+
context "with configuration for a single room" do
before do
configuration.set :campfire_options, {
Something went wrong with that request. Please try again.