pusher_rails 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ v0.1.4
2
+ ======
3
+ - Upgraded backpusher.js to pusher/backpusher@9caa3ecce01916d8bcb8da1d5997912ec3c60bf9 which fixes a problem with success/error callbacks on create/fetch calls.
4
+
1
5
  v0.1.3
2
6
  ======
3
7
  - Upgraded to pusher.js 1.9.4
data/pusher_rails.gemspec CHANGED
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = 'pusher_rails'
6
- s.version = '0.1.3'
6
+ s.version = '0.1.4'
7
7
  s.platform = Gem::Platform::RUBY
8
8
  s.authors = ["David Grandinetti"]
9
9
  s.email = ["dave@wegoto12.com"]
@@ -16,7 +16,7 @@
16
16
  // we can setup the socket_id param.
17
17
  if (channel.pusher.connection) {
18
18
  channel.pusher.connection.bind('connected', function() {
19
- Backbone.pusher_socket_id = channel.pusher.socket_id;
19
+ Backbone.pusher_socket_id = channel.pusher.connection.socket_id;
20
20
  });
21
21
  } else {
22
22
  channel.pusher.bind('pusher:connection_established', function() {
@@ -100,40 +100,34 @@
100
100
  'read' : 'GET'
101
101
  };
102
102
 
103
- // Backpusher's Backbone.sync method:
104
- // -------------
105
- Backbone.sync = function(method, model, success, error) {
103
+ Backbone.sync = function(method, model, options) {
106
104
  var type = methodMap[method];
107
- var modelJSON = null;
108
105
 
109
- if (method === 'create' || method === 'update') {
110
- modelJSON = JSON.stringify(model.toJSON());
111
- }
106
+ // Default JSON-request options.
107
+ var params = _.extend({
108
+ type: type,
109
+ dataType: 'json'
110
+ }, options);
112
111
 
113
112
  if (!(model && model.url)) {
114
113
  throw new Error("A 'url' property or function must be specified");
115
114
  }
116
115
 
117
- var modelUrl = _.isFunction(model.url) ? model.url() : model.url;
118
- modelUrl += '?socket_id=' + Backbone.pusher_socket_id;
116
+ if (!params.url) {
117
+ params.url = _.isFunction(model.url) ? model.url() : model.url;
118
+ params.url += '?socket_id=' + Backbone.pusher_socket_id;
119
+ }
119
120
 
120
- // Default JSON-request options.
121
- var params = {
122
- url: modelUrl,
123
- type: type,
124
- contentType: 'application/json',
125
- data: modelJSON,
126
- dataType: 'json',
127
- processData: false,
128
- success: success,
129
- error: error
130
- };
121
+ // Ensure that we have the appropriate request data.
122
+ if (!params.data && model && (method == 'create' || method == 'update')) {
123
+ params.contentType = 'application/json';
124
+ params.data = JSON.stringify(model.toJSON());
125
+ }
131
126
 
132
127
  // For older servers, emulate JSON by encoding the request into an HTML-form.
133
128
  if (Backbone.emulateJSON) {
134
129
  params.contentType = 'application/x-www-form-urlencoded';
135
- params.processData = true;
136
- params.data = modelJSON ? {model : modelJSON} : {};
130
+ params.data = params.data ? {model : params.data} : {};
137
131
  }
138
132
 
139
133
  // For older servers, emulate HTTP by mimicking the HTTP method with `_method`
@@ -143,15 +137,20 @@
143
137
  if (Backbone.emulateJSON) params.data._method = type;
144
138
  params.type = 'POST';
145
139
  params.beforeSend = function(xhr) {
146
- xhr.setRequestHeader("X-HTTP-Method-Override", type);
140
+ xhr.setRequestHeader('X-HTTP-Method-Override', type);
147
141
  };
148
142
  }
149
143
  }
150
144
 
145
+ // Don't process data on a non-GET request.
146
+ if (params.type !== 'GET' && !Backbone.emulateJSON) {
147
+ params.processData = false;
148
+ }
149
+
151
150
  // Make the request.
152
- $.ajax(params);
151
+ return $.ajax(params);
153
152
  };
154
153
 
155
154
  // Export:
156
155
  exports.Backpusher = Backpusher;
157
- })((typeof exports !== 'undefined' ? exports : this));
156
+ })((typeof exports !== 'undefined' ? exports : this));
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pusher_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
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: 2011-11-09 00:00:00.000000000 Z
12
+ date: 2011-12-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: pusher
16
- requirement: &70338432315200 !ruby/object:Gem::Requirement
16
+ requirement: &70285432931700 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: 0.8.4
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70338432315200
24
+ version_requirements: *70285432931700
25
25
  description: Adds pusher.js/backpusher.js to the asset pipeline and pusher-gem to
26
26
  to your app.
27
27
  email: