foreign_office 0.1.1 → 0.1.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 66c0acf7def09497bd9be0e9a071c68436d08db0
4
- data.tar.gz: b33fb3acfbdce38c10ba9f06cc7e3206697275a5
3
+ metadata.gz: cbf32739fee81b0bc8be61f18f585e721dd01736
4
+ data.tar.gz: e42d37d55f26e121d7a83c100da65c9cc26214fd
5
5
  SHA512:
6
- metadata.gz: 03794deaa596219d2fd150ed9dea1fe497b87f01d206e1581fb2bcdc267a1d45c74d3ce1ec3f4b29863d0b7315f1c0f59ac47cfa13a04f64c6ec625d4b193fee
7
- data.tar.gz: 75a019150860afecdd3c0e19cabe9eea880dfcacb4294141efd9a15e6d9f4a09618a44d42451d08136d74799d923688ab0edbab7f551e68aabb566078a54e99c
6
+ metadata.gz: cc81bc349c49729151305bdd30342b4579e13576fd71eaad7a8ab65a32f81b49332f2ab3f513649a5443c5ebb0503a88918b83dfe69c6098a6b1e9413b0cf41a
7
+ data.tar.gz: b4a5b2ca24a7edb259078888ca1b29391a2da2be4fde9d6b49a359e925c612c9cb3d2f75637779bc5fe2d888e5080dc7a0dcad2861dda93b22a010da38f29d16
@@ -9,10 +9,12 @@ var ForeignOffice = Class.extend({
9
9
  this.channels_by_name = [];
10
10
  },
11
11
  config: function(config){
12
- third_party_busname = this.busMap(config.bus_name)
13
- if (typeof(eval(third_party_busname)) != 'undefined') {
14
- bus_class = eval(config.bus_name);
15
- } else {
12
+ bus_class = eval(config.bus_name);
13
+ third_party_library = this.library_name_for(config.bus_name)
14
+ try {
15
+ bus_class = eval(third_party_library)
16
+ }
17
+ catch(err){
16
18
  bus_class = TestBus
17
19
  }
18
20
  this.bus = new bus_class(config);
@@ -33,9 +35,9 @@ var ForeignOffice = Class.extend({
33
35
  channelNames: function(){
34
36
  return $.map(this.channels,function(channel){return channel.channel_name});
35
37
  },
36
- busMap: function(bus_name) {
37
- var map = { PubnubBus: 'PUBNUB',
38
- PusherBus: 'Pusher'}[bus_name]
38
+ library_name_for: function(bus_name){
39
+ var library_map = {PubnubBus: 'PUBNUB', PusherBus: 'Pusher'}
40
+ return library_map[bus_name]
39
41
  }
40
42
  });
41
43
 
@@ -44,6 +46,8 @@ foreign_office = new ForeignOffice();
44
46
  var ForeignOfficeChannel = Class.extend({
45
47
  init: function(channel_name){
46
48
  var foreign_office_channel = this;
49
+ debug_logger.log("Subscribing to: ");
50
+ debug_logger.log(channel_name);
47
51
  foreign_office.bus.subscribe({
48
52
  channel : channel_name,
49
53
  callback : function(m){
@@ -1,5 +1,6 @@
1
1
  var PubnubBus = Class.extend({
2
2
  init: function(config){
3
+ debug_logger.log("initializing pubnub js")
3
4
  this.pubnub = PUBNUB.init({
4
5
  publish_key : config.publish_key,
5
6
  subscribe_key : config.subscribe_key,
@@ -7,9 +8,10 @@ var PubnubBus = Class.extend({
7
8
  });
8
9
  },
9
10
  subscribe: function(subscription){
11
+ debug_logger.log("subscribing with PubnubBus")
12
+ debug_logger.log(subscription)
10
13
  this.pubnub.subscribe({
11
14
  channel : subscription.channel,
12
- backfill: true,
13
15
  message : function(m){subscription.callback(m)}
14
16
  });
15
17
 
@@ -7,5 +7,6 @@ var PusherBus = Class.extend({
7
7
  this.channel.bind('publish', function(data){
8
8
  subscription.callback(data);
9
9
  })
10
- }
10
+ },
11
+ third_party_library: 'Pusher'
11
12
  })
@@ -44,17 +44,16 @@ class ForeignOffice::Busses::PubnubBus < ForeignOffice::Busses::GenericBus
44
44
  self.connection.publish(
45
45
  channel: message[:channel],
46
46
  message: message,
47
- http_sync: true,
48
- callback: lambda{|response|
49
- if 0 == JSON.parse(response.instance_variable_get(:@response)).first #pubnub publishing failed
50
- if attempts <= 3
51
- self.publish!(message, attempts) #retry if we failed
52
- else
53
- Rails.logger.debug("ForeignOffice#publish! failed after #{attempts} attempts. message: #{message.inspect}")
54
- end
55
- end
56
- }
57
- )
47
+ http_sync: true
48
+ ) do |envelope|
49
+ if '200' != envelope.status_code.to_s
50
+ Rails.logger.error "ForeignOffice error esponse:"
51
+ Rails.logger.error envelope.message
52
+ Rails.logger.error envelope.channel
53
+ Rails.logger.error envelope.status_code
54
+ Rails.logger.error envelope.timetoken
55
+ end
56
+ end
58
57
  end
59
58
 
60
59
  end
@@ -1,3 +1,3 @@
1
1
  module ForeignOffice
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreign_office
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Draut
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-10-08 00:00:00.000000000 Z
12
+ date: 2014-10-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails