faye 0.3.1 → 0.3.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.
Potentially problematic release.
This version of faye might be problematic. Click here for more details.
- data/History.txt +12 -0
- data/Manifest.txt +5 -0
- data/README.txt +25 -7
- data/Rakefile +1 -0
- data/build/faye-client-min.js +1 -1
- data/build/faye.js +367 -186
- data/examples/node/faye-client-min.js +1 -1
- data/examples/node/faye.js +367 -186
- data/examples/shared/public/index.html +1 -0
- data/examples/shared/public/mootools.js +4329 -0
- data/examples/shared/public/prototype.js +4874 -0
- data/jake.yml +3 -1
- data/lib/faye-client-min.js +1 -1
- data/lib/faye.rb +5 -2
- data/lib/faye/channel.rb +4 -0
- data/lib/faye/client.rb +53 -29
- data/lib/faye/connection.rb +16 -37
- data/lib/faye/rack_adapter.rb +33 -28
- data/lib/faye/server.rb +24 -23
- data/lib/faye/timeouts.rb +21 -0
- data/lib/faye/transport.rb +17 -4
- data/test/scenario.js +73 -37
- data/test/scenario.rb +104 -0
- data/test/test_channel.rb +7 -1
- data/test/test_clients.js +28 -10
- data/test/test_clients.rb +154 -0
- data/test/test_grammar.rb +1 -1
- data/test/test_server.rb +8 -7
- metadata +17 -11
| @@ -0,0 +1,154 @@ | |
| 1 | 
            +
            require "test/unit"
         | 
| 2 | 
            +
            require File.dirname(__FILE__) + "/../lib/faye"
         | 
| 3 | 
            +
            require "test/scenario"
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            class TestClients < Test::Unit::TestCase
         | 
| 6 | 
            +
              include Faye
         | 
| 7 | 
            +
              include Scenario
         | 
| 8 | 
            +
              
         | 
| 9 | 
            +
              scenario "Two HTTP clients, no messages delivered" do
         | 
| 10 | 
            +
                server 8000
         | 
| 11 | 
            +
                http_client :A, ['/channels/a']
         | 
| 12 | 
            +
                http_client :B, []
         | 
| 13 | 
            +
                publish :B, '/channels/b', 'hello' => 'world'
         | 
| 14 | 
            +
                check_inbox(
         | 
| 15 | 
            +
                  :A => {},
         | 
| 16 | 
            +
                  :B => {}
         | 
| 17 | 
            +
                )
         | 
| 18 | 
            +
              end
         | 
| 19 | 
            +
              
         | 
| 20 | 
            +
              scenario "Two HTTP clients, single subscription" do
         | 
| 21 | 
            +
                server 8000
         | 
| 22 | 
            +
                http_client :A, ['/channels/a']
         | 
| 23 | 
            +
                http_client :B, []
         | 
| 24 | 
            +
                publish :B, '/channels/a', 'hello' => 'world'
         | 
| 25 | 
            +
                check_inbox(
         | 
| 26 | 
            +
                    :A => {
         | 
| 27 | 
            +
                      '/channels/a' => ['hello' => 'world']
         | 
| 28 | 
            +
                    },
         | 
| 29 | 
            +
                    :B => {}
         | 
| 30 | 
            +
                )
         | 
| 31 | 
            +
              end
         | 
| 32 | 
            +
             | 
| 33 | 
            +
              scenario "Two HTTP clients, multiple subscriptions" do
         | 
| 34 | 
            +
                server 8000
         | 
| 35 | 
            +
                http_client :A, ['/channels/a', '/channels/*']
         | 
| 36 | 
            +
                http_client :B, []
         | 
| 37 | 
            +
                publish :B, '/channels/a', 'hello' => 'world'
         | 
| 38 | 
            +
                check_inbox(
         | 
| 39 | 
            +
                    :A => {
         | 
| 40 | 
            +
                      '/channels/a' => ['hello' => 'world'],
         | 
| 41 | 
            +
                      '/channels/*' => ['hello' => 'world']
         | 
| 42 | 
            +
                    },
         | 
| 43 | 
            +
                    :B => {}
         | 
| 44 | 
            +
                )
         | 
| 45 | 
            +
              end
         | 
| 46 | 
            +
             | 
| 47 | 
            +
              scenario "Three HTTP clients, single receiver" do
         | 
| 48 | 
            +
                server 8000
         | 
| 49 | 
            +
                http_client :A, ['/channels/a']
         | 
| 50 | 
            +
                http_client :B, []
         | 
| 51 | 
            +
                http_client :C, ['/channels/c']
         | 
| 52 | 
            +
                publish :B, '/channels/a', 'chunky' => 'bacon'
         | 
| 53 | 
            +
                check_inbox(
         | 
| 54 | 
            +
                    :A => {
         | 
| 55 | 
            +
                      '/channels/a' => ['chunky' => 'bacon']
         | 
| 56 | 
            +
                    },
         | 
| 57 | 
            +
                    :B => {},
         | 
| 58 | 
            +
                    :C => {}
         | 
| 59 | 
            +
                )
         | 
| 60 | 
            +
              end
         | 
| 61 | 
            +
             | 
| 62 | 
            +
              scenario "Three HTTP clients, multiple receivers" do
         | 
| 63 | 
            +
                server 8000
         | 
| 64 | 
            +
                http_client :A, ['/channels/shared']
         | 
| 65 | 
            +
                http_client :B, []
         | 
| 66 | 
            +
                http_client :C, ['/channels/shared']
         | 
| 67 | 
            +
                publish :B, '/channels/shared', 'chunky' => 'bacon'
         | 
| 68 | 
            +
                check_inbox(
         | 
| 69 | 
            +
                    :A => {
         | 
| 70 | 
            +
                      '/channels/shared' => ['chunky' => 'bacon']
         | 
| 71 | 
            +
                    },
         | 
| 72 | 
            +
                    :B => {},
         | 
| 73 | 
            +
                    :C => {
         | 
| 74 | 
            +
                      '/channels/shared' => ['chunky' => 'bacon']
         | 
| 75 | 
            +
                    }
         | 
| 76 | 
            +
                )
         | 
| 77 | 
            +
              end
         | 
| 78 | 
            +
             | 
| 79 | 
            +
              scenario "Two HTTP clients, single wildcard on receiver" do
         | 
| 80 | 
            +
                server 8000
         | 
| 81 | 
            +
                http_client :A, ['/channels/*']
         | 
| 82 | 
            +
                http_client :B, []
         | 
| 83 | 
            +
                publish :B, '/channels/anything', 'msg' => 'hey'
         | 
| 84 | 
            +
                check_inbox(
         | 
| 85 | 
            +
                    :A => {
         | 
| 86 | 
            +
                      '/channels/*' => ['msg' => 'hey']
         | 
| 87 | 
            +
                    },
         | 
| 88 | 
            +
                    :B => {}
         | 
| 89 | 
            +
                )
         | 
| 90 | 
            +
              end
         | 
| 91 | 
            +
             | 
| 92 | 
            +
              scenario "Two HTTP clients, single wildcard on sender" do
         | 
| 93 | 
            +
                server 8000
         | 
| 94 | 
            +
                http_client :A, ['/channels/name', '/channels/hello', '/channels/nested/hello']
         | 
| 95 | 
            +
                http_client :B, []
         | 
| 96 | 
            +
                publish :B, '/channels/*', 'msg' => 'hey'
         | 
| 97 | 
            +
                check_inbox(
         | 
| 98 | 
            +
                    :A => {
         | 
| 99 | 
            +
                      '/channels/name' => ['msg' => 'hey'],
         | 
| 100 | 
            +
                      '/channels/hello' => ['msg' => 'hey']
         | 
| 101 | 
            +
                    },
         | 
| 102 | 
            +
                    :B => {}
         | 
| 103 | 
            +
                )
         | 
| 104 | 
            +
              end
         | 
| 105 | 
            +
             | 
| 106 | 
            +
              scenario "Two HTTP clients, single wildcard on both" do
         | 
| 107 | 
            +
                server 8000
         | 
| 108 | 
            +
                http_client :A, ['/channels/*']
         | 
| 109 | 
            +
                http_client :B, []
         | 
| 110 | 
            +
                publish :B, '/channels/*', 'msg' => 'hey'
         | 
| 111 | 
            +
                check_inbox(
         | 
| 112 | 
            +
                    :A => {
         | 
| 113 | 
            +
                      '/channels/*' => ['msg' => 'hey']
         | 
| 114 | 
            +
                    },
         | 
| 115 | 
            +
                    :B => {}
         | 
| 116 | 
            +
                )
         | 
| 117 | 
            +
              end
         | 
| 118 | 
            +
             | 
| 119 | 
            +
              scenario "Two local clients, double wildcard on sender" do
         | 
| 120 | 
            +
                server 8000
         | 
| 121 | 
            +
                local_client :A, ['/channels/name', '/channels/hello', '/channels/nested/hello']
         | 
| 122 | 
            +
                local_client :B, []
         | 
| 123 | 
            +
                publish :B, '/channels/**', 'msg' => 'hey'
         | 
| 124 | 
            +
                check_inbox(
         | 
| 125 | 
            +
                    :A => {
         | 
| 126 | 
            +
                      '/channels/name' => ['msg' => 'hey'],
         | 
| 127 | 
            +
                      '/channels/hello' => ['msg' => 'hey'],
         | 
| 128 | 
            +
                      '/channels/nested/hello' => ['msg' => 'hey']
         | 
| 129 | 
            +
                    },
         | 
| 130 | 
            +
                    :B => {}
         | 
| 131 | 
            +
                )
         | 
| 132 | 
            +
              end
         | 
| 133 | 
            +
             | 
| 134 | 
            +
              scenario "Two local clients, one HTTP, double wildcard on sender and one subscription" do
         | 
| 135 | 
            +
                server 8000
         | 
| 136 | 
            +
                local_client :A, ['/channels/hello', '/channels/nested/hello']
         | 
| 137 | 
            +
                local_client :B, []
         | 
| 138 | 
            +
                http_client :C, ['/channels/name', '/channels/foo/**']
         | 
| 139 | 
            +
                publish :B, '/channels/**', 'msg' => 'hey'
         | 
| 140 | 
            +
                check_inbox(
         | 
| 141 | 
            +
                    :A => {
         | 
| 142 | 
            +
                      '/channels/hello' => ['msg' => 'hey'],
         | 
| 143 | 
            +
                      '/channels/nested/hello' => ['msg' => 'hey']
         | 
| 144 | 
            +
                    },
         | 
| 145 | 
            +
                    :B => {},
         | 
| 146 | 
            +
                    :C => {
         | 
| 147 | 
            +
                      '/channels/name' => ['msg' => 'hey'],
         | 
| 148 | 
            +
                      '/channels/foo/**' => ['msg' => 'hey'],
         | 
| 149 | 
            +
                      '/channels/name' => ['msg' => 'hey'],
         | 
| 150 | 
            +
                    }
         | 
| 151 | 
            +
                )
         | 
| 152 | 
            +
              end
         | 
| 153 | 
            +
            end
         | 
| 154 | 
            +
             | 
    
        data/test/test_grammar.rb
    CHANGED
    
    
    
        data/test/test_server.rb
    CHANGED
    
    | @@ -1,5 +1,5 @@ | |
| 1 1 | 
             
            require "test/unit"
         | 
| 2 | 
            -
            require "faye"
         | 
| 2 | 
            +
            require File.dirname(__FILE__) + "/../lib/faye"
         | 
| 3 3 |  | 
| 4 4 | 
             
            class TestServer < Test::Unit::TestCase
         | 
| 5 5 | 
             
              include Faye
         | 
| @@ -14,8 +14,9 @@ class TestServer < Test::Unit::TestCase | |
| 14 14 | 
             
                @r['clientId']
         | 
| 15 15 | 
             
              end
         | 
| 16 16 |  | 
| 17 | 
            -
              def method_missing(*args, &block)
         | 
| 18 | 
            -
                 | 
| 17 | 
            +
              def method_missing(channel, message, *args, &block)
         | 
| 18 | 
            +
                message['channel'] = "/meta/#{channel}"
         | 
| 19 | 
            +
                @r = @server.__send__(channel, message, *args, &block)
         | 
| 19 20 | 
             
              end
         | 
| 20 21 |  | 
| 21 22 | 
             
              def test_handshake
         | 
| @@ -30,7 +31,7 @@ class TestServer < Test::Unit::TestCase | |
| 30 31 | 
             
                assert_equal  '/meta/handshake',                  @r['channel']
         | 
| 31 32 | 
             
                assert_not_equal  nil,                            @r['version']
         | 
| 32 33 | 
             
                assert_equal  %w[long-polling callback-polling],  @r['supportedConnectionTypes']
         | 
| 33 | 
            -
                assert_match | 
| 34 | 
            +
                assert_match( /[a-z0-9]+/,                        @r['clientId'] )
         | 
| 34 35 | 
             
                assert_equal  true,                               @r['successful']
         | 
| 35 36 | 
             
                # MAY
         | 
| 36 37 | 
             
                assert_equal  nil,                                @r['id']
         | 
| @@ -93,7 +94,7 @@ class TestServer < Test::Unit::TestCase | |
| 93 94 | 
             
                assert_equal  '/meta/handshake',                  @r['channel']
         | 
| 94 95 | 
             
                assert_not_equal  nil,                            @r['version']
         | 
| 95 96 | 
             
                assert_equal  nil,                                @r['supportedConnectionTypes']
         | 
| 96 | 
            -
                assert_match | 
| 97 | 
            +
                assert_match( /[a-z0-9]+/,                        @r['clientId'] )
         | 
| 97 98 | 
             
                assert_equal  true,                               @r['successful']
         | 
| 98 99 | 
             
              end
         | 
| 99 100 |  | 
| @@ -446,14 +447,14 @@ class TestServer < Test::Unit::TestCase | |
| 446 447 | 
             
              end
         | 
| 447 448 |  | 
| 448 449 | 
             
              def test_advice
         | 
| 449 | 
            -
                handle | 
| 450 | 
            +
                @server.send :handle, 'channel' => '/meta/subscribe', 'subscription' => '/foo', 'clientId' => 'fake' do |r|
         | 
| 450 451 | 
             
                  assert_equal  '401:fake:Unknown client', r['error']
         | 
| 451 452 | 
             
                  assert_equal  'handshake',      r['advice']['reconnect']
         | 
| 452 453 | 
             
                  assert_equal  1000,             r['advice']['interval']
         | 
| 453 454 | 
             
                end
         | 
| 454 455 |  | 
| 455 456 | 
             
                id = get_client_id
         | 
| 456 | 
            -
                handle | 
| 457 | 
            +
                @server.send :handle, 'channel' => '/meta/subscribe', 'subscription' => '/foo', 'clientId' => id do |r|
         | 
| 457 458 | 
             
                  assert_equal  true,             r['successful']
         | 
| 458 459 | 
             
                  assert_equal  'retry',          r['advice']['reconnect']
         | 
| 459 460 | 
             
                  assert_equal  1000,             r['advice']['interval']
         | 
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification 
         | 
| 2 2 | 
             
            name: faye
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version 
         | 
| 4 | 
            -
              version: 0.3. | 
| 4 | 
            +
              version: 0.3.2
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors: 
         | 
| 7 7 | 
             
            - James Coglan
         | 
| @@ -9,7 +9,7 @@ autorequire: | |
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 11 |  | 
| 12 | 
            -
            date: 2010- | 
| 12 | 
            +
            date: 2010-04-04 00:00:00 +01:00
         | 
| 13 13 | 
             
            default_executable: 
         | 
| 14 14 | 
             
            dependencies: 
         | 
| 15 15 | 
             
            - !ruby/object:Gem::Dependency 
         | 
| @@ -43,34 +43,34 @@ dependencies: | |
| 43 43 | 
             
                    version: "1.0"
         | 
| 44 44 | 
             
                version: 
         | 
| 45 45 | 
             
            - !ruby/object:Gem::Dependency 
         | 
| 46 | 
            -
              name:  | 
| 46 | 
            +
              name: thin
         | 
| 47 47 | 
             
              type: :runtime
         | 
| 48 48 | 
             
              version_requirement: 
         | 
| 49 49 | 
             
              version_requirements: !ruby/object:Gem::Requirement 
         | 
| 50 50 | 
             
                requirements: 
         | 
| 51 51 | 
             
                - - ">="
         | 
| 52 52 | 
             
                  - !ruby/object:Gem::Version 
         | 
| 53 | 
            -
                    version: "1. | 
| 53 | 
            +
                    version: "1.2"
         | 
| 54 54 | 
             
                version: 
         | 
| 55 55 | 
             
            - !ruby/object:Gem::Dependency 
         | 
| 56 | 
            -
              name:  | 
| 57 | 
            -
              type: : | 
| 56 | 
            +
              name: json
         | 
| 57 | 
            +
              type: :runtime
         | 
| 58 58 | 
             
              version_requirement: 
         | 
| 59 59 | 
             
              version_requirements: !ruby/object:Gem::Requirement 
         | 
| 60 60 | 
             
                requirements: 
         | 
| 61 61 | 
             
                - - ">="
         | 
| 62 62 | 
             
                  - !ruby/object:Gem::Version 
         | 
| 63 | 
            -
                    version:  | 
| 63 | 
            +
                    version: "1.0"
         | 
| 64 64 | 
             
                version: 
         | 
| 65 65 | 
             
            - !ruby/object:Gem::Dependency 
         | 
| 66 | 
            -
              name:  | 
| 66 | 
            +
              name: rubyforge
         | 
| 67 67 | 
             
              type: :development
         | 
| 68 68 | 
             
              version_requirement: 
         | 
| 69 69 | 
             
              version_requirements: !ruby/object:Gem::Requirement 
         | 
| 70 70 | 
             
                requirements: 
         | 
| 71 71 | 
             
                - - ">="
         | 
| 72 72 | 
             
                  - !ruby/object:Gem::Version 
         | 
| 73 | 
            -
                    version: 0.3 | 
| 73 | 
            +
                    version: 2.0.3
         | 
| 74 74 | 
             
                version: 
         | 
| 75 75 | 
             
            - !ruby/object:Gem::Dependency 
         | 
| 76 76 | 
             
              name: hoe
         | 
| @@ -80,7 +80,7 @@ dependencies: | |
| 80 80 | 
             
                requirements: 
         | 
| 81 81 | 
             
                - - ">="
         | 
| 82 82 | 
             
                  - !ruby/object:Gem::Version 
         | 
| 83 | 
            -
                    version: 2. | 
| 83 | 
            +
                    version: 2.6.0
         | 
| 84 84 | 
             
                version: 
         | 
| 85 85 | 
             
            description: ""
         | 
| 86 86 | 
             
            email: 
         | 
| @@ -107,6 +107,8 @@ files: | |
| 107 107 | 
             
            - examples/shared/public/index.html
         | 
| 108 108 | 
             
            - examples/shared/public/favicon.ico
         | 
| 109 109 | 
             
            - examples/shared/public/jquery.js
         | 
| 110 | 
            +
            - examples/shared/public/mootools.js
         | 
| 111 | 
            +
            - examples/shared/public/prototype.js
         | 
| 110 112 | 
             
            - examples/shared/public/robots.txt
         | 
| 111 113 | 
             
            - examples/shared/public/soapbox.js
         | 
| 112 114 | 
             
            - examples/shared/public/style.css
         | 
| @@ -127,10 +129,13 @@ files: | |
| 127 129 | 
             
            - lib/faye/namespace.rb
         | 
| 128 130 | 
             
            - lib/faye/rack_adapter.rb
         | 
| 129 131 | 
             
            - lib/faye/server.rb
         | 
| 132 | 
            +
            - lib/faye/timeouts.rb
         | 
| 130 133 | 
             
            - lib/faye/transport.rb
         | 
| 131 134 | 
             
            - test/scenario.js
         | 
| 135 | 
            +
            - test/scenario.rb
         | 
| 132 136 | 
             
            - test/test_channel.rb
         | 
| 133 137 | 
             
            - test/test_clients.js
         | 
| 138 | 
            +
            - test/test_clients.rb
         | 
| 134 139 | 
             
            - test/test_grammar.rb
         | 
| 135 140 | 
             
            - test/test_server.rb
         | 
| 136 141 | 
             
            has_rdoc: true
         | 
| @@ -163,6 +168,7 @@ signing_key: | |
| 163 168 | 
             
            specification_version: 3
         | 
| 164 169 | 
             
            summary: ""
         | 
| 165 170 | 
             
            test_files: 
         | 
| 171 | 
            +
            - test/test_grammar.rb
         | 
| 166 172 | 
             
            - test/test_server.rb
         | 
| 173 | 
            +
            - test/test_clients.rb
         | 
| 167 174 | 
             
            - test/test_channel.rb
         | 
| 168 | 
            -
            - test/test_grammar.rb
         |