campy 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +1 -0
- data/.travis.yml +0 -1
- data/CHANGELOG.md +10 -1
- data/README.md +12 -0
- data/campy.gemspec +1 -0
- data/lib/campy/room.rb +1 -1
- data/lib/campy/version.rb +1 -1
- data/spec/campy/room_spec.rb +47 -0
- metadata +19 -14
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,12 @@
|
|
1
|
-
## 0.1.
|
1
|
+
## 0.1.4.dev (unreleased)
|
2
|
+
|
3
|
+
|
4
|
+
## 0.1.3 (July 10, 2012)
|
5
|
+
|
6
|
+
### New features
|
7
|
+
|
8
|
+
* Pull request [#1](https://github.com/fnichol/campy/pull/1): Add option to
|
9
|
+
use Campfire room id rather than room name. ([@mvandenbeuken][])
|
2
10
|
|
3
11
|
|
4
12
|
## 0.1.2 (April 5, 2012)
|
@@ -21,3 +29,4 @@
|
|
21
29
|
The initial release.
|
22
30
|
|
23
31
|
[@fnichol]: https://github.com/fnichol
|
32
|
+
[@mvandenbeuken]: https://github.com/mvandenbeuken
|
data/README.md
CHANGED
@@ -68,6 +68,18 @@ campy.paste "Long pastes are long"
|
|
68
68
|
campy.play "ohmy"
|
69
69
|
```
|
70
70
|
|
71
|
+
If you know the room ID and would prefer to use that instead of the name:
|
72
|
+
|
73
|
+
```ruby
|
74
|
+
require 'campy'
|
75
|
+
|
76
|
+
campy = Campy::Room.new(:account => "mysubdomain",
|
77
|
+
:token => "mytoken123", :room_id => "12345")
|
78
|
+
campy.speak "Campy says yello"
|
79
|
+
campy.paste "Long pastes are long"
|
80
|
+
campy.play "ohmy"
|
81
|
+
```
|
82
|
+
|
71
83
|
Why not use the `campfire.yml` config? Let's do that:
|
72
84
|
|
73
85
|
```ruby
|
data/campy.gemspec
CHANGED
data/lib/campy/room.rb
CHANGED
@@ -31,7 +31,7 @@ module Campy
|
|
31
31
|
def initialize(options = {})
|
32
32
|
options = { :ssl => true }.merge(options)
|
33
33
|
|
34
|
-
[:account, :room, :token, :ssl].each do |option|
|
34
|
+
[:account, :room_id, :room, :token, :ssl].each do |option|
|
35
35
|
instance_variable_set "@#{option}", options[option]
|
36
36
|
end
|
37
37
|
end
|
data/lib/campy/version.rb
CHANGED
data/spec/campy/room_spec.rb
CHANGED
@@ -1,4 +1,20 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
# Currently there no support for SimpleCov in Rubinus, see:
|
4
|
+
# http://donttreadonme.co.uk/rubinius/2012/02/22.html#message_243
|
5
|
+
unless defined?(RUBY_ENGINE) && RUBY_ENGINE == "rbx"
|
6
|
+
require 'simplecov'
|
7
|
+
SimpleCov.adapters.define 'gem' do
|
8
|
+
command_name 'Specs'
|
9
|
+
|
10
|
+
add_filter '/spec/'
|
11
|
+
|
12
|
+
add_group 'Binaries', '/bin/'
|
13
|
+
add_group 'Libraries', '/lib/'
|
14
|
+
end
|
15
|
+
SimpleCov.start 'gem'
|
16
|
+
end
|
17
|
+
|
2
18
|
require 'minitest/autorun'
|
3
19
|
require 'webmock/minitest'
|
4
20
|
require 'campy/room'
|
@@ -46,6 +62,13 @@ describe Campy::Room do
|
|
46
62
|
:body => fixture("speak").sub(/@@MESSAGE@@/, msg))
|
47
63
|
end
|
48
64
|
|
65
|
+
def stub_speak_not_found!(msg, type = 'TextMessage')
|
66
|
+
stub_request(:post, "https://yepyep:X@zubzub.campfirenow.com/room/123456/speak.json").
|
67
|
+
with(:headers => {'Content-Type' => 'application/json'},
|
68
|
+
:body => {:message => {:body => msg, :type => type}}).
|
69
|
+
to_return(:status => 404, :headers => {}, :body => "Not Found")
|
70
|
+
end
|
71
|
+
|
49
72
|
def stub_speak_error!(error)
|
50
73
|
stub_request(:post, "https://yepyep:X@zubzub.campfirenow.com/room/123456/speak.json").
|
51
74
|
with(:headers => {'Content-Type' => 'application/json'}).
|
@@ -75,6 +98,12 @@ describe Campy::Room do
|
|
75
98
|
describe "#room_id" do
|
76
99
|
let(:subject) { Campy::Room.new(opts) }
|
77
100
|
|
101
|
+
it "returns the room_id set in the initializer if it is provided" do
|
102
|
+
room_with_id = Campy::Room.new(opts.merge(:room_id => 654321))
|
103
|
+
|
104
|
+
room_with_id.room_id.must_equal 654321
|
105
|
+
end
|
106
|
+
|
78
107
|
it "fetches the room id from the API" do
|
79
108
|
stub_rooms!
|
80
109
|
|
@@ -123,6 +152,12 @@ describe Campy::Room do
|
|
123
152
|
subject.speak("talking about talking").must_equal true
|
124
153
|
end
|
125
154
|
|
155
|
+
it "raises a ConnectionError when API does not return HTTP 201" do
|
156
|
+
stub_speak_not_found!("nope")
|
157
|
+
|
158
|
+
proc { subject.speak "nope" }.must_raise(Campy::Room::ConnectionError)
|
159
|
+
end
|
160
|
+
|
126
161
|
WRAPPED_ERRORS.each do |error|
|
127
162
|
it "wraps #{error} and raises a ConnectionError" do
|
128
163
|
stub_speak_error!(error)
|
@@ -153,6 +188,12 @@ describe Campy::Room do
|
|
153
188
|
subject.paste("big ol long paste\nwith newlines").must_equal true
|
154
189
|
end
|
155
190
|
|
191
|
+
it "raises a ConnectionError when API does not return HTTP 201" do
|
192
|
+
stub_speak_not_found!("nope", "PasteMessage")
|
193
|
+
|
194
|
+
proc { subject.paste "nope" }.must_raise(Campy::Room::ConnectionError)
|
195
|
+
end
|
196
|
+
|
156
197
|
WRAPPED_ERRORS.each do |error|
|
157
198
|
it "wraps #{error} and raises a ConnectionError" do
|
158
199
|
stub_speak_error!(error)
|
@@ -183,6 +224,12 @@ describe Campy::Room do
|
|
183
224
|
subject.play("tada").must_equal true
|
184
225
|
end
|
185
226
|
|
227
|
+
it "raises a ConnectionError when API does not return HTTP 201" do
|
228
|
+
stub_speak_not_found!("nope", "SoundMessage")
|
229
|
+
|
230
|
+
proc { subject.play "nope" }.must_raise(Campy::Room::ConnectionError)
|
231
|
+
end
|
232
|
+
|
186
233
|
WRAPPED_ERRORS.each do |error|
|
187
234
|
it "wraps #{error} and raises a ConnectionError" do
|
188
235
|
stub_speak_error!(error)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: campy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-07-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: multi_json
|
16
|
-
requirement: &
|
16
|
+
requirement: &2155891020 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '1.0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2155891020
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: minitest
|
27
|
-
requirement: &
|
27
|
+
requirement: &2155890340 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 2.12.0
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *2155890340
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: webmock
|
38
|
-
requirement: &
|
38
|
+
requirement: &2155889700 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,7 +43,18 @@ dependencies:
|
|
43
43
|
version: 1.8.5
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *2155889700
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: simplecov
|
49
|
+
requirement: &2155888960 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.6.1
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *2155888960
|
47
58
|
description: Tiny Campfire Ruby client so you can get on with it.
|
48
59
|
email:
|
49
60
|
- fnichol@nichol.ca
|
@@ -81,18 +92,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
81
92
|
- - ! '>='
|
82
93
|
- !ruby/object:Gem::Version
|
83
94
|
version: '0'
|
84
|
-
segments:
|
85
|
-
- 0
|
86
|
-
hash: -3617043583867255143
|
87
95
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
96
|
none: false
|
89
97
|
requirements:
|
90
98
|
- - ! '>='
|
91
99
|
- !ruby/object:Gem::Version
|
92
100
|
version: '0'
|
93
|
-
segments:
|
94
|
-
- 0
|
95
|
-
hash: -3617043583867255143
|
96
101
|
requirements: []
|
97
102
|
rubyforge_project:
|
98
103
|
rubygems_version: 1.8.17
|