jubilee 1.0.2 → 1.1.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (128) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +1 -1
  3. data/CHANGELOG +17 -0
  4. data/Gemfile +19 -1
  5. data/Gemfile.lock +189 -31
  6. data/LICENSE.txt +20 -0
  7. data/README.md +44 -5
  8. data/ROADMAP +5 -0
  9. data/Rakefile +6 -5
  10. data/examples/chatapp/Gemfile +2 -1
  11. data/examples/chatapp/Gemfile.lock +8 -6
  12. data/examples/chatapp/README.md +5 -2
  13. data/examples/chatapp/app.rb +24 -0
  14. data/examples/chatapp/public/assets/javascripts/application.js +59 -6
  15. data/examples/chatapp/public/assets/stylesheets/application.css +25 -0
  16. data/examples/jubilee.conf.rb +0 -3
  17. data/jars/{hazelcast-2.6.jar → hazelcast-2.6.3.jar} +0 -0
  18. data/jars/{netty-all-4.0.4.Final.jar → netty-all-4.0.13.Final.jar} +0 -0
  19. data/jars/vertx-core-2.1M3-SNAPSHOT.jar +0 -0
  20. data/jars/vertx-hazelcast-2.1M3-SNAPSHOT.jar +0 -0
  21. data/java/src/jubilee/JubileeService.java +7 -7
  22. data/java/src/org/jruby/jubilee/Const.java +10 -35
  23. data/java/src/org/jruby/jubilee/RackApplication.java +77 -46
  24. data/java/src/org/jruby/jubilee/RackResponse.java +1 -3
  25. data/java/src/org/jruby/jubilee/RubyHttpServerResponse.java +88 -0
  26. data/java/src/org/jruby/jubilee/{Server.java → RubyServer.java} +17 -14
  27. data/java/src/org/jruby/jubilee/impl/RackEnvironment.java +157 -0
  28. data/java/src/org/jruby/jubilee/impl/RackEnvironmentHash.java +449 -0
  29. data/java/src/org/jruby/jubilee/impl/RubyIORackInput.java +5 -5
  30. data/java/src/org/jruby/jubilee/impl/{NullIO.java → RubyNullIO.java} +5 -9
  31. data/java/src/org/jruby/jubilee/utils/RubyHelper.java +37 -0
  32. data/jubilee.gemspec +101 -14
  33. data/lib/jubilee.rb +4 -3
  34. data/lib/jubilee/cli.rb +2 -1
  35. data/lib/jubilee/configuration.rb +4 -9
  36. data/lib/jubilee/const.rb +2 -2
  37. data/lib/jubilee/jubilee.jar +0 -0
  38. data/lib/jubilee/response.rb +9 -8
  39. data/lib/jubilee/server.rb +1 -1
  40. data/lib/jubilee/version.rb +8 -1
  41. data/lib/rack/chunked.rb +38 -0
  42. data/spec/apps/rack/basic/config.ru +50 -0
  43. data/spec/apps/rails4/basic/.gitignore +16 -0
  44. data/spec/apps/rails4/basic/Gemfile +41 -0
  45. data/spec/apps/rails4/basic/Gemfile.lock +127 -0
  46. data/spec/apps/rails4/basic/README.rdoc +28 -0
  47. data/spec/apps/rails4/basic/Rakefile +6 -0
  48. data/spec/apps/rails4/basic/app/assets/images/.keep +0 -0
  49. data/spec/apps/rails4/basic/app/assets/images/rails.png +0 -0
  50. data/spec/apps/rails4/basic/app/assets/javascripts/application.js +16 -0
  51. data/spec/apps/rails4/basic/app/assets/stylesheets/application.css +13 -0
  52. data/spec/apps/rails4/basic/app/controllers/application_controller.rb +5 -0
  53. data/spec/apps/rails4/basic/app/controllers/concerns/.keep +0 -0
  54. data/spec/apps/rails4/basic/app/controllers/reloader_controller.rb +11 -0
  55. data/spec/apps/rails4/basic/app/controllers/reloader_controller.rb.erb +11 -0
  56. data/spec/apps/rails4/basic/app/controllers/root_controller.rb +14 -0
  57. data/spec/apps/rails4/basic/app/helpers/application_helper.rb +2 -0
  58. data/spec/apps/rails4/basic/app/mailers/.keep +0 -0
  59. data/spec/apps/rails4/basic/app/models/.keep +0 -0
  60. data/spec/apps/rails4/basic/app/models/concerns/.keep +0 -0
  61. data/spec/apps/rails4/basic/app/views/layouts/application.html.erb +14 -0
  62. data/spec/apps/rails4/basic/app/views/reloader/index.html.erb +1 -0
  63. data/spec/apps/rails4/basic/app/views/root/index.html.erb +8 -0
  64. data/spec/apps/rails4/basic/app/views/root/streaming.html.erb +6 -0
  65. data/spec/apps/rails4/basic/bin/bundle +3 -0
  66. data/spec/apps/rails4/basic/bin/rails +4 -0
  67. data/spec/apps/rails4/basic/bin/rake +4 -0
  68. data/spec/apps/rails4/basic/config.ru +4 -0
  69. data/spec/apps/rails4/basic/config/application.rb +23 -0
  70. data/spec/apps/rails4/basic/config/boot.rb +4 -0
  71. data/spec/apps/rails4/basic/config/database.yml +20 -0
  72. data/spec/apps/rails4/basic/config/environment.rb +5 -0
  73. data/spec/apps/rails4/basic/config/environments/development.rb +29 -0
  74. data/spec/apps/rails4/basic/config/environments/production.rb +80 -0
  75. data/spec/apps/rails4/basic/config/environments/test.rb +36 -0
  76. data/spec/apps/rails4/basic/config/initializers/backtrace_silencers.rb +7 -0
  77. data/spec/apps/rails4/basic/config/initializers/filter_parameter_logging.rb +4 -0
  78. data/spec/apps/rails4/basic/config/initializers/inflections.rb +16 -0
  79. data/spec/apps/rails4/basic/config/initializers/mime_types.rb +5 -0
  80. data/spec/apps/rails4/basic/config/initializers/secret_token.rb +12 -0
  81. data/spec/apps/rails4/basic/config/initializers/session_store.rb +2 -0
  82. data/spec/apps/rails4/basic/config/initializers/wrap_parameters.rb +14 -0
  83. data/spec/apps/rails4/basic/config/locales/en.yml +23 -0
  84. data/spec/apps/rails4/basic/config/routes.rb +5 -0
  85. data/spec/apps/rails4/basic/db/seeds.rb +7 -0
  86. data/spec/apps/rails4/basic/lib/assets/.keep +0 -0
  87. data/spec/apps/rails4/basic/lib/tasks/.keep +0 -0
  88. data/spec/apps/rails4/basic/public/404.html +58 -0
  89. data/spec/apps/rails4/basic/public/422.html +58 -0
  90. data/spec/apps/rails4/basic/public/500.html +57 -0
  91. data/spec/apps/rails4/basic/public/favicon.ico +0 -0
  92. data/spec/apps/rails4/basic/public/robots.txt +5 -0
  93. data/spec/apps/rails4/basic/public/some_page.html +7 -0
  94. data/spec/apps/rails4/basic/test/controllers/.keep +0 -0
  95. data/spec/apps/rails4/basic/test/fixtures/.keep +0 -0
  96. data/spec/apps/rails4/basic/test/helpers/.keep +0 -0
  97. data/spec/apps/rails4/basic/test/integration/.keep +0 -0
  98. data/spec/apps/rails4/basic/test/mailers/.keep +0 -0
  99. data/spec/apps/rails4/basic/test/models/.keep +0 -0
  100. data/spec/apps/rails4/basic/test/test_helper.rb +15 -0
  101. data/spec/apps/rails4/basic/vendor/assets/javascripts/.keep +0 -0
  102. data/spec/apps/rails4/basic/vendor/assets/stylesheets/.keep +0 -0
  103. data/spec/apps/sinatra/basic/Gemfile +4 -0
  104. data/spec/apps/sinatra/basic/Gemfile.lock +20 -0
  105. data/spec/apps/sinatra/basic/basic.rb +27 -0
  106. data/spec/apps/sinatra/basic/config.ru +7 -0
  107. data/spec/apps/sinatra/basic/public/some_page.html +7 -0
  108. data/spec/apps/sinatra/basic/views/index.erb +4 -0
  109. data/spec/apps/sinatra/basic/views/posted.haml +2 -0
  110. data/spec/apps/sinatra/basic/views/poster.haml +4 -0
  111. data/spec/apps/sinatra/basic/views/request_mapping.haml +4 -0
  112. data/spec/integration/basic_rack_spec.rb +89 -0
  113. data/spec/integration/basic_rails4_spec.rb +64 -0
  114. data/spec/integration/basic_sinatra_spec.rb +80 -0
  115. data/spec/spec_helper.rb +13 -0
  116. data/test/jubilee/test_cli.rb +1 -1
  117. data/test/jubilee/test_configuration.rb +18 -1
  118. data/test/jubilee/test_rack_server.rb +7 -7
  119. data/test/jubilee/test_response.rb +35 -36
  120. data/test/jubilee/test_server.rb +1 -1
  121. data/test/jubilee/test_upload.rb +14 -11
  122. data/test/test_helper.rb +1 -0
  123. metadata +97 -18
  124. data/VERSION +0 -1
  125. data/jars/vertx-core-2.1.0-SNAPSHOT.jar +0 -0
  126. data/java/src/org/jruby/jubilee/RackErrors.java +0 -44
  127. data/java/src/org/jruby/jubilee/impl/DefaultRackEnvironment.java +0 -99
  128. data/java/src/org/jruby/jubilee/impl/RubyIORackErrors.java +0 -68
@@ -39,9 +39,9 @@ public class RubyIORackInput extends RubyObject implements RackInput {
39
39
  }
40
40
  };
41
41
 
42
- public static RubyClass createRubyIORackInputClass(Ruby runtime) {
43
- RubyModule jModule = runtime.defineModule("Jubilee");
44
- RubyClass rackIOInputClass = jModule.defineClassUnder("RubyIORackInput", runtime.getObject(), ALLOCATOR);
42
+ public static RubyClass createIORackInputClass(Ruby runtime) {
43
+ RubyModule jModule = runtime.getOrCreateModule("Jubilee");
44
+ RubyClass rackIOInputClass = jModule.defineClassUnder("IORackInput", runtime.getObject(), ALLOCATOR);
45
45
  rackIOInputClass.defineAnnotatedMethods(RubyIORackInput.class);
46
46
  return rackIOInputClass;
47
47
  }
@@ -50,8 +50,8 @@ public class RubyIORackInput extends RubyObject implements RackInput {
50
50
  super(runtime, metaClass);
51
51
  }
52
52
 
53
- public RubyIORackInput(Ruby runtime, HttpServerRequest request, ByteBuf buf, AtomicBoolean eof) {
54
- this(runtime, createRubyIORackInputClass(runtime));
53
+ public RubyIORackInput(Ruby runtime, RubyClass rubyClass, HttpServerRequest request, ByteBuf buf, AtomicBoolean eof) {
54
+ this(runtime, rubyClass);
55
55
  this.request = request;
56
56
  String hdr = request.headers().get(Const.Vertx.CONTENT_LENGTH);
57
57
  this.chunked = hdr == null;
@@ -17,26 +17,22 @@ import org.jruby.runtime.builtin.IRubyObject;
17
17
  * Date: 11/26/12
18
18
  * Time: 12:11 PM
19
19
  */
20
- public class NullIO extends RubyObject implements RackInput {
20
+ public class RubyNullIO extends RubyObject implements RackInput {
21
21
  public static RubyClass createNullIOClass(Ruby ruby) {
22
- RubyModule jModule = ruby.defineModule("Jubilee");
22
+ RubyModule jModule = ruby.getOrCreateModule("Jubilee");
23
23
  RubyClass nullIOClass = jModule.defineClassUnder("NullIO", ruby.getObject(), ALLOCATOR);
24
- nullIOClass.defineAnnotatedMethods(NullIO.class);
24
+ nullIOClass.defineAnnotatedMethods(RubyNullIO.class);
25
25
  return nullIOClass;
26
26
  }
27
27
 
28
28
  public static ObjectAllocator ALLOCATOR = new ObjectAllocator() {
29
29
  @Override
30
30
  public IRubyObject allocate(Ruby ruby, RubyClass rubyClass) {
31
- return new NullIO(ruby, rubyClass);
31
+ return new RubyNullIO(ruby, rubyClass);
32
32
  }
33
33
  };
34
34
 
35
- public NullIO(Ruby ruby) {
36
- this(ruby, createNullIOClass(ruby));
37
- }
38
-
39
- public NullIO(Ruby runtime, RubyClass metaClass) {
35
+ public RubyNullIO(Ruby runtime, RubyClass metaClass) {
40
36
  super(runtime, metaClass);
41
37
  }
42
38
 
@@ -0,0 +1,37 @@
1
+ package org.jruby.jubilee.utils;
2
+
3
+ import org.jcodings.specific.USASCIIEncoding;
4
+ import org.jruby.Ruby;
5
+ import org.jruby.RubyHash;
6
+ import org.jruby.RubyModule;
7
+ import org.jruby.RubyString;
8
+ import org.jruby.javasupport.JavaEmbedUtils;
9
+ import org.jruby.util.ByteList;
10
+
11
+ import java.util.Map;
12
+ import java.util.Map.Entry;
13
+
14
+ /**
15
+ * Ruby reflection helper utilities.
16
+ *
17
+ * @author Bob McWhirter <bmcwhirt@redhat.com>
18
+ */
19
+ public class RubyHelper {
20
+
21
+ public static final RubyString toUsAsciiRubyString(final Ruby runtime, final String string) {
22
+ byte[] bytes = new byte[string.length()];
23
+ for (int i = 0; i < bytes.length; i++) {
24
+ bytes[i] = (byte) string.charAt(i);
25
+ }
26
+ return toUsAsciiRubyString(runtime, bytes);
27
+ }
28
+
29
+ public static final RubyString toUsAsciiRubyString(final Ruby runtime, final byte[] bytes) {
30
+ return RubyString.newString(runtime, new ByteList(bytes, USASCIIEncoding.INSTANCE, false));
31
+ }
32
+
33
+ public static final RubyString toUnicodeRubyString(final Ruby runtime, final String string) {
34
+ return RubyString.newUnicodeString(runtime, string);
35
+ }
36
+ }
37
+
data/jubilee.gemspec CHANGED
@@ -2,15 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
+ # stub: jubilee 1.1.0.rc1 ruby lib
5
6
 
6
7
  Gem::Specification.new do |s|
7
8
  s.name = "jubilee"
8
- s.version = "1.0.0.beta1"
9
+ s.version = "1.1.0.rc1"
9
10
 
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
11
12
  s.authors = ["Isaiah Peng"]
12
- s.date = "2013-09-22"
13
- s.description = "Jubilee is a experimental webserver built for speed, it's based on Vertx."
13
+ s.date = "2013-12-30"
14
+ s.description = "Jubilee is a jruby webserver built upon Vertx."
14
15
  s.email = "issaria@gmail.com"
15
16
  s.executables = ["jubilee", "jubilee_d"]
16
17
  s.extra_rdoc_files = [
@@ -23,35 +24,48 @@ Gem::Specification.new do |s|
23
24
  "Gemfile",
24
25
  "Gemfile.lock",
25
26
  "Guardfile",
27
+ "KNOWN_ISSUES",
26
28
  "README.md",
27
29
  "Rakefile",
28
- "VERSION",
29
30
  "bin/jubilee",
30
31
  "bin/jubilee_d",
32
+ "examples/chatapp/Gemfile",
33
+ "examples/chatapp/Gemfile.lock",
34
+ "examples/chatapp/README.md",
35
+ "examples/chatapp/app.rb",
36
+ "examples/chatapp/config.ru",
37
+ "examples/chatapp/public/assets/javascripts/application.js",
38
+ "examples/chatapp/public/assets/javascripts/jquery.js",
39
+ "examples/chatapp/public/assets/javascripts/sockjs-0.3.4.min.js",
40
+ "examples/chatapp/public/assets/javascripts/vertxbus.js",
41
+ "examples/chatapp/public/assets/stylesheets/application.css",
31
42
  "examples/client/sockjs-0.3.4.min.js",
32
43
  "examples/client/vertxbus.js",
33
44
  "examples/jubilee.conf.rb",
34
45
  "examples/jubilee/keystore.jks",
35
46
  "examples/jubilee/server-keystore.jks",
36
- "jars/hazelcast-2.6.jar",
47
+ "jars/hazelcast-2.6.3.jar",
37
48
  "jars/jackson-annotations-2.2.2.jar",
38
49
  "jars/jackson-core-2.2.2.jar",
39
50
  "jars/jackson-databind-2.2.2.jar",
40
- "jars/netty-all-4.0.4.Final.jar",
41
- "jars/vertx-core-2.1.0-SNAPSHOT.jar",
51
+ "jars/netty-all-4.0.13.Final.jar",
52
+ "jars/vertx-core-2.1M3-SNAPSHOT.jar",
53
+ "jars/vertx-hazelcast-2.1M3-SNAPSHOT.jar",
42
54
  "java/src/jubilee/JubileeService.java",
43
55
  "java/src/org/jruby/jubilee/Const.java",
44
56
  "java/src/org/jruby/jubilee/RackApplication.java",
45
57
  "java/src/org/jruby/jubilee/RackEnvironment.java",
46
- "java/src/org/jruby/jubilee/RackErrors.java",
47
58
  "java/src/org/jruby/jubilee/RackInput.java",
48
59
  "java/src/org/jruby/jubilee/RackResponse.java",
49
- "java/src/org/jruby/jubilee/Server.java",
60
+ "java/src/org/jruby/jubilee/RubyHttpServerResponse.java",
61
+ "java/src/org/jruby/jubilee/RubyServer.java",
50
62
  "java/src/org/jruby/jubilee/deploy/Starter.java",
51
63
  "java/src/org/jruby/jubilee/impl/DefaultRackEnvironment.java",
52
- "java/src/org/jruby/jubilee/impl/NullIO.java",
53
- "java/src/org/jruby/jubilee/impl/RubyIORackErrors.java",
64
+ "java/src/org/jruby/jubilee/impl/RackEnvironment.java",
65
+ "java/src/org/jruby/jubilee/impl/RackEnvironmentHash.java",
54
66
  "java/src/org/jruby/jubilee/impl/RubyIORackInput.java",
67
+ "java/src/org/jruby/jubilee/impl/RubyNullIO.java",
68
+ "java/src/org/jruby/jubilee/utils/RubyHelper.java",
55
69
  "java/src/org/jruby/jubilee/vertx/JubileeVertx.java",
56
70
  "jubilee.gemspec",
57
71
  "lib/jubilee.rb",
@@ -69,6 +83,79 @@ Gem::Specification.new do |s|
69
83
  "lib/vertx/buffer.rb",
70
84
  "lib/vertx/event_bus.rb",
71
85
  "lib/vertx/shared_data.rb",
86
+ "spec/apps/rack/basic/config.ru",
87
+ "spec/apps/rails4/basic/.gitignore",
88
+ "spec/apps/rails4/basic/Gemfile",
89
+ "spec/apps/rails4/basic/README.rdoc",
90
+ "spec/apps/rails4/basic/Rakefile",
91
+ "spec/apps/rails4/basic/app/assets/images/.keep",
92
+ "spec/apps/rails4/basic/app/assets/images/rails.png",
93
+ "spec/apps/rails4/basic/app/assets/javascripts/application.js",
94
+ "spec/apps/rails4/basic/app/assets/stylesheets/application.css",
95
+ "spec/apps/rails4/basic/app/controllers/application_controller.rb",
96
+ "spec/apps/rails4/basic/app/controllers/concerns/.keep",
97
+ "spec/apps/rails4/basic/app/controllers/reloader_controller.rb",
98
+ "spec/apps/rails4/basic/app/controllers/reloader_controller.rb.erb",
99
+ "spec/apps/rails4/basic/app/controllers/root_controller.rb",
100
+ "spec/apps/rails4/basic/app/helpers/application_helper.rb",
101
+ "spec/apps/rails4/basic/app/mailers/.keep",
102
+ "spec/apps/rails4/basic/app/models/.keep",
103
+ "spec/apps/rails4/basic/app/models/concerns/.keep",
104
+ "spec/apps/rails4/basic/app/views/layouts/application.html.erb",
105
+ "spec/apps/rails4/basic/app/views/reloader/index.html.erb",
106
+ "spec/apps/rails4/basic/app/views/root/index.html.erb",
107
+ "spec/apps/rails4/basic/app/views/root/streaming.html.erb",
108
+ "spec/apps/rails4/basic/bin/bundle",
109
+ "spec/apps/rails4/basic/bin/rails",
110
+ "spec/apps/rails4/basic/bin/rake",
111
+ "spec/apps/rails4/basic/config.ru",
112
+ "spec/apps/rails4/basic/config/application.rb",
113
+ "spec/apps/rails4/basic/config/boot.rb",
114
+ "spec/apps/rails4/basic/config/database.yml",
115
+ "spec/apps/rails4/basic/config/environment.rb",
116
+ "spec/apps/rails4/basic/config/environments/development.rb",
117
+ "spec/apps/rails4/basic/config/environments/production.rb",
118
+ "spec/apps/rails4/basic/config/environments/test.rb",
119
+ "spec/apps/rails4/basic/config/initializers/backtrace_silencers.rb",
120
+ "spec/apps/rails4/basic/config/initializers/filter_parameter_logging.rb",
121
+ "spec/apps/rails4/basic/config/initializers/inflections.rb",
122
+ "spec/apps/rails4/basic/config/initializers/mime_types.rb",
123
+ "spec/apps/rails4/basic/config/initializers/secret_token.rb",
124
+ "spec/apps/rails4/basic/config/initializers/session_store.rb",
125
+ "spec/apps/rails4/basic/config/initializers/wrap_parameters.rb",
126
+ "spec/apps/rails4/basic/config/locales/en.yml",
127
+ "spec/apps/rails4/basic/config/routes.rb",
128
+ "spec/apps/rails4/basic/db/seeds.rb",
129
+ "spec/apps/rails4/basic/lib/assets/.keep",
130
+ "spec/apps/rails4/basic/lib/tasks/.keep",
131
+ "spec/apps/rails4/basic/public/404.html",
132
+ "spec/apps/rails4/basic/public/422.html",
133
+ "spec/apps/rails4/basic/public/500.html",
134
+ "spec/apps/rails4/basic/public/favicon.ico",
135
+ "spec/apps/rails4/basic/public/robots.txt",
136
+ "spec/apps/rails4/basic/public/some_page.html",
137
+ "spec/apps/rails4/basic/test/controllers/.keep",
138
+ "spec/apps/rails4/basic/test/fixtures/.keep",
139
+ "spec/apps/rails4/basic/test/helpers/.keep",
140
+ "spec/apps/rails4/basic/test/integration/.keep",
141
+ "spec/apps/rails4/basic/test/mailers/.keep",
142
+ "spec/apps/rails4/basic/test/models/.keep",
143
+ "spec/apps/rails4/basic/test/test_helper.rb",
144
+ "spec/apps/rails4/basic/vendor/assets/javascripts/.keep",
145
+ "spec/apps/rails4/basic/vendor/assets/stylesheets/.keep",
146
+ "spec/apps/sinatra/basic/Gemfile",
147
+ "spec/apps/sinatra/basic/Gemfile.lock",
148
+ "spec/apps/sinatra/basic/basic.rb",
149
+ "spec/apps/sinatra/basic/config.ru",
150
+ "spec/apps/sinatra/basic/public/some_page.html",
151
+ "spec/apps/sinatra/basic/views/index.erb",
152
+ "spec/apps/sinatra/basic/views/posted.haml",
153
+ "spec/apps/sinatra/basic/views/poster.haml",
154
+ "spec/apps/sinatra/basic/views/request_mapping.haml",
155
+ "spec/integration/basic_rack_spec.rb",
156
+ "spec/integration/basic_rails4_spec.rb",
157
+ "spec/integration/basic_sinatra_spec.rb",
158
+ "spec/spec_helper.rb",
72
159
  "test/.ruby-version",
73
160
  "test/config/app.rb",
74
161
  "test/jubilee/test_cli.rb",
@@ -86,11 +173,11 @@ Gem::Specification.new do |s|
86
173
  s.homepage = "http://github.com/isaiah/jubilee"
87
174
  s.licenses = ["MIT"]
88
175
  s.require_paths = ["lib"]
89
- s.rubygems_version = "1.8.24"
176
+ s.rubygems_version = "2.1.9"
90
177
  s.summary = "More than a server for rack applications."
91
178
 
92
179
  if s.respond_to? :specification_version then
93
- s.specification_version = 3
180
+ s.specification_version = 4
94
181
 
95
182
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
96
183
  s.add_runtime_dependency(%q<rack>, [">= 1.4.1"])
data/lib/jubilee.rb CHANGED
@@ -1,9 +1,9 @@
1
1
  require File.join(File.dirname(__FILE__), "../jars/jackson-core-2.2.2.jar")
2
2
  require File.join(File.dirname(__FILE__), "../jars/jackson-databind-2.2.2.jar")
3
3
  require File.join(File.dirname(__FILE__), "../jars/jackson-annotations-2.2.2.jar")
4
- require File.join(File.dirname(__FILE__), "../jars/hazelcast-2.6.jar")
5
- require File.join(File.dirname(__FILE__), "../jars/vertx-core-2.1.0-SNAPSHOT.jar")
6
- require File.join(File.dirname(__FILE__), "../jars/netty-all-4.0.4.Final.jar")
4
+ require File.join(File.dirname(__FILE__), "../jars/hazelcast-2.6.3.jar")
5
+ require File.join(File.dirname(__FILE__), "../jars/vertx-core-2.1M3-SNAPSHOT.jar")
6
+ require File.join(File.dirname(__FILE__), "../jars/netty-all-4.0.13.Final.jar")
7
7
 
8
8
  require 'jubilee/jubilee.jar'
9
9
  require 'rack'
@@ -14,3 +14,4 @@ require 'jubilee/application'
14
14
  require 'jubilee/configuration'
15
15
  require 'jubilee/response'
16
16
  require 'rack/handler/jubilee'
17
+ require 'rack/chunked'
data/lib/jubilee/cli.rb CHANGED
@@ -41,7 +41,8 @@ module Jubilee
41
41
  @options = {
42
42
  debug: false,
43
43
  daemon: false,
44
- Port: 3215,
44
+ Port: 8080,
45
+ Host: "0.0.0.0",
45
46
  ssl: false,
46
47
  environment: ENV["RACK_ENV"] || "development"
47
48
  }
@@ -11,7 +11,7 @@ module Jubilee
11
11
  attr_reader :options
12
12
 
13
13
  def initialize(options, &block)
14
- config_file = options.delete(:config_file)
14
+ @config_file = options.delete(:config_file)
15
15
  @options = options.dup
16
16
  @block = block
17
17
 
@@ -50,18 +50,13 @@ module Jubilee
50
50
  "config_file=#{config_file} would not be accessible in" \
51
51
  " working_directory=#{path}"
52
52
  end
53
- end
54
-
55
- # sets the number of worker threads in the threads pool, Each worker thread
56
- # will serve exactly one client at a time.
57
- def worker_threads(nr)
58
- set_int(:worker_threads, nr, 1)
53
+ @options[:chdir] = path
59
54
  end
60
55
 
61
56
  # set the event bus bridge prefix, prefix, options
62
57
  # eventbus /eventbus, inbound: {foo:bar}, outbound: {foo: bar}
63
58
  # will set the event bus prefix as eventbus "/eventbus", it can be
64
- # connected via new EventBus("http://localhost:3215/eventbus"), inbound and
59
+ # connected via new EventBus("http://localhost:8080/eventbus"), inbound and
65
60
  # outbound options are security measures that will filter the messages
66
61
  def eventbus(prefix, options = {})
67
62
  @options[:event_bus][:prefix] = prefix
@@ -129,7 +124,7 @@ module Jubilee
129
124
  inner_app = Object.const_get(File.basename(options[:rackup], '.rb').capitalize.to_sym).new
130
125
  else
131
126
  Dir.chdir options[:chdir] if options[:chdir]
132
- inner_app, opts = Rack::Builder.parse_file "config.ru"
127
+ inner_app, _ = Rack::Builder.parse_file "config.ru"
133
128
  end
134
129
  end
135
130
  inner_app
data/lib/jubilee/const.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module Jubilee
2
2
  module Const
3
- JUBILEE_VERSION = VERSION
3
+ JUBILEE_VERSION = Version::STRING
4
4
  HTTP_11 = "HTTP/1.1".freeze
5
5
  HTTP_10 = "HTTP/1.0".freeze
6
6
 
@@ -35,6 +35,6 @@ module Jubilee
35
35
  HTTP_CONNECTION = "HTTP_CONNECTION".freeze
36
36
  NEWLINE = "\n".freeze
37
37
 
38
- STATUS_WITH_NO_ENTITY_BODY = Hash[Rack::Utils::STATUS_WITH_NO_ENTITY_BODY.map{|s| [s, true]}]
38
+ STATUS_WITH_NO_ENTITY_BODY = Hash[[204,205,304].map{|s| [s, true]}]
39
39
  end
40
40
  end
Binary file
@@ -13,6 +13,7 @@ module Jubilee
13
13
  end
14
14
  end
15
15
 
16
+ # See Rack::Utils::
16
17
  def respond(response)
17
18
  no_body = @status < 200 || STATUS_WITH_NO_ENTITY_BODY[@status]
18
19
  write_status(response)
@@ -21,19 +22,21 @@ module Jubilee
21
22
  response.end
22
23
  else
23
24
  if @body.respond_to?(:to_path)
24
- response.sendFile(@body.to_path)
25
+ response.send_file(@body.to_path)
25
26
  else
26
27
  write_body(response)
27
28
  response.end
28
29
  end
29
30
  end
31
+ rescue NativeException => e
32
+ puts e
30
33
  ensure
31
34
  @body.close if @body.respond_to?(:close)
32
35
  end
33
36
 
34
37
  private
35
38
  def write_status(response)
36
- response.setStatusCode(@status)
39
+ response.status_code = @status
37
40
  end
38
41
 
39
42
  def write_headers(response)
@@ -43,21 +46,19 @@ module Jubilee
43
46
  @content_length = values
44
47
  next
45
48
  when TRANSFER_ENCODING
46
- @allow_chunked = false
47
49
  @content_length = nil
48
50
  end
49
51
  # Multiple values are joined by \n
50
- values.split(NEWLINE).each do |value|
51
- response.putHeader(key, value)
52
- end
52
+ response.put_header(key, values)
53
53
  end
54
54
  end
55
55
 
56
56
  def write_body(response)
57
+ response.put_default_headers
57
58
  if @content_length
58
- response.putHeader(CONTENT_LENGTH, @content_length.to_s)
59
+ response.put_header(CONTENT_LENGTH, @content_length.to_s)
59
60
  else
60
- response.setChunked(true)
61
+ response.chunked = true
61
62
  end
62
63
 
63
64
  @body.each do |part|
@@ -2,7 +2,7 @@ require 'rack/methodoverride'
2
2
  module Jubilee
3
3
  class Server < VertxServer
4
4
  def initialize(app, opts = {})
5
- options = {Port: 3215, ssl: false, number_of_workers: 4}.merge(opts)
5
+ options = {Port: 8080, ssl: false}.merge(opts)
6
6
  if (options[:ssl]) && options[:keystore_path].nil?
7
7
  raise ArgumentError, "Please provide a keystore for ssl"
8
8
  end
@@ -1,3 +1,10 @@
1
1
  module Jubilee
2
- VERSION = "1.0.2".freeze
2
+ module Version
3
+ MAJOR = 1
4
+ MINOR = 1
5
+ PATCH = 0
6
+ BUILD = 'rc1'
7
+
8
+ STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join('.')
9
+ end
3
10
  end
@@ -0,0 +1,38 @@
1
+ # Rails use this to chunk it's streaming response body, which we don't need
2
+ module Rack
3
+ class Chunked
4
+ class Body
5
+ def initialize(body)
6
+ @body = body
7
+ end
8
+
9
+ def each
10
+ @body.each {|chunk| yield chunk}
11
+ end
12
+
13
+ def close
14
+ @body.close if @body.respond_to?(:close)
15
+ end
16
+ end
17
+
18
+ include Rack::Utils
19
+
20
+ def initialize(app)
21
+ @app = app
22
+ end
23
+
24
+ def call(env)
25
+ status, headers, body = @app.call(env)
26
+ headers = HeaderHash.new(headers)
27
+
28
+ unless env['HTTP_VERSION'] == 'HTTP/1.0' ||
29
+ STATUS_WITH_NO_ENTITY_BODY.include?(status) ||
30
+ headers['Content-Length'] ||
31
+ headers['Transfer-Encoding']
32
+ headers.delete('Content-Length')
33
+ headers.delete('Transfer-Encoding')
34
+ end
35
+ [status, headers, body]
36
+ end
37
+ end
38
+ end