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
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 1.0.2
Binary file
@@ -1,44 +0,0 @@
1
- package org.jruby.jubilee;
2
-
3
- /**
4
- * Created with IntelliJ IDEA.
5
- * User: isaiah
6
- * Date: 11/26/12
7
- * Time: 12:01 PM
8
- */
9
- import org.jruby.runtime.ThreadContext;
10
- import org.jruby.runtime.builtin.IRubyObject;
11
-
12
- public interface RackErrors {
13
- /**
14
- * puts must be called with a single argument that responds to to_s.
15
- *
16
- * @param context ruby context
17
- * @param arg must respond to to_s
18
- * @return nil
19
- */
20
- IRubyObject puts( ThreadContext context, IRubyObject arg );
21
-
22
- /**
23
- * write must be called with a single argument that is a String.
24
- *
25
- * @param context ruby context
26
- * @param string a Ruby String
27
- * @return nil
28
- */
29
- IRubyObject write( ThreadContext context, IRubyObject string );
30
-
31
- /**
32
- * flush must be called without arguments and must be called in order to make the error appear for sure.
33
- *
34
- * @return nil
35
- */
36
- IRubyObject flush();
37
-
38
- /**
39
- * close must never be called on the error stream.
40
- *
41
- * @return nil
42
- */
43
- IRubyObject close();
44
- }
@@ -1,99 +0,0 @@
1
- package org.jruby.jubilee.impl;
2
-
3
- import org.jruby.Ruby;
4
- import org.jruby.RubyHash;
5
- import org.jruby.RubyString;
6
- import org.jruby.jubilee.Const;
7
- import org.jruby.jubilee.RackEnvironment;
8
- import org.jruby.jubilee.RackInput;
9
- import org.vertx.java.core.MultiMap;
10
- import org.vertx.java.core.http.HttpServerRequest;
11
-
12
- import java.util.Map;
13
-
14
- /**
15
- * Created with IntelliJ IDEA.
16
- * User: isaiah
17
- * Date: 11/26/12
18
- * Time: 11:40 AM
19
- */
20
- public class DefaultRackEnvironment implements RackEnvironment {
21
- private RubyHash env;
22
- private MultiMap headers;
23
- private Ruby runtime;
24
-
25
- public DefaultRackEnvironment(final Ruby runtime, final HttpServerRequest request, RackInput input, boolean isSSL) {
26
-
27
- this.runtime = runtime;
28
- // DEFAULT
29
- env = RubyHash.newHash(runtime);
30
- env.put(Const.RACK_VERSION, Const.RackVersion(runtime));
31
- env.put(Const.RACK_ERRORS, new RubyIORackErrors(runtime));
32
- env.put(Const.RACK_MULTITHREAD, true);
33
- env.put(Const.RACK_MULTIPROCESS, false);
34
- env.put(Const.RACK_RUNONCE, true);
35
- if (isSSL)
36
- env.put(Const.URL_SCHEME, Const.HTTPS);
37
- else
38
- env.put(Const.URL_SCHEME, Const.HTTP);
39
- env.put(Const.SCRIPT_NAME, "");
40
-
41
- env.put(Const.SERVER_PROTOCOL, Const.HTTP_11);
42
- env.put(Const.SERVER_SOFTWARE, Const.JUBILEE_VERSION);
43
- env.put(Const.GATEWAY_INTERFACE, Const.CGI_VER);
44
-
45
- // Parse request headers
46
- headers = request.headers();
47
- String host;
48
- if ((host = headers.get(Const.Vertx.HOST)) != null) {
49
- int colon = host.indexOf(":");
50
- if (colon > 0) {
51
- env.put(Const.SERVER_NAME, host.substring(0, colon));
52
- env.put(Const.SERVER_PORT, host.substring(colon + 1));
53
- } else {
54
- env.put(Const.SERVER_NAME, host);
55
- env.put(Const.SERVER_PORT, Const.PORT_80);
56
- }
57
-
58
- } else {
59
- env.put(Const.SERVER_NAME, Const.LOCALHOST);
60
- env.put(Const.SERVER_PORT, Const.PORT_80);
61
- }
62
-
63
- env.put(Const.RACK_INPUT, input);
64
- env.put(Const.REQUEST_METHOD, request.method());
65
- env.put(Const.REQUEST_PATH, request.path());
66
- env.put(Const.REQUEST_URI, request.uri());
67
- env.put(Const.QUERY_STRING, orEmpty(request.query()));
68
- env.put(Const.REMOTE_ADDR, request.remoteAddress().getHostString());
69
- env.put(Const.HTTP_HOST, host);
70
- env.put(Const.HTTP_COOKIE, orEmpty(headers.get(Const.Vertx.COOKIE)));
71
- env.put(Const.HTTP_USER_AGENT, headers.get(Const.Vertx.USER_AGENT));
72
- env.put(Const.HTTP_ACCEPT, headers.get(Const.Vertx.ACCEPT));
73
- env.put(Const.HTTP_ACCEPT_LANGUAGE, orEmpty(headers.get(Const.Vertx.ACCEPT_LANGUAGE)));
74
- env.put(Const.HTTP_ACCEPT_ENCODING, orEmpty(headers.get(Const.Vertx.ACCEPT_ENCODING)));
75
- env.put(Const.HTTP_CONNECTION, orEmpty(headers.get(Const.Vertx.CONNECTION)));
76
- env.put(Const.HTTP_CONTENT_TYPE, orEmpty(headers.get(Const.Vertx.CONTENT_TYPE)));
77
-
78
- String contentLength;
79
- if ((contentLength = headers.get(Const.Vertx.CONTENT_LENGTH)) != null)
80
- env.put(Const.HTTP_CONTENT_LENGTH, contentLength);
81
- env.put(Const.PATH_INFO, request.path());
82
-
83
- // Additional headers
84
- for (Map.Entry<String, String> var : Const.ADDITIONAL_HEADERS.entrySet())
85
- setRackHeader(var.getKey(), var.getValue());
86
- }
87
-
88
- public RubyHash getEnv() {
89
- return env;
90
- }
91
-
92
- private RubyString orEmpty(String jString) {
93
- return jString == null ? RubyString.newEmptyString(runtime) : RubyString.newString(runtime, jString);
94
- }
95
-
96
- private void setRackHeader(String vertxHeader, String rackHeader) {
97
- if (headers.contains(vertxHeader)) env.put(rackHeader, headers.get(vertxHeader));
98
- }
99
- }
@@ -1,68 +0,0 @@
1
- package org.jruby.jubilee.impl;
2
-
3
- import org.jruby.Ruby;
4
- import org.jruby.RubyClass;
5
- import org.jruby.RubyModule;
6
- import org.jruby.RubyObject;
7
- import org.jruby.anno.JRubyMethod;
8
- import org.jruby.jubilee.RackErrors;
9
- import org.jruby.runtime.ObjectAllocator;
10
- import org.jruby.runtime.ThreadContext;
11
- import org.jruby.runtime.builtin.IRubyObject;
12
-
13
- /**
14
- * Created with IntelliJ IDEA.
15
- * User: isaiah
16
- * Date: 11/26/12
17
- * Time: 12:03 PM
18
- */
19
- public class RubyIORackErrors extends RubyObject implements RackErrors {
20
-
21
- public static RubyClass createRubyIORackErrorsClass(Ruby runtime) {
22
- RubyModule jModule = runtime.defineModule("Jubilee");
23
- RubyClass rackErrorsClass = jModule.defineClassUnder("RubyIORackErrors", runtime.getObject(), ALLOCATOR);
24
- rackErrorsClass.defineAnnotatedMethods(RubyIORackErrors.class);
25
- return rackErrorsClass;
26
- }
27
-
28
- public static final ObjectAllocator ALLOCATOR = new ObjectAllocator() {
29
- @Override
30
- public IRubyObject allocate(Ruby ruby, RubyClass rubyClass) {
31
- return new RubyIORackErrors(ruby, rubyClass);
32
- }
33
- };
34
-
35
- public RubyIORackErrors(Ruby runtime, RubyClass metaClass) {
36
- super(runtime, metaClass);
37
- }
38
-
39
- public RubyIORackErrors(Ruby runtime) {
40
- super(runtime, createRubyIORackErrorsClass(runtime));
41
- }
42
-
43
- @Override
44
- @JRubyMethod(name = "puts")
45
- public IRubyObject puts(ThreadContext context, IRubyObject arg) {
46
- //getRuntime().getOutputStream().println(arg.toString());
47
- return null; //To change body of implemented methods use File | Settings | File Templates.
48
- }
49
-
50
- @Override
51
- @JRubyMethod
52
- public IRubyObject write(ThreadContext context, IRubyObject string) {
53
- //getRuntime().getOutputStream().println(string.toString());
54
- return null; //To change body of implemented methods use File | Settings | File Templates.
55
- }
56
-
57
- @Override
58
- @JRubyMethod
59
- public IRubyObject flush() {
60
- return null; //To change body of implemented methods use File | Settings | File Templates.
61
- }
62
-
63
- @Override
64
- @JRubyMethod
65
- public IRubyObject close() {
66
- return null; //To change body of implemented methods use File | Settings | File Templates.
67
- }
68
- }