klomp 1.0.6 → 1.0.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,12 @@
1
1
  Klomp Changes
2
2
  --------------------------------------------------------------------------------
3
3
 
4
+ 1.0.7 (2013/02/04)
5
+ ================================================================================
6
+
7
+ - Ruby 1.8 support for the laggards
8
+ - Add empty .gemtest and fix gemspec so klomp may be used directly from git
9
+
4
10
  1.0.6 (2012/11/19)
5
11
  ================================================================================
6
12
 
data/Gemfile CHANGED
@@ -15,6 +15,7 @@ gem "rspec-given", "~>1.0", :group => [:development, :test]
15
15
  gem "simplecov", "~>0.6.0", :group => [:development, :test]
16
16
  gem "em-proxy", "~>0.1.0", :group => [:development, :test]
17
17
  gem "ci_reporter", "~>1.7.0", :group => [:development, :test]
18
+ gem "activesupport", ">=2.3.0", :group => [:development, :test]
18
19
  gem "hoe", "~>3.0", :group => [:development, :test]
19
20
 
20
21
  # vim: syntax=ruby
@@ -2,6 +2,7 @@ GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
4
  ZenTest (4.8.0)
5
+ activesupport (2.3.16)
5
6
  builder (3.1.4)
6
7
  ci_reporter (1.7.3)
7
8
  builder (>= 2.1.2)
@@ -42,6 +43,7 @@ PLATFORMS
42
43
 
43
44
  DEPENDENCIES
44
45
  ZenTest (~> 4.8.0)
46
+ activesupport (>= 2.3.0)
45
47
  ci_reporter (~> 1.7.0)
46
48
  em-proxy (~> 0.1.0)
47
49
  hoe (~> 3.0)
@@ -1,3 +1,4 @@
1
+ .gemtest
1
2
  .rspec
2
3
  .simplecov
3
4
  ChangeLog.md
data/Rakefile CHANGED
@@ -13,15 +13,16 @@ Hoe.spec 'klomp' do
13
13
  self.clean_globs << 'spec/reports'
14
14
 
15
15
  ### dependencies!
16
- self.extra_dev_deps << [ 'hoe-bundler', '~> 1.1.0' ]
17
- self.extra_dev_deps << [ 'hoe-gemspec', '~> 1.0.0' ]
18
- self.extra_dev_deps << [ 'hoe-git', '~> 1.5.0' ]
19
- self.extra_dev_deps << [ 'rspec', '~> 2.11.0' ]
20
- self.extra_dev_deps << [ 'ZenTest', '~> 4.8.0' ]
21
- self.extra_dev_deps << [ 'rspec-given', '~> 1.0' ]
22
- self.extra_dev_deps << [ 'simplecov', '~> 0.6.0' ]
23
- self.extra_dev_deps << [ 'em-proxy', '~> 0.1.0' ]
24
- self.extra_dev_deps << [ 'ci_reporter', '~> 1.7.0' ]
16
+ self.extra_dev_deps << [ 'hoe-bundler', '~> 1.1.0' ]
17
+ self.extra_dev_deps << [ 'hoe-gemspec', '~> 1.0.0' ]
18
+ self.extra_dev_deps << [ 'hoe-git', '~> 1.5.0' ]
19
+ self.extra_dev_deps << [ 'rspec', '~> 2.11.0' ]
20
+ self.extra_dev_deps << [ 'ZenTest', '~> 4.8.0' ]
21
+ self.extra_dev_deps << [ 'rspec-given', '~> 1.0' ]
22
+ self.extra_dev_deps << [ 'simplecov', '~> 0.6.0' ]
23
+ self.extra_dev_deps << [ 'em-proxy', '~> 0.1.0' ]
24
+ self.extra_dev_deps << [ 'ci_reporter', '~> 1.7.0' ]
25
+ self.extra_dev_deps << [ 'activesupport', '>= 2.3.0' ]
25
26
  end
26
27
 
27
28
  require 'ci/reporter/rake/rspec'
@@ -2,15 +2,15 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "klomp"
5
- s.version = "1.0.6"
5
+ s.version = "1.0.7"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Nick Sieger"]
9
- s.date = "2012-10-17"
9
+ s.date = "2013-02-04"
10
10
  s.description = "Klomp is a simple [Stomp] messaging client that keeps your sanity intact.\n\nThe purpose of Klomp is to be the simplest possible Stomp client. No in-memory\nbuffering of outgoing messages, no fanout subscriptions in-process, no\ntransactions, no complicated messaging patterns. Code simple enough so that when\nsomething goes wrong, the problem is obvious.\n\n[Stomp]: http://stomp.github.com/"
11
11
  s.email = ["nick.sieger@livingsocial.com"]
12
12
  s.extra_rdoc_files = ["Manifest.txt"]
13
- s.files = [".rspec", ".simplecov", "ChangeLog.md", "Gemfile", "Gemfile.lock", "Manifest.txt", "README.md", "Rakefile", "klomp.gemspec", "lib/klomp.rb", "lib/klomp/connection.rb", "lib/klomp/frames.rb", "lib/klomp/sentinel.rb", "spec/acceptance/acceptance_spec.rb", "spec/frames/auth_error.txt", "spec/frames/connect.txt", "spec/frames/connect_vhost.txt", "spec/frames/connected.txt", "spec/frames/disconnect.txt", "spec/frames/error.txt", "spec/frames/greeting.txt", "spec/frames/message.txt", "spec/frames/receipt.txt", "spec/frames/subscribe.txt", "spec/frames/unsubscribe.txt", "spec/klomp/connection_spec.rb", "spec/klomp/frames_spec.rb", "spec/klomp/sentinel_spec.rb", "spec/klomp_spec.rb", "spec/spec_helper.rb", "spec/support/have_received.rb", ".gemtest"]
13
+ s.files = [".gemtest", ".rspec", ".simplecov", "ChangeLog.md", "Gemfile", "Gemfile.lock", "Manifest.txt", "README.md", "Rakefile", "klomp.gemspec", "lib/klomp.rb", "lib/klomp/connection.rb", "lib/klomp/frames.rb", "lib/klomp/sentinel.rb", "spec/acceptance/acceptance_spec.rb", "spec/acceptance/reconnect_spec.rb", "spec/frames/auth_error.txt", "spec/frames/connect.txt", "spec/frames/connect_vhost.txt", "spec/frames/connected.txt", "spec/frames/disconnect.txt", "spec/frames/error.txt", "spec/frames/greeting.txt", "spec/frames/message.txt", "spec/frames/receipt.txt", "spec/frames/subscribe.txt", "spec/frames/unsubscribe.txt", "spec/klomp/connection_spec.rb", "spec/klomp/frames_spec.rb", "spec/klomp/sentinel_spec.rb", "spec/klomp_spec.rb", "spec/spec_helper.rb", "spec/support/have_received.rb", "spec/support/shared_contexts.rb"]
14
14
  s.homepage = "http://github.com/livingsocial/klomp"
15
15
  s.rdoc_options = ["--main", "README.md"]
16
16
  s.require_paths = ["lib"]
@@ -32,6 +32,7 @@ Gem::Specification.new do |s|
32
32
  s.add_development_dependency(%q<simplecov>, ["~> 0.6.0"])
33
33
  s.add_development_dependency(%q<em-proxy>, ["~> 0.1.0"])
34
34
  s.add_development_dependency(%q<ci_reporter>, ["~> 1.7.0"])
35
+ s.add_development_dependency(%q<activesupport>, [">= 2.3.0"])
35
36
  s.add_development_dependency(%q<hoe>, ["~> 3.0"])
36
37
  else
37
38
  s.add_dependency(%q<rdoc>, ["~> 3.10"])
@@ -44,6 +45,7 @@ Gem::Specification.new do |s|
44
45
  s.add_dependency(%q<simplecov>, ["~> 0.6.0"])
45
46
  s.add_dependency(%q<em-proxy>, ["~> 0.1.0"])
46
47
  s.add_dependency(%q<ci_reporter>, ["~> 1.7.0"])
48
+ s.add_dependency(%q<activesupport>, [">= 2.3.0"])
47
49
  s.add_dependency(%q<hoe>, ["~> 3.0"])
48
50
  end
49
51
  else
@@ -57,6 +59,7 @@ Gem::Specification.new do |s|
57
59
  s.add_dependency(%q<simplecov>, ["~> 0.6.0"])
58
60
  s.add_dependency(%q<em-proxy>, ["~> 0.1.0"])
59
61
  s.add_dependency(%q<ci_reporter>, ["~> 1.7.0"])
62
+ s.add_dependency(%q<activesupport>, [">= 2.3.0"])
60
63
  s.add_dependency(%q<hoe>, ["~> 3.0"])
61
64
  end
62
65
  end
@@ -1,5 +1,5 @@
1
1
  class Klomp
2
- VERSION = '1.0.6'
2
+ VERSION = '1.0.7'
3
3
 
4
4
  class Error < StandardError; end
5
5
 
@@ -14,7 +14,7 @@ class Klomp
14
14
  def publish(queue, body, headers = {})
15
15
  connections_remaining = connections.dup
16
16
  begin
17
- conn = connections_remaining.sample
17
+ conn = connections_remaining[rand(connections_remaining.size)]
18
18
  conn.publish(queue, body, headers)
19
19
  rescue
20
20
  connections_remaining.delete conn
@@ -84,7 +84,7 @@ class Klomp
84
84
  private
85
85
  def connect
86
86
  @socket = TCPSocket.new *options['server']
87
- @socket.set_encoding 'UTF-8'
87
+ @socket.set_encoding 'UTF-8' if @socket.respond_to?(:set_encoding)
88
88
  write Frames::Connect.new(options)
89
89
  frame = read Frames::Connected, @select_timeout
90
90
  log_frame frame if logger
@@ -5,9 +5,14 @@ class Klomp
5
5
  class Frame
6
6
  def name; @name ||= self.class.name.split('::').last.upcase; end
7
7
 
8
- def headers; @headers ||= {}; end
9
- def [](key); headers[key]; end
10
- def []=(key, value); headers[key] = value; end
8
+ def new_headers
9
+ # Dependency injection point for tests.
10
+ {}
11
+ end
12
+
13
+ def headers; @headers ||= new_headers; end
14
+ def [](key); headers[key]; end
15
+ def []=(key, value); headers[key] = value; end
11
16
 
12
17
  def body; @body ||= ""; end
13
18
  def body=(b); @body = b; end
@@ -44,7 +49,7 @@ class Klomp
44
49
 
45
50
  def parse_headers(data)
46
51
  frame = nil
47
- {}.tap do |headers|
52
+ new_headers.tap do |headers|
48
53
  data.lines.each do |line|
49
54
  next if line == "\n"
50
55
  unless frame
@@ -16,7 +16,7 @@ describe "Klomp acceptance", :acceptance => true do
16
16
 
17
17
  context "publish" do
18
18
 
19
- When { klomp.publish "/queue/greeting", "hello" }
19
+ When { klomp.publish("/queue/greeting", "hello") }
20
20
 
21
21
  Then do
22
22
  vhosts = apollo_api_get_json "/broker/virtual-hosts.json"
@@ -4,18 +4,24 @@ describe Klomp::Connection do
4
4
 
5
5
  Given(:data) { frame(:connected) }
6
6
  Given(:server) { "127.0.0.1:61613" }
7
- Given(:options) { { "login" => "admin", "passcode" => "password", "logger" => logger } }
8
- Given(:socket) { double(TCPSocket, gets:data, write:nil, set_encoding:nil, close:nil) }
9
- Given(:logger) { double("Logger", error:nil, warn:nil, info:nil, debug:nil).as_null_object }
10
- Given(:subscriber) { double "subscriber", call:nil }
7
+ Given(:socket) { double(TCPSocket, :gets => data, :write => nil, :set_encoding => nil, :close => nil) }
8
+ Given(:logger) { double("Logger", :error => nil, :warn => nil, :info => nil, :debug => nil).as_null_object }
9
+ Given(:subscriber) { double "subscriber", :call => nil }
11
10
  Given(:thread) { double Thread }
12
- Given(:sentinel) { double Klomp::Sentinel, alive?:true }
11
+ Given(:sentinel) { double Klomp::Sentinel, :alive? => true }
12
+ Given(:options) {
13
+ hsh = ActiveSupport::OrderedHash.new
14
+ hsh['login'] = 'admin'
15
+ hsh['passcode'] = 'password'
16
+ hsh['logger'] = logger
17
+ hsh
18
+ }
13
19
 
14
20
  Given do
15
21
  IO.stub!(:select).and_return([[socket], [socket]])
16
22
  TCPSocket.stub!(:new).and_return socket
17
23
  Thread.stub!(:new).and_return {|*args,&blk| thread.stub!(:block => blk); thread }
18
- Klomp::Sentinel.stub!(new: sentinel)
24
+ Klomp::Sentinel.stub!(:new => sentinel)
19
25
  end
20
26
 
21
27
  context "new" do
@@ -78,7 +84,7 @@ describe Klomp::Connection do
78
84
 
79
85
  context "logs when logger level is debug" do
80
86
 
81
- Given(:logger) { double("Logger").as_null_object.tap {|l| l.stub!(debug?: true) } }
87
+ Given(:logger) { double("Logger").as_null_object.tap {|l| l.stub!(:debug? => true) } }
82
88
 
83
89
  Then { logger.should have_received(:debug) }
84
90
 
@@ -100,7 +106,7 @@ describe Klomp::Connection do
100
106
 
101
107
  context "and logs when logger level is debug" do
102
108
 
103
- Given(:logger) { double("Logger").as_null_object.tap {|l| l.stub!(debug?: true) } }
109
+ Given(:logger) { double("Logger").as_null_object.tap {|l| l.stub!(:debug? => true) } }
104
110
 
105
111
  Then { logger.should have_received(:debug) }
106
112
 
@@ -112,7 +118,7 @@ describe Klomp::Connection do
112
118
 
113
119
  When do
114
120
  connection.subscribe "/queue/greeting", subscriber
115
- connection.subscribe "/queue/greeting", double("another subscriber that replaces the first", call:nil)
121
+ connection.subscribe "/queue/greeting", double("another subscriber that replaces the first", :call => nil)
116
122
  end
117
123
 
118
124
  Then { socket.should have_received(:write).with(frame(:subscribe)).once }
@@ -225,7 +231,7 @@ describe Klomp::Connection do
225
231
 
226
232
  context "disconnect" do
227
233
 
228
- Given!(:connection) { Klomp::Connection.new server, options }
234
+ Given!(:connection) { Klomp::Connection.new server, options}
229
235
 
230
236
  When(:result) { connection.disconnect }
231
237
 
@@ -293,7 +299,7 @@ describe Klomp::Connection do
293
299
  Given!(:connection) { Klomp::Connection.new server, options }
294
300
 
295
301
  Given do
296
- thread.stub!(:raise).and_return {|e| raise e }
302
+ thread.stub!(:raise).and_return {|e, _| raise e }
297
303
  socket.stub!(:gets).and_raise SystemCallError.new("some socket error")
298
304
  end
299
305
 
@@ -22,7 +22,7 @@ describe Klomp::Frames do
22
22
 
23
23
  context "stringifies all header keys and values" do
24
24
 
25
- Given(:headers) { { timeout:42 } }
25
+ Given(:headers) { { :timeout => 42 } }
26
26
 
27
27
  When(:send_frame) { Klomp::Frames::Send.new("/queue/q", "", headers) }
28
28
 
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  describe Klomp::Sentinel do
4
4
 
5
- Given(:connection) { double "Connection", connected?:false, reconnect:nil }
5
+ Given(:connection) { double "Connection", :connected? => false, :reconnect => nil }
6
6
  Given(:sentinel) { Klomp::Sentinel.new connection }
7
7
  Given(:thread) { double Thread }
8
8
  Given do
@@ -11,7 +11,7 @@ describe Klomp::Sentinel do
11
11
 
12
12
  context "does nothing if the connection is already connected" do
13
13
 
14
- Given { connection.stub!(connected?: true) }
14
+ Given { connection.stub!(:connected? => true) }
15
15
 
16
16
  When { sentinel }
17
17
 
@@ -4,7 +4,7 @@ describe Klomp do
4
4
 
5
5
  Given(:servers) { ["127.0.0.1:61613", "127.0.0.1:67673"] }
6
6
  Given(:connections) { Hash[*servers.map {|s| [s, double("connection #{s}")] }.flatten] }
7
- Given { Klomp::Connection.stub!(:new).and_return {|s| connections[s] } }
7
+ Given { Klomp::Connection.stub!(:new).and_return {|s, _| connections[s] } }
8
8
  Given(:klomp) { Klomp.new servers }
9
9
 
10
10
  context "new" do
@@ -113,7 +113,7 @@ describe Klomp do
113
113
 
114
114
  context "calls subscribe on all of the servers" do
115
115
 
116
- Given { connections.values.each {|conn| conn.stub!(subscribe: 42) } }
116
+ Given { connections.values.each {|conn| conn.stub!(:subscribe => 42) } }
117
117
 
118
118
  When(:result) { klomp.subscribe("/queue/greeting") { true } }
119
119
 
@@ -143,7 +143,7 @@ describe Klomp do
143
143
 
144
144
  context "calls unsubscribe on all the servers" do
145
145
 
146
- Given { connections.values.each {|conn| conn.stub!(unsubscribe: 42) } }
146
+ Given { connections.values.each {|conn| conn.stub!(:unsubscribe => 42) } }
147
147
 
148
148
  When(:result) { klomp.unsubscribe("/queue/greeting") }
149
149
 
@@ -197,7 +197,7 @@ describe Klomp do
197
197
 
198
198
  context "disconnects all the servers" do
199
199
 
200
- Given { connections.values.each {|conn| conn.stub!(disconnect: 42) } }
200
+ Given { connections.values.each {|conn| conn.stub!(:disconnect => 42) } }
201
201
 
202
202
  When(:result) { klomp.disconnect }
203
203
 
@@ -1,7 +1,8 @@
1
- require 'simplecov'
1
+ require 'simplecov' if RUBY_VERSION >= '1.9'
2
2
  require 'klomp'
3
3
  require 'rspec'
4
4
  require 'rspec-given'
5
+ require 'active_support'
5
6
 
6
7
  Dir[File.expand_path('../support/', __FILE__) + '/*.rb'].each {|f| require f }
7
8
 
@@ -32,5 +33,11 @@ RSpec.configure do |config|
32
33
  config.filter_run_excluding :performance
33
34
  end
34
35
 
36
+ config.before :each do
37
+ Klomp::Frames::Frame.any_instance.stub(:new_headers) do
38
+ ActiveSupport::OrderedHash.new
39
+ end
40
+ end
41
+
35
42
  config.include Frames
36
43
  end
@@ -54,7 +54,7 @@ module RSpec::Matchers::HaveReceived
54
54
  def initialize(message, expected_from)
55
55
  @message, @mock = message, RSpec::Mocks::Mock.new
56
56
  @mock.stub!(message)
57
- @expectation = @mock.should_receive(message, expected_from: expected_from)
57
+ @expectation = @mock.should_receive(message, expected_from => expected_from)
58
58
  end
59
59
 
60
60
  def matches?(actual)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: klomp
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.6
4
+ version: 1.0.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-19 00:00:00.000000000 Z
12
+ date: 2013-02-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rdoc
@@ -171,6 +171,22 @@ dependencies:
171
171
  - - ~>
172
172
  - !ruby/object:Gem::Version
173
173
  version: 1.7.0
174
+ - !ruby/object:Gem::Dependency
175
+ name: activesupport
176
+ requirement: !ruby/object:Gem::Requirement
177
+ none: false
178
+ requirements:
179
+ - - ! '>='
180
+ - !ruby/object:Gem::Version
181
+ version: 2.3.0
182
+ type: :development
183
+ prerelease: false
184
+ version_requirements: !ruby/object:Gem::Requirement
185
+ none: false
186
+ requirements:
187
+ - - ! '>='
188
+ - !ruby/object:Gem::Version
189
+ version: 2.3.0
174
190
  - !ruby/object:Gem::Dependency
175
191
  name: hoe
176
192
  requirement: !ruby/object:Gem::Requirement
@@ -208,6 +224,7 @@ extensions: []
208
224
  extra_rdoc_files:
209
225
  - Manifest.txt
210
226
  files:
227
+ - .gemtest
211
228
  - .rspec
212
229
  - .simplecov
213
230
  - ChangeLog.md
@@ -241,7 +258,6 @@ files:
241
258
  - spec/spec_helper.rb
242
259
  - spec/support/have_received.rb
243
260
  - spec/support/shared_contexts.rb
244
- - .gemtest
245
261
  homepage: http://github.com/livingsocial/klomp
246
262
  licenses: []
247
263
  post_install_message:
@@ -258,7 +274,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
258
274
  version: '0'
259
275
  segments:
260
276
  - 0
261
- hash: 30151873419123398
277
+ hash: 2933496602827248730
262
278
  required_rubygems_version: !ruby/object:Gem::Requirement
263
279
  none: false
264
280
  requirements: