diy_rails 0.1.0 → 0.2.0

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.
Files changed (153) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +5 -2
  3. data/lib/diy_rails/array.rb +5 -0
  4. data/lib/diy_rails/routing.rb +10 -0
  5. data/lib/diy_rails/version.rb +1 -1
  6. data/lib/diy_rails.rb +25 -3
  7. metadata +28 -151
  8. data/vendor/bundle/ruby/3.0.0/bin/rackup +0 -29
  9. data/vendor/bundle/ruby/3.0.0/bin/rake +0 -29
  10. data/vendor/bundle/ruby/3.0.0/cache/rack-2.2.4.gem +0 -0
  11. data/vendor/bundle/ruby/3.0.0/cache/rake-13.0.6.gem +0 -0
  12. data/vendor/bundle/ruby/3.0.0/gems/rack-2.2.4/CHANGELOG.md +0 -708
  13. data/vendor/bundle/ruby/3.0.0/gems/rack-2.2.4/CONTRIBUTING.md +0 -136
  14. data/vendor/bundle/ruby/3.0.0/gems/rack-2.2.4/MIT-LICENSE +0 -20
  15. data/vendor/bundle/ruby/3.0.0/gems/rack-2.2.4/README.rdoc +0 -306
  16. data/vendor/bundle/ruby/3.0.0/gems/rack-2.2.4/Rakefile +0 -130
  17. data/vendor/bundle/ruby/3.0.0/gems/rack-2.2.4/SPEC.rdoc +0 -288
  18. data/vendor/bundle/ruby/3.0.0/gems/rack-2.2.4/bin/rackup +0 -5
  19. data/vendor/bundle/ruby/3.0.0/gems/rack-2.2.4/contrib/rack.png +0 -0
  20. data/vendor/bundle/ruby/3.0.0/gems/rack-2.2.4/contrib/rack.svg +0 -150
  21. data/vendor/bundle/ruby/3.0.0/gems/rack-2.2.4/contrib/rack_logo.svg +0 -164
  22. data/vendor/bundle/ruby/3.0.0/gems/rack-2.2.4/contrib/rdoc.css +0 -412
  23. data/vendor/bundle/ruby/3.0.0/gems/rack-2.2.4/example/lobster.ru +0 -6
  24. data/vendor/bundle/ruby/3.0.0/gems/rack-2.2.4/example/protectedlobster.rb +0 -16
  25. data/vendor/bundle/ruby/3.0.0/gems/rack-2.2.4/example/protectedlobster.ru +0 -10
  26. data/vendor/bundle/ruby/3.0.0/gems/rack-2.2.4/lib/rack/auth/abstract/handler.rb +0 -39
  27. data/vendor/bundle/ruby/3.0.0/gems/rack-2.2.4/lib/rack/auth/abstract/request.rb +0 -47
  28. data/vendor/bundle/ruby/3.0.0/gems/rack-2.2.4/lib/rack/auth/basic.rb +0 -61
  29. data/vendor/bundle/ruby/3.0.0/gems/rack-2.2.4/lib/rack/auth/digest/md5.rb +0 -131
  30. data/vendor/bundle/ruby/3.0.0/gems/rack-2.2.4/lib/rack/auth/digest/nonce.rb +0 -54
  31. data/vendor/bundle/ruby/3.0.0/gems/rack-2.2.4/lib/rack/auth/digest/params.rb +0 -54
  32. data/vendor/bundle/ruby/3.0.0/gems/rack-2.2.4/lib/rack/auth/digest/request.rb +0 -43
  33. data/vendor/bundle/ruby/3.0.0/gems/rack-2.2.4/lib/rack/body_proxy.rb +0 -45
  34. data/vendor/bundle/ruby/3.0.0/gems/rack-2.2.4/lib/rack/builder.rb +0 -257
  35. data/vendor/bundle/ruby/3.0.0/gems/rack-2.2.4/lib/rack/cascade.rb +0 -68
  36. data/vendor/bundle/ruby/3.0.0/gems/rack-2.2.4/lib/rack/chunked.rb +0 -117
  37. data/vendor/bundle/ruby/3.0.0/gems/rack-2.2.4/lib/rack/common_logger.rb +0 -83
  38. data/vendor/bundle/ruby/3.0.0/gems/rack-2.2.4/lib/rack/conditional_get.rb +0 -83
  39. data/vendor/bundle/ruby/3.0.0/gems/rack-2.2.4/lib/rack/config.rb +0 -22
  40. data/vendor/bundle/ruby/3.0.0/gems/rack-2.2.4/lib/rack/content_length.rb +0 -38
  41. data/vendor/bundle/ruby/3.0.0/gems/rack-2.2.4/lib/rack/content_type.rb +0 -30
  42. data/vendor/bundle/ruby/3.0.0/gems/rack-2.2.4/lib/rack/core_ext/regexp.rb +0 -14
  43. data/vendor/bundle/ruby/3.0.0/gems/rack-2.2.4/lib/rack/deflater.rb +0 -144
  44. data/vendor/bundle/ruby/3.0.0/gems/rack-2.2.4/lib/rack/directory.rb +0 -199
  45. data/vendor/bundle/ruby/3.0.0/gems/rack-2.2.4/lib/rack/etag.rb +0 -77
  46. data/vendor/bundle/ruby/3.0.0/gems/rack-2.2.4/lib/rack/events.rb +0 -153
  47. data/vendor/bundle/ruby/3.0.0/gems/rack-2.2.4/lib/rack/file.rb +0 -7
  48. data/vendor/bundle/ruby/3.0.0/gems/rack-2.2.4/lib/rack/files.rb +0 -218
  49. data/vendor/bundle/ruby/3.0.0/gems/rack-2.2.4/lib/rack/handler/cgi.rb +0 -59
  50. data/vendor/bundle/ruby/3.0.0/gems/rack-2.2.4/lib/rack/handler/fastcgi.rb +0 -100
  51. data/vendor/bundle/ruby/3.0.0/gems/rack-2.2.4/lib/rack/handler/lsws.rb +0 -61
  52. data/vendor/bundle/ruby/3.0.0/gems/rack-2.2.4/lib/rack/handler/scgi.rb +0 -71
  53. data/vendor/bundle/ruby/3.0.0/gems/rack-2.2.4/lib/rack/handler/thin.rb +0 -36
  54. data/vendor/bundle/ruby/3.0.0/gems/rack-2.2.4/lib/rack/handler/webrick.rb +0 -129
  55. data/vendor/bundle/ruby/3.0.0/gems/rack-2.2.4/lib/rack/handler.rb +0 -104
  56. data/vendor/bundle/ruby/3.0.0/gems/rack-2.2.4/lib/rack/head.rb +0 -25
  57. data/vendor/bundle/ruby/3.0.0/gems/rack-2.2.4/lib/rack/lint.rb +0 -806
  58. data/vendor/bundle/ruby/3.0.0/gems/rack-2.2.4/lib/rack/lobster.rb +0 -70
  59. data/vendor/bundle/ruby/3.0.0/gems/rack-2.2.4/lib/rack/lock.rb +0 -32
  60. data/vendor/bundle/ruby/3.0.0/gems/rack-2.2.4/lib/rack/logger.rb +0 -20
  61. data/vendor/bundle/ruby/3.0.0/gems/rack-2.2.4/lib/rack/media_type.rb +0 -43
  62. data/vendor/bundle/ruby/3.0.0/gems/rack-2.2.4/lib/rack/method_override.rb +0 -52
  63. data/vendor/bundle/ruby/3.0.0/gems/rack-2.2.4/lib/rack/mime.rb +0 -685
  64. data/vendor/bundle/ruby/3.0.0/gems/rack-2.2.4/lib/rack/mock.rb +0 -273
  65. data/vendor/bundle/ruby/3.0.0/gems/rack-2.2.4/lib/rack/multipart/generator.rb +0 -97
  66. data/vendor/bundle/ruby/3.0.0/gems/rack-2.2.4/lib/rack/multipart/parser.rb +0 -365
  67. data/vendor/bundle/ruby/3.0.0/gems/rack-2.2.4/lib/rack/multipart/uploaded_file.rb +0 -41
  68. data/vendor/bundle/ruby/3.0.0/gems/rack-2.2.4/lib/rack/multipart.rb +0 -64
  69. data/vendor/bundle/ruby/3.0.0/gems/rack-2.2.4/lib/rack/null_logger.rb +0 -39
  70. data/vendor/bundle/ruby/3.0.0/gems/rack-2.2.4/lib/rack/query_parser.rb +0 -221
  71. data/vendor/bundle/ruby/3.0.0/gems/rack-2.2.4/lib/rack/recursive.rb +0 -64
  72. data/vendor/bundle/ruby/3.0.0/gems/rack-2.2.4/lib/rack/reloader.rb +0 -114
  73. data/vendor/bundle/ruby/3.0.0/gems/rack-2.2.4/lib/rack/request.rb +0 -659
  74. data/vendor/bundle/ruby/3.0.0/gems/rack-2.2.4/lib/rack/response.rb +0 -318
  75. data/vendor/bundle/ruby/3.0.0/gems/rack-2.2.4/lib/rack/rewindable_input.rb +0 -94
  76. data/vendor/bundle/ruby/3.0.0/gems/rack-2.2.4/lib/rack/runtime.rb +0 -34
  77. data/vendor/bundle/ruby/3.0.0/gems/rack-2.2.4/lib/rack/sendfile.rb +0 -162
  78. data/vendor/bundle/ruby/3.0.0/gems/rack-2.2.4/lib/rack/server.rb +0 -466
  79. data/vendor/bundle/ruby/3.0.0/gems/rack-2.2.4/lib/rack/session/abstract/id.rb +0 -523
  80. data/vendor/bundle/ruby/3.0.0/gems/rack-2.2.4/lib/rack/session/cookie.rb +0 -203
  81. data/vendor/bundle/ruby/3.0.0/gems/rack-2.2.4/lib/rack/session/memcache.rb +0 -10
  82. data/vendor/bundle/ruby/3.0.0/gems/rack-2.2.4/lib/rack/session/pool.rb +0 -85
  83. data/vendor/bundle/ruby/3.0.0/gems/rack-2.2.4/lib/rack/show_exceptions.rb +0 -390
  84. data/vendor/bundle/ruby/3.0.0/gems/rack-2.2.4/lib/rack/show_status.rb +0 -113
  85. data/vendor/bundle/ruby/3.0.0/gems/rack-2.2.4/lib/rack/static.rb +0 -187
  86. data/vendor/bundle/ruby/3.0.0/gems/rack-2.2.4/lib/rack/tempfile_reaper.rb +0 -22
  87. data/vendor/bundle/ruby/3.0.0/gems/rack-2.2.4/lib/rack/urlmap.rb +0 -97
  88. data/vendor/bundle/ruby/3.0.0/gems/rack-2.2.4/lib/rack/utils.rb +0 -616
  89. data/vendor/bundle/ruby/3.0.0/gems/rack-2.2.4/lib/rack/version.rb +0 -29
  90. data/vendor/bundle/ruby/3.0.0/gems/rack-2.2.4/lib/rack.rb +0 -141
  91. data/vendor/bundle/ruby/3.0.0/gems/rack-2.2.4/rack.gemspec +0 -46
  92. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.6/History.rdoc +0 -2403
  93. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.6/MIT-LICENSE +0 -21
  94. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.6/README.rdoc +0 -155
  95. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.6/doc/command_line_usage.rdoc +0 -158
  96. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.6/doc/example/Rakefile1 +0 -38
  97. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.6/doc/example/Rakefile2 +0 -35
  98. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.6/doc/example/a.c +0 -6
  99. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.6/doc/example/b.c +0 -6
  100. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.6/doc/example/main.c +0 -11
  101. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.6/doc/glossary.rdoc +0 -42
  102. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.6/doc/jamis.rb +0 -592
  103. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.6/doc/proto_rake.rdoc +0 -127
  104. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.6/doc/rake.1 +0 -156
  105. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.6/doc/rakefile.rdoc +0 -622
  106. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.6/doc/rational.rdoc +0 -151
  107. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.6/exe/rake +0 -27
  108. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.6/lib/rake/application.rb +0 -831
  109. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.6/lib/rake/backtrace.rb +0 -24
  110. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.6/lib/rake/clean.rb +0 -78
  111. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.6/lib/rake/cloneable.rb +0 -17
  112. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.6/lib/rake/cpu_counter.rb +0 -107
  113. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.6/lib/rake/default_loader.rb +0 -15
  114. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.6/lib/rake/dsl_definition.rb +0 -195
  115. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.6/lib/rake/early_time.rb +0 -22
  116. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.6/lib/rake/ext/core.rb +0 -26
  117. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.6/lib/rake/ext/string.rb +0 -176
  118. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.6/lib/rake/file_creation_task.rb +0 -25
  119. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.6/lib/rake/file_list.rb +0 -435
  120. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.6/lib/rake/file_task.rb +0 -54
  121. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.6/lib/rake/file_utils.rb +0 -134
  122. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.6/lib/rake/file_utils_ext.rb +0 -134
  123. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.6/lib/rake/invocation_chain.rb +0 -57
  124. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.6/lib/rake/invocation_exception_mixin.rb +0 -17
  125. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.6/lib/rake/late_time.rb +0 -18
  126. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.6/lib/rake/linked_list.rb +0 -112
  127. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.6/lib/rake/loaders/makefile.rb +0 -54
  128. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.6/lib/rake/multi_task.rb +0 -14
  129. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.6/lib/rake/name_space.rb +0 -38
  130. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.6/lib/rake/packagetask.rb +0 -222
  131. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.6/lib/rake/phony.rb +0 -16
  132. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.6/lib/rake/private_reader.rb +0 -21
  133. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.6/lib/rake/promise.rb +0 -100
  134. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.6/lib/rake/pseudo_status.rb +0 -30
  135. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.6/lib/rake/rake_module.rb +0 -67
  136. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.6/lib/rake/rake_test_loader.rb +0 -27
  137. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.6/lib/rake/rule_recursion_overflow_error.rb +0 -20
  138. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.6/lib/rake/scope.rb +0 -43
  139. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.6/lib/rake/task.rb +0 -434
  140. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.6/lib/rake/task_argument_error.rb +0 -8
  141. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.6/lib/rake/task_arguments.rb +0 -109
  142. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.6/lib/rake/task_manager.rb +0 -331
  143. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.6/lib/rake/tasklib.rb +0 -12
  144. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.6/lib/rake/testtask.rb +0 -189
  145. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.6/lib/rake/thread_history_display.rb +0 -49
  146. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.6/lib/rake/thread_pool.rb +0 -163
  147. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.6/lib/rake/trace_output.rb +0 -23
  148. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.6/lib/rake/version.rb +0 -10
  149. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.6/lib/rake/win32.rb +0 -51
  150. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.6/lib/rake.rb +0 -71
  151. data/vendor/bundle/ruby/3.0.0/gems/rake-13.0.6/rake.gemspec +0 -100
  152. data/vendor/bundle/ruby/3.0.0/specifications/rack-2.2.4.gemspec +0 -41
  153. data/vendor/bundle/ruby/3.0.0/specifications/rake-13.0.6.gemspec +0 -26
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'rack/session/dalli'
4
-
5
- module Rack
6
- module Session
7
- warn "Rack::Session::Memcache is deprecated, please use Rack::Session::Dalli from 'dalli' gem instead."
8
- Memcache = Dalli
9
- end
10
- end
@@ -1,85 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # AUTHOR: blink <blinketje@gmail.com>; blink#ruby-lang@irc.freenode.net
4
- # THANKS:
5
- # apeiros, for session id generation, expiry setup, and threadiness
6
- # sergio, threadiness and bugreps
7
-
8
- require_relative 'abstract/id'
9
- require 'thread'
10
-
11
- module Rack
12
- module Session
13
- # Rack::Session::Pool provides simple cookie based session management.
14
- # Session data is stored in a hash held by @pool.
15
- # In the context of a multithreaded environment, sessions being
16
- # committed to the pool is done in a merging manner.
17
- #
18
- # The :drop option is available in rack.session.options if you wish to
19
- # explicitly remove the session from the session cache.
20
- #
21
- # Example:
22
- # myapp = MyRackApp.new
23
- # sessioned = Rack::Session::Pool.new(myapp,
24
- # :domain => 'foo.com',
25
- # :expire_after => 2592000
26
- # )
27
- # Rack::Handler::WEBrick.run sessioned
28
-
29
- class Pool < Abstract::PersistedSecure
30
- attr_reader :mutex, :pool
31
- DEFAULT_OPTIONS = Abstract::ID::DEFAULT_OPTIONS.merge drop: false
32
-
33
- def initialize(app, options = {})
34
- super
35
- @pool = Hash.new
36
- @mutex = Mutex.new
37
- end
38
-
39
- def generate_sid
40
- loop do
41
- sid = super
42
- break sid unless @pool.key? sid.private_id
43
- end
44
- end
45
-
46
- def find_session(req, sid)
47
- with_lock(req) do
48
- unless sid and session = get_session_with_fallback(sid)
49
- sid, session = generate_sid, {}
50
- @pool.store sid.private_id, session
51
- end
52
- [sid, session]
53
- end
54
- end
55
-
56
- def write_session(req, session_id, new_session, options)
57
- with_lock(req) do
58
- @pool.store session_id.private_id, new_session
59
- session_id
60
- end
61
- end
62
-
63
- def delete_session(req, session_id, options)
64
- with_lock(req) do
65
- @pool.delete(session_id.public_id)
66
- @pool.delete(session_id.private_id)
67
- generate_sid unless options[:drop]
68
- end
69
- end
70
-
71
- def with_lock(req)
72
- @mutex.lock if req.multithread?
73
- yield
74
- ensure
75
- @mutex.unlock if @mutex.locked?
76
- end
77
-
78
- private
79
-
80
- def get_session_with_fallback(sid)
81
- @pool[sid.private_id] || @pool[sid.public_id]
82
- end
83
- end
84
- end
85
- end
@@ -1,390 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'ostruct'
4
- require 'erb'
5
-
6
- module Rack
7
- # Rack::ShowExceptions catches all exceptions raised from the app it
8
- # wraps. It shows a useful backtrace with the sourcefile and
9
- # clickable context, the whole Rack environment and the request
10
- # data.
11
- #
12
- # Be careful when you use this on public-facing sites as it could
13
- # reveal information helpful to attackers.
14
-
15
- class ShowExceptions
16
- CONTEXT = 7
17
-
18
- def initialize(app)
19
- @app = app
20
- end
21
-
22
- def call(env)
23
- @app.call(env)
24
- rescue StandardError, LoadError, SyntaxError => e
25
- exception_string = dump_exception(e)
26
-
27
- env[RACK_ERRORS].puts(exception_string)
28
- env[RACK_ERRORS].flush
29
-
30
- if accepts_html?(env)
31
- content_type = "text/html"
32
- body = pretty(env, e)
33
- else
34
- content_type = "text/plain"
35
- body = exception_string
36
- end
37
-
38
- [
39
- 500,
40
- {
41
- CONTENT_TYPE => content_type,
42
- CONTENT_LENGTH => body.bytesize.to_s,
43
- },
44
- [body],
45
- ]
46
- end
47
-
48
- def prefers_plaintext?(env)
49
- !accepts_html?(env)
50
- end
51
-
52
- def accepts_html?(env)
53
- Rack::Utils.best_q_match(env["HTTP_ACCEPT"], %w[text/html])
54
- end
55
- private :accepts_html?
56
-
57
- def dump_exception(exception)
58
- string = "#{exception.class}: #{exception.message}\n".dup
59
- string << exception.backtrace.map { |l| "\t#{l}" }.join("\n")
60
- string
61
- end
62
-
63
- def pretty(env, exception)
64
- req = Rack::Request.new(env)
65
-
66
- # This double assignment is to prevent an "unused variable" warning.
67
- # Yes, it is dumb, but I don't like Ruby yelling at me.
68
- path = path = (req.script_name + req.path_info).squeeze("/")
69
-
70
- # This double assignment is to prevent an "unused variable" warning.
71
- # Yes, it is dumb, but I don't like Ruby yelling at me.
72
- frames = frames = exception.backtrace.map { |line|
73
- frame = OpenStruct.new
74
- if line =~ /(.*?):(\d+)(:in `(.*)')?/
75
- frame.filename = $1
76
- frame.lineno = $2.to_i
77
- frame.function = $4
78
-
79
- begin
80
- lineno = frame.lineno - 1
81
- lines = ::File.readlines(frame.filename)
82
- frame.pre_context_lineno = [lineno - CONTEXT, 0].max
83
- frame.pre_context = lines[frame.pre_context_lineno...lineno]
84
- frame.context_line = lines[lineno].chomp
85
- frame.post_context_lineno = [lineno + CONTEXT, lines.size].min
86
- frame.post_context = lines[lineno + 1..frame.post_context_lineno]
87
- rescue
88
- end
89
-
90
- frame
91
- else
92
- nil
93
- end
94
- }.compact
95
-
96
- template.result(binding)
97
- end
98
-
99
- def template
100
- TEMPLATE
101
- end
102
-
103
- def h(obj) # :nodoc:
104
- case obj
105
- when String
106
- Utils.escape_html(obj)
107
- else
108
- Utils.escape_html(obj.inspect)
109
- end
110
- end
111
-
112
- # :stopdoc:
113
-
114
- # adapted from Django <www.djangoproject.com>
115
- # Copyright (c) Django Software Foundation and individual contributors.
116
- # Used under the modified BSD license:
117
- # http://www.xfree86.org/3.3.6/COPYRIGHT2.html#5
118
- TEMPLATE = ERB.new(<<-'HTML'.gsub(/^ /, ''))
119
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
120
- <html lang="en">
121
- <head>
122
- <meta http-equiv="content-type" content="text/html; charset=utf-8" />
123
- <meta name="robots" content="NONE,NOARCHIVE" />
124
- <title><%=h exception.class %> at <%=h path %></title>
125
- <style type="text/css">
126
- html * { padding:0; margin:0; }
127
- body * { padding:10px 20px; }
128
- body * * { padding:0; }
129
- body { font:small sans-serif; }
130
- body>div { border-bottom:1px solid #ddd; }
131
- h1 { font-weight:normal; }
132
- h2 { margin-bottom:.8em; }
133
- h2 span { font-size:80%; color:#666; font-weight:normal; }
134
- h3 { margin:1em 0 .5em 0; }
135
- h4 { margin:0 0 .5em 0; font-weight: normal; }
136
- table {
137
- border:1px solid #ccc; border-collapse: collapse; background:white; }
138
- tbody td, tbody th { vertical-align:top; padding:2px 3px; }
139
- thead th {
140
- padding:1px 6px 1px 3px; background:#fefefe; text-align:left;
141
- font-weight:normal; font-size:11px; border:1px solid #ddd; }
142
- tbody th { text-align:right; color:#666; padding-right:.5em; }
143
- table.vars { margin:5px 0 2px 40px; }
144
- table.vars td, table.req td { font-family:monospace; }
145
- table td.code { width:100%;}
146
- table td.code div { overflow:hidden; }
147
- table.source th { color:#666; }
148
- table.source td {
149
- font-family:monospace; white-space:pre; border-bottom:1px solid #eee; }
150
- ul.traceback { list-style-type:none; }
151
- ul.traceback li.frame { margin-bottom:1em; }
152
- div.context { margin: 10px 0; }
153
- div.context ol {
154
- padding-left:30px; margin:0 10px; list-style-position: inside; }
155
- div.context ol li {
156
- font-family:monospace; white-space:pre; color:#666; cursor:pointer; }
157
- div.context ol.context-line li { color:black; background-color:#ccc; }
158
- div.context ol.context-line li span { float: right; }
159
- div.commands { margin-left: 40px; }
160
- div.commands a { color:black; text-decoration:none; }
161
- #summary { background: #ffc; }
162
- #summary h2 { font-weight: normal; color: #666; }
163
- #summary ul#quicklinks { list-style-type: none; margin-bottom: 2em; }
164
- #summary ul#quicklinks li { float: left; padding: 0 1em; }
165
- #summary ul#quicklinks>li+li { border-left: 1px #666 solid; }
166
- #explanation { background:#eee; }
167
- #template, #template-not-exist { background:#f6f6f6; }
168
- #template-not-exist ul { margin: 0 0 0 20px; }
169
- #traceback { background:#eee; }
170
- #requestinfo { background:#f6f6f6; padding-left:120px; }
171
- #summary table { border:none; background:transparent; }
172
- #requestinfo h2, #requestinfo h3 { position:relative; margin-left:-100px; }
173
- #requestinfo h3 { margin-bottom:-1em; }
174
- .error { background: #ffc; }
175
- .specific { color:#cc3300; font-weight:bold; }
176
- </style>
177
- <script type="text/javascript">
178
- //<!--
179
- function getElementsByClassName(oElm, strTagName, strClassName){
180
- // Written by Jonathan Snook, http://www.snook.ca/jon;
181
- // Add-ons by Robert Nyman, http://www.robertnyman.com
182
- var arrElements = (strTagName == "*" && document.all)? document.all :
183
- oElm.getElementsByTagName(strTagName);
184
- var arrReturnElements = new Array();
185
- strClassName = strClassName.replace(/\-/g, "\\-");
186
- var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$$)");
187
- var oElement;
188
- for(var i=0; i<arrElements.length; i++){
189
- oElement = arrElements[i];
190
- if(oRegExp.test(oElement.className)){
191
- arrReturnElements.push(oElement);
192
- }
193
- }
194
- return (arrReturnElements)
195
- }
196
- function hideAll(elems) {
197
- for (var e = 0; e < elems.length; e++) {
198
- elems[e].style.display = 'none';
199
- }
200
- }
201
- window.onload = function() {
202
- hideAll(getElementsByClassName(document, 'table', 'vars'));
203
- hideAll(getElementsByClassName(document, 'ol', 'pre-context'));
204
- hideAll(getElementsByClassName(document, 'ol', 'post-context'));
205
- }
206
- function toggle() {
207
- for (var i = 0; i < arguments.length; i++) {
208
- var e = document.getElementById(arguments[i]);
209
- if (e) {
210
- e.style.display = e.style.display == 'none' ? 'block' : 'none';
211
- }
212
- }
213
- return false;
214
- }
215
- function varToggle(link, id) {
216
- toggle('v' + id);
217
- var s = link.getElementsByTagName('span')[0];
218
- var uarr = String.fromCharCode(0x25b6);
219
- var darr = String.fromCharCode(0x25bc);
220
- s.innerHTML = s.innerHTML == uarr ? darr : uarr;
221
- return false;
222
- }
223
- //-->
224
- </script>
225
- </head>
226
- <body>
227
-
228
- <div id="summary">
229
- <h1><%=h exception.class %> at <%=h path %></h1>
230
- <h2><%=h exception.message %></h2>
231
- <table><tr>
232
- <th>Ruby</th>
233
- <td>
234
- <% if first = frames.first %>
235
- <code><%=h first.filename %></code>: in <code><%=h first.function %></code>, line <%=h frames.first.lineno %>
236
- <% else %>
237
- unknown location
238
- <% end %>
239
- </td>
240
- </tr><tr>
241
- <th>Web</th>
242
- <td><code><%=h req.request_method %> <%=h(req.host + path)%></code></td>
243
- </tr></table>
244
-
245
- <h3>Jump to:</h3>
246
- <ul id="quicklinks">
247
- <li><a href="#get-info">GET</a></li>
248
- <li><a href="#post-info">POST</a></li>
249
- <li><a href="#cookie-info">Cookies</a></li>
250
- <li><a href="#env-info">ENV</a></li>
251
- </ul>
252
- </div>
253
-
254
- <div id="traceback">
255
- <h2>Traceback <span>(innermost first)</span></h2>
256
- <ul class="traceback">
257
- <% frames.each { |frame| %>
258
- <li class="frame">
259
- <code><%=h frame.filename %></code>: in <code><%=h frame.function %></code>
260
-
261
- <% if frame.context_line %>
262
- <div class="context" id="c<%=h frame.object_id %>">
263
- <% if frame.pre_context %>
264
- <ol start="<%=h frame.pre_context_lineno+1 %>" class="pre-context" id="pre<%=h frame.object_id %>">
265
- <% frame.pre_context.each { |line| %>
266
- <li onclick="toggle('pre<%=h frame.object_id %>', 'post<%=h frame.object_id %>')"><%=h line %></li>
267
- <% } %>
268
- </ol>
269
- <% end %>
270
-
271
- <ol start="<%=h frame.lineno %>" class="context-line">
272
- <li onclick="toggle('pre<%=h frame.object_id %>', 'post<%=h frame.object_id %>')"><%=h frame.context_line %><span>...</span></li></ol>
273
-
274
- <% if frame.post_context %>
275
- <ol start='<%=h frame.lineno+1 %>' class="post-context" id="post<%=h frame.object_id %>">
276
- <% frame.post_context.each { |line| %>
277
- <li onclick="toggle('pre<%=h frame.object_id %>', 'post<%=h frame.object_id %>')"><%=h line %></li>
278
- <% } %>
279
- </ol>
280
- <% end %>
281
- </div>
282
- <% end %>
283
- </li>
284
- <% } %>
285
- </ul>
286
- </div>
287
-
288
- <div id="requestinfo">
289
- <h2>Request information</h2>
290
-
291
- <h3 id="get-info">GET</h3>
292
- <% if req.GET and not req.GET.empty? %>
293
- <table class="req">
294
- <thead>
295
- <tr>
296
- <th>Variable</th>
297
- <th>Value</th>
298
- </tr>
299
- </thead>
300
- <tbody>
301
- <% req.GET.sort_by { |k, v| k.to_s }.each { |key, val| %>
302
- <tr>
303
- <td><%=h key %></td>
304
- <td class="code"><div><%=h val.inspect %></div></td>
305
- </tr>
306
- <% } %>
307
- </tbody>
308
- </table>
309
- <% else %>
310
- <p>No GET data.</p>
311
- <% end %>
312
-
313
- <h3 id="post-info">POST</h3>
314
- <% if ((req.POST and not req.POST.empty?) rescue (no_post_data = "Invalid POST data"; nil)) %>
315
- <table class="req">
316
- <thead>
317
- <tr>
318
- <th>Variable</th>
319
- <th>Value</th>
320
- </tr>
321
- </thead>
322
- <tbody>
323
- <% req.POST.sort_by { |k, v| k.to_s }.each { |key, val| %>
324
- <tr>
325
- <td><%=h key %></td>
326
- <td class="code"><div><%=h val.inspect %></div></td>
327
- </tr>
328
- <% } %>
329
- </tbody>
330
- </table>
331
- <% else %>
332
- <p><%= no_post_data || "No POST data" %>.</p>
333
- <% end %>
334
-
335
-
336
- <h3 id="cookie-info">COOKIES</h3>
337
- <% unless req.cookies.empty? %>
338
- <table class="req">
339
- <thead>
340
- <tr>
341
- <th>Variable</th>
342
- <th>Value</th>
343
- </tr>
344
- </thead>
345
- <tbody>
346
- <% req.cookies.each { |key, val| %>
347
- <tr>
348
- <td><%=h key %></td>
349
- <td class="code"><div><%=h val.inspect %></div></td>
350
- </tr>
351
- <% } %>
352
- </tbody>
353
- </table>
354
- <% else %>
355
- <p>No cookie data.</p>
356
- <% end %>
357
-
358
- <h3 id="env-info">Rack ENV</h3>
359
- <table class="req">
360
- <thead>
361
- <tr>
362
- <th>Variable</th>
363
- <th>Value</th>
364
- </tr>
365
- </thead>
366
- <tbody>
367
- <% env.sort_by { |k, v| k.to_s }.each { |key, val| %>
368
- <tr>
369
- <td><%=h key %></td>
370
- <td class="code"><div><%=h val.inspect %></div></td>
371
- </tr>
372
- <% } %>
373
- </tbody>
374
- </table>
375
-
376
- </div>
377
-
378
- <div id="explanation">
379
- <p>
380
- You're seeing this error because you use <code>Rack::ShowExceptions</code>.
381
- </p>
382
- </div>
383
-
384
- </body>
385
- </html>
386
- HTML
387
-
388
- # :startdoc:
389
- end
390
- end
@@ -1,113 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'erb'
4
-
5
- module Rack
6
- # Rack::ShowStatus catches all empty responses and replaces them
7
- # with a site explaining the error.
8
- #
9
- # Additional details can be put into <tt>rack.showstatus.detail</tt>
10
- # and will be shown as HTML. If such details exist, the error page
11
- # is always rendered, even if the reply was not empty.
12
-
13
- class ShowStatus
14
- def initialize(app)
15
- @app = app
16
- @template = ERB.new(TEMPLATE)
17
- end
18
-
19
- def call(env)
20
- status, headers, body = @app.call(env)
21
- headers = Utils::HeaderHash[headers]
22
- empty = headers[CONTENT_LENGTH].to_i <= 0
23
-
24
- # client or server error, or explicit message
25
- if (status.to_i >= 400 && empty) || env[RACK_SHOWSTATUS_DETAIL]
26
- # This double assignment is to prevent an "unused variable" warning.
27
- # Yes, it is dumb, but I don't like Ruby yelling at me.
28
- req = req = Rack::Request.new(env)
29
-
30
- message = Rack::Utils::HTTP_STATUS_CODES[status.to_i] || status.to_s
31
-
32
- # This double assignment is to prevent an "unused variable" warning.
33
- # Yes, it is dumb, but I don't like Ruby yelling at me.
34
- detail = detail = env[RACK_SHOWSTATUS_DETAIL] || message
35
-
36
- body = @template.result(binding)
37
- size = body.bytesize
38
- [status, headers.merge(CONTENT_TYPE => "text/html", CONTENT_LENGTH => size.to_s), [body]]
39
- else
40
- [status, headers, body]
41
- end
42
- end
43
-
44
- def h(obj) # :nodoc:
45
- case obj
46
- when String
47
- Utils.escape_html(obj)
48
- else
49
- Utils.escape_html(obj.inspect)
50
- end
51
- end
52
-
53
- # :stopdoc:
54
-
55
- # adapted from Django <www.djangoproject.com>
56
- # Copyright (c) Django Software Foundation and individual contributors.
57
- # Used under the modified BSD license:
58
- # http://www.xfree86.org/3.3.6/COPYRIGHT2.html#5
59
- TEMPLATE = <<'HTML'
60
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
61
- <html lang="en">
62
- <head>
63
- <meta http-equiv="content-type" content="text/html; charset=utf-8" />
64
- <title><%=h message %> at <%=h req.script_name + req.path_info %></title>
65
- <meta name="robots" content="NONE,NOARCHIVE" />
66
- <style type="text/css">
67
- html * { padding:0; margin:0; }
68
- body * { padding:10px 20px; }
69
- body * * { padding:0; }
70
- body { font:small sans-serif; background:#eee; }
71
- body>div { border-bottom:1px solid #ddd; }
72
- h1 { font-weight:normal; margin-bottom:.4em; }
73
- h1 span { font-size:60%; color:#666; font-weight:normal; }
74
- table { border:none; border-collapse: collapse; width:100%; }
75
- td, th { vertical-align:top; padding:2px 3px; }
76
- th { width:12em; text-align:right; color:#666; padding-right:.5em; }
77
- #info { background:#f6f6f6; }
78
- #info ol { margin: 0.5em 4em; }
79
- #info ol li { font-family: monospace; }
80
- #summary { background: #ffc; }
81
- #explanation { background:#eee; border-bottom: 0px none; }
82
- </style>
83
- </head>
84
- <body>
85
- <div id="summary">
86
- <h1><%=h message %> <span>(<%= status.to_i %>)</span></h1>
87
- <table class="meta">
88
- <tr>
89
- <th>Request Method:</th>
90
- <td><%=h req.request_method %></td>
91
- </tr>
92
- <tr>
93
- <th>Request URL:</th>
94
- <td><%=h req.url %></td>
95
- </tr>
96
- </table>
97
- </div>
98
- <div id="info">
99
- <p><%=h detail %></p>
100
- </div>
101
-
102
- <div id="explanation">
103
- <p>
104
- You're seeing this error because you use <code>Rack::ShowStatus</code>.
105
- </p>
106
- </div>
107
- </body>
108
- </html>
109
- HTML
110
-
111
- # :startdoc:
112
- end
113
- end