sinarey_support 0.0.1 → 0.0.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4b1bb6ef862c14de85d7d67558e4ce1ee5432b76
4
- data.tar.gz: f7cdef605e27116e65f5f87ddaec404758827afc
3
+ metadata.gz: a486c06e5234203bd2d4ce530e9832805a361a2c
4
+ data.tar.gz: 028bb2d4393f58e5031e5482705c173211d209fe
5
5
  SHA512:
6
- metadata.gz: 2bc65ae4d59af13eb5c7e5351ee3ea8baf629cf0fc0b473d472fc85a1a064fa765cf6570ed472de5501b568496131a6092d330850822cbfc44ab5b8ffdbbf7d4
7
- data.tar.gz: 2ec5590ffcda475af839908addb45fbc57d9a7c69ded6a14b7c6495115d4b1707243f8f87cd2f8ffeb722b95977998d57e5025dee23fb5fd8c18cca60db410b6
6
+ metadata.gz: 16986922046ac51e4d22e3870e02f5ceecbf08158122e0b5ed30e1ca2df42b70f0431c51303a417845279cfedc43f12e5d5461aa971723d6ded944c6e7367044
7
+ data.tar.gz: bf054611eca57f512761718a4d7bbc6ea76100816e3d916ff64d98f77c5164b9955e3bf32d39f4f187d9a4fe09d6a29f64c77f88653cb88b5b423fc1339e9027
@@ -0,0 +1,6 @@
1
+ module Kernel
2
+ # class_eval on an object acts like singleton_class.class_eval.
3
+ def class_eval(*args, &block)
4
+ singleton_class.class_eval(*args, &block)
5
+ end
6
+ end
@@ -0,0 +1 @@
1
+ require 'sinarey_support/core_ext/kernel/singleton_class'
@@ -0,0 +1,198 @@
1
+ require 'erb'
2
+ require 'sinarey_support/core_ext/kernel/singleton_class'
3
+
4
+ class ERB
5
+ module Util
6
+ HTML_ESCAPE = { '&' => '&amp;', '>' => '&gt;', '<' => '&lt;', '"' => '&quot;', "'" => '&#39;' }
7
+ JSON_ESCAPE = { '&' => '\u0026', '>' => '\u003E', '<' => '\u003C' }
8
+ HTML_ESCAPE_ONCE_REGEXP = /["><']|&(?!([a-zA-Z]+|(#\d+));)/
9
+ JSON_ESCAPE_REGEXP = /[&"><]/
10
+
11
+ # A utility method for escaping HTML without affecting existing escaped entities.
12
+ #
13
+ # html_escape_once('1 < 2 &amp; 3')
14
+ # # => "1 &lt; 2 &amp; 3"
15
+ #
16
+ # html_escape_once('&lt;&lt; Accept & Checkout')
17
+ # # => "&lt;&lt; Accept &amp; Checkout"
18
+ def html_escape_once(s)
19
+ result = s.to_s.gsub(HTML_ESCAPE_ONCE_REGEXP, HTML_ESCAPE)
20
+ s.html_safe? ? result.html_safe : result
21
+ end
22
+
23
+ module_function :html_escape_once
24
+
25
+ # A utility method for escaping HTML entities in JSON strings
26
+ # using \uXXXX JavaScript escape sequences for string literals:
27
+ #
28
+ # json_escape('is a > 0 & a < 10?')
29
+ # # => is a \u003E 0 \u0026 a \u003C 10?
30
+ #
31
+ # Note that after this operation is performed the output is not
32
+ # valid JSON. In particular double quotes are removed:
33
+ #
34
+ # json_escape('{"name":"john","created_at":"2010-04-28T01:39:31Z","id":1}')
35
+ # # => {name:john,created_at:2010-04-28T01:39:31Z,id:1}
36
+ def json_escape(s)
37
+ result = s.to_s.gsub(JSON_ESCAPE_REGEXP, JSON_ESCAPE)
38
+ s.html_safe? ? result.html_safe : result
39
+ end
40
+
41
+ module_function :json_escape
42
+
43
+
44
+ def sinarey_escape(value)
45
+ if value.html_safe?
46
+ value.to_s
47
+ else
48
+ value.to_s.gsub(/[&"'><]/, HTML_ESCAPE)
49
+ end
50
+ end
51
+
52
+ module_function :sinarey_escape
53
+
54
+ end
55
+ end
56
+
57
+ class Object
58
+ def html_safe?
59
+ false
60
+ end
61
+ end
62
+
63
+ class Numeric
64
+ def html_safe?
65
+ true
66
+ end
67
+ end
68
+
69
+ class TrueClass
70
+ def html_safe?
71
+ true
72
+ end
73
+ end
74
+
75
+ class FalseClass
76
+ def html_safe?
77
+ true
78
+ end
79
+ end
80
+
81
+ class NilClass
82
+ def html_safe?
83
+ true
84
+ end
85
+ end
86
+
87
+ module ActiveSupport #:nodoc:
88
+ class SafeBuffer < String
89
+ UNSAFE_STRING_METHODS = %w(
90
+ capitalize chomp chop delete downcase gsub lstrip next reverse rstrip
91
+ slice squeeze strip sub succ swapcase tr tr_s upcase prepend
92
+ )
93
+
94
+ alias_method :original_concat, :concat
95
+ private :original_concat
96
+
97
+ class SafeConcatError < StandardError
98
+ def initialize
99
+ super 'Could not concatenate to the buffer because it is not html safe.'
100
+ end
101
+ end
102
+
103
+ def [](*args)
104
+ if args.size < 2
105
+ super
106
+ else
107
+ if html_safe?
108
+ new_safe_buffer = super
109
+ new_safe_buffer.instance_eval { @html_safe = true }
110
+ new_safe_buffer
111
+ else
112
+ to_str[*args]
113
+ end
114
+ end
115
+ end
116
+
117
+ def safe_concat(value)
118
+ raise SafeConcatError unless html_safe?
119
+ original_concat(value)
120
+ end
121
+
122
+ def initialize(*)
123
+ @html_safe = true
124
+ super
125
+ end
126
+
127
+ def initialize_copy(other)
128
+ super
129
+ @html_safe = other.html_safe?
130
+ end
131
+
132
+ def clone_empty
133
+ self[0, 0]
134
+ end
135
+
136
+ def concat(value)
137
+ if !html_safe? || value.html_safe?
138
+ super(value)
139
+ else
140
+ super(ERB::Util.h(value))
141
+ end
142
+ end
143
+ alias << concat
144
+
145
+ def +(other)
146
+ dup.concat(other)
147
+ end
148
+
149
+ def %(args)
150
+ args = Array(args).map do |arg|
151
+ if !html_safe? || arg.html_safe?
152
+ arg
153
+ else
154
+ ERB::Util.h(arg)
155
+ end
156
+ end
157
+
158
+ self.class.new(super(args))
159
+ end
160
+
161
+ def html_safe?
162
+ defined?(@html_safe) && @html_safe
163
+ end
164
+
165
+ def to_s
166
+ self
167
+ end
168
+
169
+ def to_param
170
+ to_str
171
+ end
172
+
173
+ def encode_with(coder)
174
+ coder.represent_scalar nil, to_str
175
+ end
176
+
177
+ UNSAFE_STRING_METHODS.each do |unsafe_method|
178
+ if 'String'.respond_to?(unsafe_method)
179
+ class_eval <<-EOT, __FILE__, __LINE__ + 1
180
+ def #{unsafe_method}(*args, &block) # def capitalize(*args, &block)
181
+ to_str.#{unsafe_method}(*args, &block) # to_str.capitalize(*args, &block)
182
+ end # end
183
+
184
+ def #{unsafe_method}!(*args) # def capitalize!(*args)
185
+ @html_safe = false # @html_safe = false
186
+ super # super
187
+ end # end
188
+ EOT
189
+ end
190
+ end
191
+ end
192
+ end
193
+
194
+ class String
195
+ def html_safe
196
+ ActiveSupport::SafeBuffer.new(self)
197
+ end
198
+ end
@@ -0,0 +1,196 @@
1
+ require 'erb'
2
+ require 'sinarey_support/core_ext/string/output_safety'
3
+
4
+ class ERB
5
+ class Compiler
6
+ def compile(s)
7
+ enc = s.encoding
8
+ raise ArgumentError, "#{enc} is not ASCII compatible" if enc.dummy?
9
+ s = s.dup.force_encoding("ASCII-8BIT") # don't use constant Enoding::ASCII_8BIT for miniruby
10
+ enc = detect_magic_comment(s) || enc
11
+ out = Buffer.new(self, enc)
12
+ content = ''
13
+ scanner = make_scanner(s)
14
+ scanner.scan do |token|
15
+ next if token.nil?
16
+ next if token == ''
17
+ if scanner.stag.nil?
18
+ case token
19
+ when PercentLine
20
+ add_put_cmd(out, content) if content.size > 0
21
+ content = ''
22
+ out.push(token.to_s)
23
+ out.cr
24
+ when :cr
25
+ out.cr
26
+ when '<%', '<%==', '<%=', '<%#'
27
+ scanner.stag = token
28
+ add_put_cmd(out, content) if content.size > 0
29
+ content = ''
30
+ when "\n"
31
+ content << "\n"
32
+ add_put_cmd(out, content)
33
+ content = ''
34
+ when '<%%'
35
+ content << '<%'
36
+ else
37
+ content << token
38
+ end
39
+ else
40
+ case token
41
+ when '%>'
42
+ case scanner.stag
43
+ when '<%'
44
+ if content[-1] == ?\n
45
+ content.chop!
46
+ out.push(content)
47
+ out.cr
48
+ else
49
+ out.push(content)
50
+ end
51
+ when '<%=='
52
+ add_insert_cmd(out, content)
53
+ when '<%='
54
+ add_insert_escapehtml_cmd(out, content)
55
+ when '<%#'
56
+ # out.push("# #{content_dump(content)}")
57
+ end
58
+ scanner.stag = nil
59
+ content = ''
60
+ when '%%>'
61
+ content << '%>'
62
+ else
63
+ content << token
64
+ end
65
+ end
66
+ end
67
+ add_put_cmd(out, content) if content.size > 0
68
+ out.close
69
+ return out.script, enc
70
+ end
71
+
72
+ def add_insert_cmd(out, content)
73
+ out.push("#{@insert_cmd}((#{content}).to_s)")
74
+ end
75
+
76
+ def add_insert_escapehtml_cmd(out, content)
77
+ out.push("#{@insert_cmd}(ERB::Util.sinarey_escape((#{content})))")
78
+ end
79
+
80
+ class TrimScanner < Scanner
81
+ def scan_line(line)
82
+ line.scan(/(.*?)(<%%|%%>|<%==|<%=|<%#|<%|%>|\n|\z)/m) do |tokens|
83
+ tokens.each do |token|
84
+ next if token.empty?
85
+ yield(token)
86
+ end
87
+ end
88
+ end
89
+ def trim_line1(line)
90
+ line.scan(/(.*?)(<%%|%%>|<%==|<%=|<%#|<%|%>\n|%>|\n|\z)/m) do |tokens|
91
+ tokens.each do |token|
92
+ next if token.empty?
93
+ if token == "%>\n"
94
+ yield('%>')
95
+ yield(:cr)
96
+ else
97
+ yield(token)
98
+ end
99
+ end
100
+ end
101
+ end
102
+ def trim_line2(line)
103
+ head = nil
104
+ line.scan(/(.*?)(<%%|%%>|<%==|<%=|<%#|<%|%>\n|%>|\n|\z)/m) do |tokens|
105
+ tokens.each do |token|
106
+ next if token.empty?
107
+ head = token unless head
108
+ if token == "%>\n"
109
+ yield('%>')
110
+ if is_erb_stag?(head)
111
+ yield(:cr)
112
+ else
113
+ yield("\n")
114
+ end
115
+ head = nil
116
+ else
117
+ yield(token)
118
+ head = nil if token == "\n"
119
+ end
120
+ end
121
+ end
122
+ end
123
+ def explicit_trim_line(line)
124
+ line.scan(/(.*?)(^[ \t]*<%\-|<%\-|<%%|%%>|<%==|<%=|<%#|<%|-%>\n|-%>|%>|\z)/m) do |tokens|
125
+ tokens.each do |token|
126
+ next if token.empty?
127
+ if @stag.nil? && /[ \t]*<%-/ =~ token
128
+ yield('<%')
129
+ elsif @stag && token == "-%>\n"
130
+ yield('%>')
131
+ yield(:cr)
132
+ elsif @stag && token == '-%>'
133
+ yield('%>')
134
+ else
135
+ yield(token)
136
+ end
137
+ end
138
+ end
139
+ end
140
+ ERB_STAG << '<%=='
141
+ def is_erb_stag?(s)
142
+ ERB_STAG.member?(s)
143
+ end
144
+ end
145
+ Scanner.default_scanner = TrimScanner
146
+ class SimpleScanner < Scanner # :nodoc:
147
+ def scan
148
+ @src.scan(/(.*?)(<%%|%%>|<%==|<%=|<%#|<%|%>|\n|\z)/m) do |tokens|
149
+ tokens.each do |token|
150
+ next if token.empty?
151
+ yield(token)
152
+ end
153
+ end
154
+ end
155
+ end
156
+ Scanner.regist_scanner(SimpleScanner, nil, false)
157
+ begin
158
+ require 'strscan'
159
+ class SimpleScanner2 < Scanner # :nodoc:
160
+ def scan
161
+ stag_reg = /(.*?)(<%%|<%==|<%=|<%#|<%|\z)/m
162
+ etag_reg = /(.*?)(%%>|%>|\z)/m
163
+ scanner = StringScanner.new(@src)
164
+ while ! scanner.eos?
165
+ scanner.scan(@stag ? etag_reg : stag_reg)
166
+ yield(scanner[1])
167
+ yield(scanner[2])
168
+ end
169
+ end
170
+ end
171
+ Scanner.regist_scanner(SimpleScanner2, nil, false)
172
+ class ExplicitScanner < Scanner # :nodoc:
173
+ def scan
174
+ stag_reg = /(.*?)(^[ \t]*<%-|<%%|<%==|<%=|<%#|<%-|<%|\z)/m
175
+ etag_reg = /(.*?)(%%>|-%>|%>|\z)/m
176
+ scanner = StringScanner.new(@src)
177
+ while ! scanner.eos?
178
+ scanner.scan(@stag ? etag_reg : stag_reg)
179
+ yield(scanner[1])
180
+ elem = scanner[2]
181
+ if /[ \t]*<%-/ =~ elem
182
+ yield('<%')
183
+ elsif elem == '-%>'
184
+ yield('%>')
185
+ yield(:cr) if scanner.scan(/(\n|\z)/)
186
+ else
187
+ yield(elem)
188
+ end
189
+ end
190
+ end
191
+ end
192
+ Scanner.regist_scanner(ExplicitScanner, '-', false)
193
+ rescue LoadError
194
+ end
195
+ end
196
+ end
@@ -0,0 +1,295 @@
1
+
2
+ #modify sinatra original exception template,fixed to erb_safe_ext.
3
+
4
+ module Sinatra
5
+
6
+ class ShowExceptions < Rack::ShowExceptions
7
+
8
+ defined?(TEMPLATE) and remove_const(:TEMPLATE)
9
+
10
+ TEMPLATE = <<-HTML # :nodoc:
11
+ <!DOCTYPE html>
12
+ <html>
13
+ <head>
14
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
15
+ <title><%= exception.class %> at <%= path %></title>
16
+
17
+ <script type="text/javascript">
18
+ //<!--
19
+ function toggle(id) {
20
+ var pre = document.getElementById("pre-" + id);
21
+ var post = document.getElementById("post-" + id);
22
+ var context = document.getElementById("context-" + id);
23
+
24
+ if (pre.style.display == 'block') {
25
+ pre.style.display = 'none';
26
+ post.style.display = 'none';
27
+ context.style.background = "none";
28
+ } else {
29
+ pre.style.display = 'block';
30
+ post.style.display = 'block';
31
+ context.style.background = "#fffed9";
32
+ }
33
+ }
34
+
35
+ function toggleBacktrace(){
36
+ var bt = document.getElementById("backtrace");
37
+ var toggler = document.getElementById("expando");
38
+
39
+ if (bt.className == 'condensed') {
40
+ bt.className = 'expanded';
41
+ toggler.innerHTML = "(condense)";
42
+ } else {
43
+ bt.className = 'condensed';
44
+ toggler.innerHTML = "(expand)";
45
+ }
46
+ }
47
+ //-->
48
+ </script>
49
+
50
+ <style type="text/css" media="screen">
51
+ * {margin: 0; padding: 0; border: 0; outline: 0;}
52
+ div.clear {clear: both;}
53
+ body {background: #EEEEEE; margin: 0; padding: 0;
54
+ font-family: 'Lucida Grande', 'Lucida Sans Unicode',
55
+ 'Garuda';}
56
+ code {font-family: 'Lucida Console', monospace;
57
+ font-size: 12px;}
58
+ li {height: 18px;}
59
+ ul {list-style: none; margin: 0; padding: 0;}
60
+ ol:hover {cursor: pointer;}
61
+ ol li {white-space: pre;}
62
+ #explanation {font-size: 12px; color: #666666;
63
+ margin: 20px 0 0 100px;}
64
+ /* WRAP */
65
+ #wrap {width: 1000px; background: #FFFFFF; margin: 0 auto;
66
+ padding: 30px 50px 20px 50px;
67
+ border-left: 1px solid #DDDDDD;
68
+ border-right: 1px solid #DDDDDD;}
69
+ /* HEADER */
70
+ #header {margin: 0 auto 25px auto;}
71
+ #header img {float: left;}
72
+ #header #summary {float: left; margin: 12px 0 0 20px; width:660px;
73
+ font-family: 'Lucida Grande', 'Lucida Sans Unicode';}
74
+ h1 {margin: 0; font-size: 36px; color: #981919;}
75
+ h2 {margin: 0; font-size: 22px; color: #333333;}
76
+ #header ul {margin: 0; font-size: 12px; color: #666666;}
77
+ #header ul li strong{color: #444444;}
78
+ #header ul li {display: inline; padding: 0 10px;}
79
+ #header ul li.first {padding-left: 0;}
80
+ #header ul li.last {border: 0; padding-right: 0;}
81
+ /* BODY */
82
+ #backtrace,
83
+ #get,
84
+ #post,
85
+ #cookies,
86
+ #rack {width: 980px; margin: 0 auto 10px auto;}
87
+ p#nav {float: right; font-size: 14px;}
88
+ /* BACKTRACE */
89
+ a#expando {float: left; padding-left: 5px; color: #666666;
90
+ font-size: 14px; text-decoration: none; cursor: pointer;}
91
+ a#expando:hover {text-decoration: underline;}
92
+ h3 {float: left; width: 100px; margin-bottom: 10px;
93
+ color: #981919; font-size: 14px; font-weight: bold;}
94
+ #nav a {color: #666666; text-decoration: none; padding: 0 5px;}
95
+ #backtrace li.frame-info {background: #f7f7f7; padding-left: 10px;
96
+ font-size: 12px; color: #333333;}
97
+ #backtrace ul {list-style-position: outside; border: 1px solid #E9E9E9;
98
+ border-bottom: 0;}
99
+ #backtrace ol {width: 920px; margin-left: 50px;
100
+ font: 10px 'Lucida Console', monospace; color: #666666;}
101
+ #backtrace ol li {border: 0; border-left: 1px solid #E9E9E9;
102
+ padding: 2px 0;}
103
+ #backtrace ol code {font-size: 10px; color: #555555; padding-left: 5px;}
104
+ #backtrace-ul li {border-bottom: 1px solid #E9E9E9; height: auto;
105
+ padding: 3px 0;}
106
+ #backtrace-ul .code {padding: 6px 0 4px 0;}
107
+ #backtrace.condensed .system,
108
+ #backtrace.condensed .framework {display:none;}
109
+ /* REQUEST DATA */
110
+ p.no-data {padding-top: 2px; font-size: 12px; color: #666666;}
111
+ table.req {width: 980px; text-align: left; font-size: 12px;
112
+ color: #666666; padding: 0; border-spacing: 0;
113
+ border: 1px solid #EEEEEE; border-bottom: 0;
114
+ border-left: 0;
115
+ clear:both}
116
+ table.req tr th {padding: 2px 10px; font-weight: bold;
117
+ background: #F7F7F7; border-bottom: 1px solid #EEEEEE;
118
+ border-left: 1px solid #EEEEEE;}
119
+ table.req tr td {padding: 2px 20px 2px 10px;
120
+ border-bottom: 1px solid #EEEEEE;
121
+ border-left: 1px solid #EEEEEE;}
122
+ /* HIDE PRE/POST CODE AT START */
123
+ .pre-context,
124
+ .post-context {display: none;}
125
+
126
+ table td.code {width:750px}
127
+ table td.code div {width:750px;overflow:hidden}
128
+ </style>
129
+ </head>
130
+ <body>
131
+ <div id="wrap">
132
+ <div id="header">
133
+ <img src="<%== env['SCRIPT_NAME'] %>/__sinatra__/500.png" alt="application error" height="161" width="313" />
134
+ <div id="summary">
135
+ <h1><strong><%= exception.class %></strong> at <strong><%= path %>
136
+ </strong></h1>
137
+ <h2><%= exception.message %></h2>
138
+ <ul>
139
+ <li class="first"><strong>file:</strong> <code>
140
+ <%= frames.first.filename.split("/").last %></code></li>
141
+ <li><strong>location:</strong> <code><%= frames.first.function %>
142
+ </code></li>
143
+ <li class="last"><strong>line:
144
+ </strong> <%= frames.first.lineno %></li>
145
+ </ul>
146
+ </div>
147
+ <div class="clear"></div>
148
+ </div>
149
+
150
+ <div id="backtrace" class='condensed'>
151
+ <h3>BACKTRACE</h3>
152
+ <p><a href="#" id="expando"
153
+ onclick="toggleBacktrace(); return false">(expand)</a></p>
154
+ <p id="nav"><strong>JUMP TO:</strong>
155
+ <a href="#get-info">GET</a>
156
+ <a href="#post-info">POST</a>
157
+ <a href="#cookie-info">COOKIES</a>
158
+ <a href="#env-info">ENV</a>
159
+ </p>
160
+ <div class="clear"></div>
161
+
162
+ <ul id="backtrace-ul">
163
+
164
+ <% id = 1 %>
165
+ <% frames.each do |frame| %>
166
+ <% if frame.context_line && frame.context_line != "#" %>
167
+
168
+ <li class="frame-info <%== frame_class(frame) %>">
169
+ <code><%= frame.filename %></code> in
170
+ <code><strong><%= frame.function %></strong></code>
171
+ </li>
172
+
173
+ <li class="code <%== frame_class(frame) %>">
174
+ <% if frame.pre_context %>
175
+ <ol start="<%= frame.pre_context_lineno + 1 %>"
176
+ class="pre-context" id="pre-<%== id %>"
177
+ onclick="toggle(<%== id %>);">
178
+ <% frame.pre_context.each do |line| %>
179
+ <li class="pre-context-line"><code><%= line %></code></li>
180
+ <% end %>
181
+ </ol>
182
+ <% end %>
183
+
184
+ <ol start="<%== frame.lineno %>" class="context" id="<%== id %>"
185
+ onclick="toggle(<%== id %>);">
186
+ <li class="context-line" id="context-<%== id %>"><code><%= frame.context_line %></code></li>
187
+ </ol>
188
+
189
+ <% if frame.post_context %>
190
+ <ol start="<%= frame.lineno + 1 %>" class="post-context"
191
+ id="post-<%== id %>" onclick="toggle(<%== id %>);">
192
+ <% frame.post_context.each do |line| %>
193
+ <li class="post-context-line"><code><%= line %></code></li>
194
+ <% end %>
195
+ </ol>
196
+ <% end %>
197
+ <div class="clear"></div>
198
+ </li>
199
+
200
+ <% end %>
201
+
202
+ <% id += 1 %>
203
+ <% end %>
204
+
205
+ </ul>
206
+ </div> <!-- /BACKTRACE -->
207
+
208
+ <div id="get">
209
+ <h3 id="get-info">GET</h3>
210
+ <% if req.GET and not req.GET.empty? %>
211
+ <table class="req">
212
+ <tr>
213
+ <th>Variable</th>
214
+ <th>Value</th>
215
+ </tr>
216
+ <% req.GET.sort_by { |k, v| k.to_s }.each { |key, val| %>
217
+ <tr>
218
+ <td><%= key %></td>
219
+ <td class="code"><div><%= val.inspect %></div></td>
220
+ </tr>
221
+ <% } %>
222
+ </table>
223
+ <% else %>
224
+ <p class="no-data">No GET data.</p>
225
+ <% end %>
226
+ <div class="clear"></div>
227
+ </div> <!-- /GET -->
228
+
229
+ <div id="post">
230
+ <h3 id="post-info">POST</h3>
231
+ <% if req.POST and not req.POST.empty? %>
232
+ <table class="req">
233
+ <tr>
234
+ <th>Variable</th>
235
+ <th>Value</th>
236
+ </tr>
237
+ <% req.POST.sort_by { |k, v| k.to_s }.each { |key, val| %>
238
+ <tr>
239
+ <td><%= key %></td>
240
+ <td class="code"><div><%= val.inspect %></div></td>
241
+ </tr>
242
+ <% } %>
243
+ </table>
244
+ <% else %>
245
+ <p class="no-data">No POST data.</p>
246
+ <% end %>
247
+ <div class="clear"></div>
248
+ </div> <!-- /POST -->
249
+
250
+ <div id="cookies">
251
+ <h3 id="cookie-info">COOKIES</h3>
252
+ <% unless req.cookies.empty? %>
253
+ <table class="req">
254
+ <tr>
255
+ <th>Variable</th>
256
+ <th>Value</th>
257
+ </tr>
258
+ <% req.cookies.each { |key, val| %>
259
+ <tr>
260
+ <td><%= key %></td>
261
+ <td class="code"><div><%= val.inspect %></div></td>
262
+ </tr>
263
+ <% } %>
264
+ </table>
265
+ <% else %>
266
+ <p class="no-data">No cookie data.</p>
267
+ <% end %>
268
+ <div class="clear"></div>
269
+ </div> <!-- /COOKIES -->
270
+
271
+ <div id="rack">
272
+ <h3 id="env-info">Rack ENV</h3>
273
+ <table class="req">
274
+ <tr>
275
+ <th>Variable</th>
276
+ <th>Value</th>
277
+ </tr>
278
+ <% env.sort_by { |k, v| k.to_s }.each { |key, val| %>
279
+ <tr>
280
+ <td><%= key %></td>
281
+ <td class="code"><div><%= val %></div></td>
282
+ </tr>
283
+ <% } %>
284
+ </table>
285
+ <div class="clear"></div>
286
+ </div> <!-- /RACK ENV -->
287
+
288
+ <p id="explanation">You're seeing this error because you have
289
+ enabled the <code>show_exceptions</code> setting.</p>
290
+ </div> <!-- /WRAP -->
291
+ </body>
292
+ </html>
293
+ HTML
294
+ end
295
+ end
@@ -0,0 +1,2 @@
1
+ require 'sinarey_support/erb/html_safe'
2
+ require 'sinarey_support/sinatra/exception_template'
@@ -1,3 +1,4 @@
1
+ require 'sinarey_support/core_ext/kernel'
1
2
  require 'sinarey_support/core_ext/string'
2
3
  require 'sinarey_support/core_ext/array'
3
4
  require 'sinarey_support/core_ext/hash'
@@ -0,0 +1,49 @@
1
+ # coding: utf-8
2
+ Gem::Specification.new do |spec|
3
+ spec.name = "sinarey_support"
4
+ spec.version = "0.0.2"
5
+ spec.authors = ["Jeffrey"]
6
+ spec.email = ["jeffrey6052@163.com"]
7
+ spec.description = "some useful methods for sinatra framework"
8
+ spec.summary = ""
9
+ spec.homepage = ""
10
+ spec.license = "MIT"
11
+
12
+ spec.files = [
13
+ 'lib/sinarey_support/core_ext/kernel/singleton_class.rb',
14
+ 'lib/sinarey_support/core_ext/string/access.rb',
15
+ 'lib/sinarey_support/core_ext/string/behavior.rb',
16
+ 'lib/sinarey_support/core_ext/string/exclude.rb',
17
+ 'lib/sinarey_support/core_ext/string/filters.rb',
18
+ 'lib/sinarey_support/core_ext/string/indent.rb',
19
+ 'lib/sinarey_support/core_ext/string/output_safety.rb',
20
+ 'lib/sinarey_support/core_ext/array/wrap.rb',
21
+ 'lib/sinarey_support/core_ext/array/access.rb',
22
+ 'lib/sinarey_support/core_ext/array/extract_options.rb',
23
+ 'lib/sinarey_support/core_ext/array/grouping.rb',
24
+ 'lib/sinarey_support/core_ext/array/prepend_and_append.rb',
25
+ 'lib/sinarey_support/core_ext/hash/deep_merge.rb',
26
+ 'lib/sinarey_support/core_ext/hash/except.rb',
27
+ 'lib/sinarey_support/core_ext/hash/keys.rb',
28
+ 'lib/sinarey_support/core_ext/hash/reverse_merge.rb',
29
+ 'lib/sinarey_support/core_ext/hash/slice.rb',
30
+ 'lib/sinarey_support/core_ext/object/acts_like.rb',
31
+ 'lib/sinarey_support/core_ext/object/blank.rb',
32
+ 'lib/sinarey_support/core_ext/object/to_param.rb',
33
+ 'lib/sinarey_support/core_ext/object/to_query.rb',
34
+ 'lib/sinarey_support/core_ext/object/try.rb',
35
+ 'lib/sinarey_support/core_ext/kernel.rb',
36
+ 'lib/sinarey_support/core_ext/string.rb',
37
+ 'lib/sinarey_support/core_ext/array.rb',
38
+ 'lib/sinarey_support/core_ext/hash.rb',
39
+ 'lib/sinarey_support/core_ext/object.rb',
40
+ 'lib/sinarey_support/core_ext/struct.rb',
41
+ 'lib/sinarey_support/erb/html_safe.rb',
42
+ 'lib/sinarey_support/sinatra/exception_template.rb',
43
+ 'lib/sinarey_support/sinatra/html_safe.rb',
44
+ 'lib/sinarey_support.rb',
45
+ 'sinarey_support.gemspec']
46
+
47
+
48
+
49
+ end
metadata CHANGED
@@ -1,26 +1,34 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sinarey_support
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
- - Jeffrey Xu
7
+ - Jeffrey
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-11 00:00:00.000000000 Z
11
+ date: 2014-04-22 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: ''
14
- email: jeffrey6052@163.com
13
+ description: some useful methods for sinatra framework
14
+ email:
15
+ - jeffrey6052@163.com
15
16
  executables: []
16
17
  extensions: []
17
18
  extra_rdoc_files: []
18
19
  files:
20
+ - lib/sinarey_support/core_ext/kernel/singleton_class.rb
21
+ - lib/sinarey_support/core_ext/string/access.rb
22
+ - lib/sinarey_support/core_ext/string/behavior.rb
23
+ - lib/sinarey_support/core_ext/string/exclude.rb
24
+ - lib/sinarey_support/core_ext/string/filters.rb
25
+ - lib/sinarey_support/core_ext/string/indent.rb
26
+ - lib/sinarey_support/core_ext/string/output_safety.rb
27
+ - lib/sinarey_support/core_ext/array/wrap.rb
19
28
  - lib/sinarey_support/core_ext/array/access.rb
20
29
  - lib/sinarey_support/core_ext/array/extract_options.rb
21
30
  - lib/sinarey_support/core_ext/array/grouping.rb
22
31
  - lib/sinarey_support/core_ext/array/prepend_and_append.rb
23
- - lib/sinarey_support/core_ext/array/wrap.rb
24
32
  - lib/sinarey_support/core_ext/hash/deep_merge.rb
25
33
  - lib/sinarey_support/core_ext/hash/except.rb
26
34
  - lib/sinarey_support/core_ext/hash/keys.rb
@@ -31,18 +39,18 @@ files:
31
39
  - lib/sinarey_support/core_ext/object/to_param.rb
32
40
  - lib/sinarey_support/core_ext/object/to_query.rb
33
41
  - lib/sinarey_support/core_ext/object/try.rb
34
- - lib/sinarey_support/core_ext/string/access.rb
35
- - lib/sinarey_support/core_ext/string/behavior.rb
36
- - lib/sinarey_support/core_ext/string/exclude.rb
37
- - lib/sinarey_support/core_ext/string/filters.rb
38
- - lib/sinarey_support/core_ext/string/indent.rb
42
+ - lib/sinarey_support/core_ext/kernel.rb
43
+ - lib/sinarey_support/core_ext/string.rb
39
44
  - lib/sinarey_support/core_ext/array.rb
40
45
  - lib/sinarey_support/core_ext/hash.rb
41
46
  - lib/sinarey_support/core_ext/object.rb
42
- - lib/sinarey_support/core_ext/string.rb
43
47
  - lib/sinarey_support/core_ext/struct.rb
48
+ - lib/sinarey_support/erb/html_safe.rb
49
+ - lib/sinarey_support/sinatra/exception_template.rb
50
+ - lib/sinarey_support/sinatra/html_safe.rb
44
51
  - lib/sinarey_support.rb
45
- homepage: http://rubygems.org/gems/sinarey_support
52
+ - sinarey_support.gemspec
53
+ homepage: ''
46
54
  licenses:
47
55
  - MIT
48
56
  metadata: {}
@@ -52,12 +60,12 @@ require_paths:
52
60
  - lib
53
61
  required_ruby_version: !ruby/object:Gem::Requirement
54
62
  requirements:
55
- - - '>='
63
+ - - ">="
56
64
  - !ruby/object:Gem::Version
57
65
  version: '0'
58
66
  required_rubygems_version: !ruby/object:Gem::Requirement
59
67
  requirements:
60
- - - '>='
68
+ - - ">="
61
69
  - !ruby/object:Gem::Version
62
70
  version: '0'
63
71
  requirements: []
@@ -65,5 +73,5 @@ rubyforge_project:
65
73
  rubygems_version: 2.0.14
66
74
  signing_key:
67
75
  specification_version: 4
68
- summary: sinarey_support!
76
+ summary: ''
69
77
  test_files: []