kindling 1.0.0 → 1.0.1

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.
@@ -21,7 +21,7 @@ If using SSL pass true to the third parameter of the Kindling::Campfire construc
21
21
  campfire = Kindling::Campfire.new(API_TOKEN, SUBDOMAIN, true)
22
22
 
23
23
  === Sending messages
24
- capfire.speak(ROOM_ID, 'my message')
24
+ campfire.speak(ROOM_ID, 'my message')
25
25
 
26
26
  ==== Message Types
27
27
  The speak method can take an optional third parameter MessageType
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{kindling}
8
- s.version = "1.0.0"
8
+ s.version = "1.0.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Wal McConnell"]
@@ -1,4 +1,4 @@
1
- require 'rubygems'
1
+ require 'rubygems'
2
2
  require 'httparty'
3
3
  require 'json'
4
4
 
@@ -17,6 +17,10 @@ class Kindling::Request
17
17
  raise Kindling::InvalidSubdomain.new(campfire.subdomain)
18
18
  when 401
19
19
  raise Kindling::InvalidAPIToken.new(campfire.api_token)
20
+ when 405
21
+ # retry with SSL
22
+ campfire.ssl = true
23
+ rooms(campfire)
20
24
  when 200
21
25
  return response["rooms"]
22
26
  end
@@ -29,6 +33,10 @@ class Kindling::Request
29
33
  raise Kindling::InvalidRoomID.new(room_id)
30
34
  when 401
31
35
  raise Kindling::InvalidAPIToken.new(campfire.api_token)
36
+ when 405
37
+ # retry with SSL
38
+ campfire.ssl = true
39
+ speak(message, campfire, room_id, type)
32
40
  when 200..201
33
41
  response
34
42
  else
@@ -25,6 +25,12 @@ class RequestTest < Test::Unit::TestCase
25
25
  end
26
26
  end
27
27
 
28
+ should "retry with SSL if 405" do
29
+ stub_rooms_request({:code => 405})
30
+ stub_rooms_request({:code => 200, :[] => JSON.parse(fixture_file("rooms.json"))["rooms"]}, true)
31
+ assert_equal [{"name"=>"Room 1", "id"=>201712}, {"name"=>"Room 2", "id"=>298625}, {"name"=>"Room 3", "id"=>206877}], Kindling::Request.rooms(@campfire)
32
+ end
33
+
28
34
  should "should return rooms list" do
29
35
  stub_rooms_request({:code => 200, :[] => JSON.parse(fixture_file("rooms.json"))["rooms"]})
30
36
  assert_equal [{"name"=>"Room 1", "id"=>201712}, {"name"=>"Room 2", "id"=>298625}, {"name"=>"Room 3", "id"=>206877}], Kindling::Request.rooms(@campfire)
@@ -54,6 +60,12 @@ class RequestTest < Test::Unit::TestCase
54
60
  Kindling::Request.speak("test message", @campfire, TEST_ROOM_ID)
55
61
  end
56
62
  end
63
+
64
+ should "retry with SSL if 405" do
65
+ stub_send_message_request('test message', {:code => 405})
66
+ stub_send_message_request('test message', {:code => 200}, true)
67
+ Kindling::Request.speak("test message", @campfire, TEST_ROOM_ID)
68
+ end
57
69
  end
58
70
  end
59
71
  end
@@ -15,9 +15,9 @@ TEST_API_TOKEN = '787654567654323456789098765432345678765432'
15
15
  TEST_ROOM_ID = 206877
16
16
  TEST_ROOM_NAME = 'Room 3'
17
17
 
18
- def stub_rooms_request(resp)
18
+ def stub_rooms_request(resp, ssl = false)
19
19
  response = mock('Net::HTTPResponse', resp)
20
- Kindling::Request.expects(:get).with("http://#{TEST_SUBDOMAIN}.campfirenow.com/rooms.json", {:basic_auth => {:password => 'x', :username => "#{TEST_API_TOKEN}"}}).returns(response)
20
+ Kindling::Request.expects(:get).with("#{ssl ? 'https' : 'http'}://#{TEST_SUBDOMAIN}.campfirenow.com/rooms.json", {:basic_auth => {:password => 'x', :username => "#{TEST_API_TOKEN}"}}).returns(response)
21
21
  end
22
22
 
23
23
  def stub_send_message_request(message, resp, ssl = false)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kindling
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wal McConnell