Skip to content

Commit

Permalink
rename to message_bus_client
Browse files Browse the repository at this point in the history
fixes lowjoel#5
  • Loading branch information
mikz committed Aug 19, 2017
1 parent 90fc35c commit cd5b98b
Show file tree
Hide file tree
Showing 13 changed files with 50 additions and 52 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
source 'https://rubygems.org'

# Specify your gem's dependencies in message_bus-client.gemspec
# Specify your gem's dependencies in message_bus_client.gemspec
gemspec
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# MessageBus::Client
[![Build Status](https://travis-ci.org/lowjoel/message_bus-client.svg?branch=master)](https://travis-ci.org/lowjoel/message_bus-client)[![Coverage Status](https://coveralls.io/repos/github/lowjoel/message_bus-client/badge.svg?branch=master)](https://coveralls.io/github/lowjoel/message_bus-client?branch=master)[![Code Climate](https://codeclimate.com/github/lowjoel/message_bus-client/badges/gpa.svg)](https://codeclimate.com/github/lowjoel/message_bus-client)[![security](https://hakiri.io/github/lowjoel/message_bus-client/master.svg)](https://hakiri.io/github/lowjoel/message_bus-client/master)[![Inline docs](http://inch-ci.org/github/lowjoel/message_bus-client.svg?branch=master)](http://inch-ci.org/github/lowjoel/message_bus-client)
# MessageBusClient
[![Build Status](https://travis-ci.org/lowjoel/message_bus_client.svg?branch=master)](https://travis-ci.org/lowjoel/message_bus_client)[![Coverage Status](https://coveralls.io/repos/github/lowjoel/message_bus_client/badge.svg?branch=master)](https://coveralls.io/github/lowjoel/message_bus_client?branch=master)[![Code Climate](https://codeclimate.com/github/lowjoel/message_bus_client/badges/gpa.svg)](https://codeclimate.com/github/lowjoel/message_bus_client)[![security](https://hakiri.io/github/lowjoel/message_bus_client/master.svg)](https://hakiri.io/github/lowjoel/message_bus_client/master)[![Inline docs](http://inch-ci.org/github/lowjoel/message_bus_client.svg?branch=master)](http://inch-ci.org/github/lowjoel/message_bus_client)

This is a Ruby implementation of the client for
[message_bus](https://github.com/samsaffron/message_bus).
Expand All @@ -9,7 +9,7 @@ This is a Ruby implementation of the client for
Add this line to your application's Gemfile:

```ruby
gem 'message_bus-client'
gem 'message_bus_client'
```

And then execute:
Expand All @@ -18,14 +18,14 @@ And then execute:

Or install it yourself as:

$ gem install message_bus-client
$ gem install message_bus_client

## Usage

The API is mostly equivalent with the JavaScript client:

```ruby
client = MessageBus::Client.new('http://chat.samsaffron.com/')
client = MessageBusClient.new('http://chat.samsaffron.com/')
client.subscribe('/message') do |payload|
# Do stuff
end
Expand All @@ -39,8 +39,8 @@ client.stop
Both Long Polling and normal polling are supported:

```ruby
MessageBus::Client.long_polling = true # false to disable
MessageBus::Client.poll_interval = 15 # seconds
MessageBusClient.long_polling = true # false to disable
MessageBusClient.poll_interval = 15 # seconds
```

## Development
Expand All @@ -54,7 +54,7 @@ If you are running Windows, Ruby is not able to kill the server process. Run it
## Contributing

Bug reports and pull requests are welcome on GitHub at
https://github.com/lowjoel/message_bus-client.
https://github.com/lowjoel/message_bus_client.

## MIT License

Expand Down
19 changes: 0 additions & 19 deletions lib/message_bus/client.rb

This file was deleted.

5 changes: 0 additions & 5 deletions lib/message_bus/client/version.rb

This file was deleted.

19 changes: 19 additions & 0 deletions lib/message_bus_client.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
require 'excon'
require 'json'
require 'securerandom'

require 'message_bus_client/version'
require 'message_bus_client/configuration'
require 'message_bus_client/connection'
require 'message_bus_client/message_handler'

class MessageBusClient
include MessageBusClient::Configuration
include MessageBusClient::Connection
include MessageBusClient::MessageHandler

def initialize(base_url)
super
@client_id = SecureRandom.uuid
end
end
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module MessageBus::Client::Configuration
module MessageBusClient::Configuration
def self.included(module_)
module_.extend(ClassMethods)
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module MessageBus::Client::Connection
module MessageBusClient::Connection
# The connection is in the initialised state.
INITIALISED = 0

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module MessageBus::Client::MessageHandler
module MessageBusClient::MessageHandler
SubscribedChannel = Struct.new(:callbacks, :last_id) do
def initialize(last_id = -1)
self.callbacks = []
Expand Down
3 changes: 3 additions & 0 deletions lib/message_bus_client/version.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class MessageBusClient
VERSION = '0.2.0'
end
8 changes: 4 additions & 4 deletions message_bus-client.gemspec → message_bus_client.gemspec
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'message_bus/client/version'
require 'message_bus_client/version'

Gem::Specification.new do |spec|
spec.name = 'message_bus-client'
spec.version = MessageBus::Client::VERSION
spec.name = 'message_bus_client'
spec.version = MessageBusClient::VERSION
spec.authors = ['Joel Low']
spec.email = ['[email protected]']

spec.summary = 'Ruby client for Message Bus'
spec.description = 'Implements a client for Message Bus, with communication over HTTP'
spec.homepage = 'https://github.com/lowjoel/message_bus-client'
spec.homepage = 'https://github.com/lowjoel/message_bus_client'
spec.license = 'MIT'

spec.files = `git ls-files -z`.split("\x0").
Expand Down
2 changes: 1 addition & 1 deletion spec/chat_server_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
chat_example_path = File.join(message_bus_path, 'examples/chat')

# Override the load path so that the message_bus library loads before us. The middleware uses a
# MessageBus::Client class as well, with a different use case from ours.
# MessageBusClient class as well, with a different use case from ours.
$LOAD_PATH.unshift File.expand_path('lib', message_bus_path)

# Use the in-memory backend since this is for testing.
Expand Down
20 changes: 10 additions & 10 deletions spec/message_bus/client_spec.rb → spec/message_bus_client_spec.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
RSpec.describe MessageBus::Client do
RSpec.describe MessageBusClient do
self::SERVER_BASE = 'http://127.0.0.1:9292'.freeze

it 'has a version number' do
expect(MessageBus::Client::VERSION).not_to be nil
expect(MessageBusClient::VERSION).not_to be nil
end

def write_message(message, user = 'message_bus-client')
def write_message(message, user = 'message_bus_client')
Excon.post(URI.join(self.class::SERVER_BASE, '/message').to_s,
body: URI.encode_www_form(name: user, data: message),
headers: { 'Content-Type' => 'application/x-www-form-urlencoded' })
end

subject { MessageBus::Client.new(self.class::SERVER_BASE) }
subject { MessageBusClient.new(self.class::SERVER_BASE) }

context 'when using long polling' do
it 'connects to the server' do
Expand Down Expand Up @@ -56,14 +56,14 @@ def write_message(message, user = 'message_bus-client')
context 'when using polling' do
around(:each) do |example|
begin
old_long_polling = MessageBus::Client.long_polling
old_poll_interval = MessageBus::Client.poll_interval
MessageBus::Client.poll_interval = 1
MessageBus::Client.long_polling = false
old_long_polling = MessageBusClient.long_polling
old_poll_interval = MessageBusClient.poll_interval
MessageBusClient.poll_interval = 1
MessageBusClient.long_polling = false
example.call
ensure
MessageBus::Client.poll_interval = old_poll_interval
MessageBus::Client.long_polling = old_long_polling
MessageBusClient.poll_interval = old_poll_interval
MessageBusClient.long_polling = old_long_polling
end
end

Expand Down
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
require 'coverage_helper'
require 'message_bus/client'
require 'message_bus_client'
require 'chat_server_helper'

# This file was generated by the `rspec --init` command. Conventionally, all
Expand Down

0 comments on commit cd5b98b

Please sign in to comment.