bossan 0.1.6 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,3 @@
1
1
  module Bossan
2
- VERSION = "0.1.6"
2
+ VERSION = "0.1.7"
3
3
  end
@@ -1,6 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  require 'rack/handler'
3
- require 'bossan'
3
+ require_relative '../../bossan'
4
4
 
5
5
  module Rack
6
6
  module Handler
@@ -0,0 +1,57 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'test/unit'
3
+ require 'pp'
4
+ require 'bossan'
5
+ require 'net/http'
6
+
7
+
8
+ class RackEnvQueryTest < Test::Unit::TestCase
9
+
10
+ RESPONSE = ["Hello ", "world!"].freeze
11
+ DEFAULT_HOST = "localhost"
12
+ DEFAULT_PORT = 8000
13
+
14
+ def test_query_app
15
+ r, w = IO.pipe
16
+ pid = fork do
17
+ r.close
18
+ trap(:INT) { Bossan.stop }
19
+ Bossan.run(DEFAULT_HOST, DEFAULT_PORT,
20
+ proc {|env|
21
+ @env = env.dup
22
+ # I have no idea how to check this two values..
23
+ @env.delete "rack.input"
24
+ @env.delete "rack.errors"
25
+ w.write @env
26
+ w.close
27
+ body = RESPONSE
28
+ [200,
29
+ {
30
+ 'Content-type'=> 'text/plain',
31
+ 'Content-length'=> RESPONSE.join.size.to_s
32
+ },
33
+ body
34
+ ]
35
+ })
36
+ end
37
+ Process.detach pid
38
+ sleep 2
39
+
40
+ Net::HTTP.start(DEFAULT_HOST, DEFAULT_PORT){|http|
41
+ http.get("/ABC/DEF?a=1234&bbbb=ccc")
42
+ }
43
+
44
+ w.close
45
+ env = r.read
46
+ r.close
47
+
48
+ # env = eval "Hash[" + env.gsub("\"", "'") + "]"
49
+ env = eval "Hash[" + env + "]"
50
+
51
+ assert_equal(env["PATH_INFO"], "/ABC/DEF")
52
+ assert_equal(env["QUERY_STRING"], "a=1234&bbbb=ccc")
53
+ ensure
54
+ Process.kill(:INT, pid)
55
+ end
56
+
57
+ end
@@ -0,0 +1,60 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'bossan'
3
+ require 'test/unit'
4
+ require 'pp'
5
+ require 'net/http'
6
+
7
+
8
+ class RackEnvSimpleTest < Test::Unit::TestCase
9
+
10
+ RESPONSE = ["Hello ", "world!"].freeze
11
+ DEFAULT_HOST = "localhost"
12
+ DEFAULT_PORT = 8000
13
+
14
+ def test_simple_app
15
+ r, w = IO.pipe
16
+ pid = fork do
17
+ r.close
18
+ trap(:INT) { Bossan.stop }
19
+ Bossan.run(DEFAULT_HOST, DEFAULT_PORT,
20
+ proc {|env|
21
+ @env = env.dup
22
+ # I have no idea how to check this two values..
23
+ @env.delete "rack.input"
24
+ @env.delete "rack.errors"
25
+ # pp @env
26
+ w.write @env
27
+ w.close
28
+ body = RESPONSE
29
+ [200,
30
+ {
31
+ 'Content-type'=> 'text/plain',
32
+ 'Content-length'=> RESPONSE.join.size.to_s
33
+ },
34
+ body
35
+ ]
36
+ })
37
+ end
38
+ Process.detach pid
39
+ sleep 2
40
+
41
+ Net::HTTP.start(DEFAULT_HOST, DEFAULT_PORT){|http|
42
+ http.get("/")
43
+ }
44
+
45
+ w.close
46
+ env = r.read
47
+ r.close
48
+
49
+ env = eval "Hash[" + env + "]"
50
+ # pp env
51
+
52
+ assert_equal(env["PATH_INFO"], "/")
53
+ assert_equal(env["SCRIPT_NAME"], "")
54
+ assert_equal(env["QUERY_STRING"], "")
55
+ assert_equal(env["REQUEST_METHOD"], "GET")
56
+ ensure
57
+ Process.kill(:INT, pid)
58
+ end
59
+
60
+ end
@@ -0,0 +1,65 @@
1
+ require_relative '../lib/bossan'
2
+ require 'test/unit'
3
+ require 'net/http'
4
+
5
+ class RackSpecTest < Test::Unit::TestCase
6
+
7
+ ASSERT_RESPONSE = "Hello world!"
8
+ RESPONSE = ["Hello ", "world!"].freeze
9
+ DEFAULT_HOST = "localhost"
10
+ DEFAULT_PORT = 8000
11
+
12
+ class App
13
+ def call env
14
+ body = RESPONSE
15
+ [200,
16
+ {
17
+ 'Content-type'=> 'text/plain',
18
+ 'Content-length'=> RESPONSE.join.size.to_s
19
+ },
20
+ body
21
+ ]
22
+ end
23
+ end
24
+
25
+ def server_is_wake_up? n=100
26
+ n.times {
27
+ begin
28
+ Net::HTTP.start(DEFAULT_HOST, DEFAULT_PORT)
29
+ rescue
30
+ next
31
+ end
32
+ server_is_wake_up = true
33
+ $stderr.puts "*** running success ***"
34
+ return true
35
+ }
36
+ return false
37
+ end
38
+
39
+ private :server_is_wake_up?
40
+
41
+ def setup
42
+ @pid = fork do
43
+ trap(:INT) { Bossan.stop }
44
+ Bossan.run(DEFAULT_HOST, DEFAULT_PORT, App.new)
45
+ end
46
+ Process.detach @pid
47
+ unless server_is_wake_up?
48
+ $stderr.puts "bossan won't wake up until you love it ..."
49
+ exit 1
50
+ end
51
+ end
52
+
53
+ def test_simple
54
+ response = nil
55
+ Net::HTTP.start("localhost", 8000){|http|
56
+ response = http.get("/")
57
+ }
58
+ assert_equal("200", response.code)
59
+ assert_equal(ASSERT_RESPONSE, response.body)
60
+ end
61
+
62
+ def teardown
63
+ Process.kill(:INT, @pid)
64
+ end
65
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bossan
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-21 00:00:00.000000000 Z
12
+ date: 2013-03-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rack
@@ -35,18 +35,44 @@ extensions:
35
35
  - ext/bossan/extconf.rb
36
36
  extra_rdoc_files: []
37
37
  files:
38
+ - .gitignore
39
+ - .travis.yml
40
+ - Gemfile
38
41
  - LICENSE.txt
39
- - lib/bossan/version.rb
40
- - lib/rack/handler/bossan.rb
41
- - lib/bossan.rb
42
+ - README.md
43
+ - Rakefile
44
+ - bossan.gemspec
45
+ - examples/blog/README.md
46
+ - examples/blog/app.rb
47
+ - examples/blog/config.ru
48
+ - examples/blog/public/style.css
49
+ - examples/blog/views/login.erb
50
+ - examples/blog/views/show_entries.erb
51
+ - examples/config.ru
52
+ - examples/hello.rb
53
+ - examples/sinatra_app.rb
54
+ - examples/views/index.haml
55
+ - examples/views_sample.rb
56
+ - ext/bossan/bossan_ext.c
57
+ - ext/bossan/buffer.c
58
+ - ext/bossan/buffer.h
59
+ - ext/bossan/client.h
60
+ - ext/bossan/extconf.rb
61
+ - ext/bossan/http_parser.c
42
62
  - ext/bossan/http_parser.h
63
+ - ext/bossan/picoev.h
43
64
  - ext/bossan/picoev_epoll.c
65
+ - ext/bossan/picoev_kqueue.c
66
+ - ext/bossan/request.c
67
+ - ext/bossan/request.h
44
68
  - ext/bossan/time_cache.c
45
- - ext/bossan/picoev.h
46
69
  - ext/bossan/time_cache.h
47
- - ext/bossan/bossan_ext.c
48
- - ext/bossan/extconf.rb
49
- - ext/bossan/http_parser.c
70
+ - lib/bossan.rb
71
+ - lib/bossan/version.rb
72
+ - lib/rack/handler/bossan.rb
73
+ - test/test_rack_env_query.rb
74
+ - test/test_rack_env_simple.rb
75
+ - test/test_rack_spec.rb
50
76
  homepage: https://github.com/kubo39/bossan
51
77
  licenses: []
52
78
  post_install_message: