sinatra-cometio 0.5.5 → 0.5.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 73ce6035810b3c246bcbea80882d3ef01b20afe7
4
- data.tar.gz: 8cebb648687ce259528ecaf5553f750bc7fa51e1
3
+ metadata.gz: c2d4bcecc45017cc73256cad7afa8424be83162c
4
+ data.tar.gz: d722c7b6be85852d63d1b011ce97fa8d1c293138
5
5
  SHA512:
6
- metadata.gz: 88f8f841affb6969885bb502661d48e277071d3a336fd86eeccee5fe003837aefe7a907b729a64aa58b603de8985f61d464fcb1e91581b67cd93aa314bfb782d
7
- data.tar.gz: 49e43eb227a7e511472e8c80d129128be663d7e3b4e033c10ddc2020e2ef2df7f3ea2eec7b040e5904804f25643c9c6333ea51264359bea29890e6cc237c81dc
6
+ metadata.gz: 3faffbfe215f98cd092e2ce48a9ca849c16dff81de741030b71936988069fbd620605e0d762ccb68d19f57b734600ee693beec8b8d6f0ae248fe64307f093508
7
+ data.tar.gz: b795964ad56a975f1ee07993c6130efdd73cb80c439db4bae11aeb63be86b9638f2a6da2fb66828b7939feea5a13f24a9af17722274ac918438ae74de2fb4743
data/History.txt CHANGED
@@ -1,3 +1,7 @@
1
+ === 0.5.6 2013-05-23
2
+
3
+ * post with JSON for nested Array
4
+
1
5
  === 0.5.5 2013-05-23
2
6
 
3
7
  * bugfix server side
data/lib/js/cometio.js CHANGED
@@ -9,8 +9,10 @@ var CometIO = function(){
9
9
  var flush = function(){
10
10
  if(!running || post_queue.length < 1) return;
11
11
  var post_data = {
12
- session: self.session,
13
- events: post_queue
12
+ json: JSON.stringify({
13
+ session: self.session,
14
+ events: post_queue
15
+ })
14
16
  };
15
17
  $.ajax(
16
18
  {
@@ -41,9 +41,10 @@ module Sinatra
41
41
  end
42
42
 
43
43
  app.post '/cometio/io' do
44
- from = params[:session]
44
+ data = JSON.parse params[:json] rescue halt 500, 'JSON parse error'
45
+ from = data['session']
45
46
  halt 400, 'no session' if !from or from.empty?
46
- events = params[:events]
47
+ events = data['events']
47
48
  halt 400, 'no data' unless [Hash, Array].include? events.class
48
49
  events = events.keys.sort.map{|i| events[i] } if events.kind_of? Hash
49
50
  EM::defer do
@@ -1,5 +1,5 @@
1
1
  module Sinatra
2
2
  module CometIO
3
- VERSION = '0.5.5'
3
+ VERSION = '0.5.6'
4
4
  end
5
5
  end
@@ -23,8 +23,10 @@ module Sinatra
23
23
 
24
24
  def push(type, data)
25
25
  post_data = {
26
- :session => @session,
27
- :events => [{:type => type, :data => data}]
26
+ :json => {
27
+ :session => @session,
28
+ :events => [{:type => type, :data => data}]
29
+ }.to_json
28
30
  }
29
31
  begin
30
32
  res = HTTParty.post @url, :timeout => 10, :body => post_data
data/test/test_cometio.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  require File.expand_path 'test_helper', File.dirname(__FILE__)
2
2
 
3
- class TestCometio < MiniTest::Unit::TestCase
3
+ class TestCometio < MiniTest::Test
4
4
 
5
5
  def setup
6
6
  App.start
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sinatra-cometio
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.5
4
+ version: 0.5.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sho Hashimoto