dh_easy-core 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +12 -0
- data/.travis.yml +7 -0
- data/.yardopts +1 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/LICENSE +21 -0
- data/README.md +20 -0
- data/Rakefile +22 -0
- data/dh_easy-core.gemspec +50 -0
- data/doc/DhEasy.html +117 -0
- data/doc/DhEasy/Core.html +1590 -0
- data/doc/DhEasy/Core/Config.html +311 -0
- data/doc/DhEasy/Core/Exception.html +117 -0
- data/doc/DhEasy/Core/Exception/OutdatedError.html +135 -0
- data/doc/DhEasy/Core/Helper.html +117 -0
- data/doc/DhEasy/Core/Helper/Cookie.html +1070 -0
- data/doc/DhEasy/Core/Mock.html +282 -0
- data/doc/DhEasy/Core/Mock/FakeDb.html +3779 -0
- data/doc/DhEasy/Core/Mock/FakeExecutor.html +3289 -0
- data/doc/DhEasy/Core/Mock/FakeFinisher.html +160 -0
- data/doc/DhEasy/Core/Mock/FakeParser.html +160 -0
- data/doc/DhEasy/Core/Mock/FakeSeeder.html +160 -0
- data/doc/DhEasy/Core/Plugin.html +117 -0
- data/doc/DhEasy/Core/Plugin/CollectionVault.html +299 -0
- data/doc/DhEasy/Core/Plugin/ConfigBehavior.html +541 -0
- data/doc/DhEasy/Core/Plugin/ContextIntegrator.html +445 -0
- data/doc/DhEasy/Core/Plugin/Executor.html +259 -0
- data/doc/DhEasy/Core/Plugin/ExecutorBehavior.html +344 -0
- data/doc/DhEasy/Core/Plugin/Finisher.html +265 -0
- data/doc/DhEasy/Core/Plugin/FinisherBehavior.html +142 -0
- data/doc/DhEasy/Core/Plugin/InitializeHook.html +220 -0
- data/doc/DhEasy/Core/Plugin/Parser.html +270 -0
- data/doc/DhEasy/Core/Plugin/ParserBehavior.html +235 -0
- data/doc/DhEasy/Core/Plugin/Seeder.html +674 -0
- data/doc/DhEasy/Core/Plugin/SeederBehavior.html +142 -0
- data/doc/DhEasy/Core/SmartCollection.html +1087 -0
- data/doc/_index.html +364 -0
- data/doc/class_list.html +51 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +58 -0
- data/doc/css/style.css +496 -0
- data/doc/file.README.html +91 -0
- data/doc/file_list.html +56 -0
- data/doc/frames.html +17 -0
- data/doc/index.html +91 -0
- data/doc/js/app.js +303 -0
- data/doc/js/full_list.js +216 -0
- data/doc/js/jquery.js +4 -0
- data/doc/method_list.html +939 -0
- data/doc/top-level-namespace.html +110 -0
- data/lib/dh_easy/core.rb +257 -0
- data/lib/dh_easy/core/config.rb +27 -0
- data/lib/dh_easy/core/exception.rb +8 -0
- data/lib/dh_easy/core/exception/outdated_error.rb +9 -0
- data/lib/dh_easy/core/helper.rb +8 -0
- data/lib/dh_easy/core/helper/cookie.rb +209 -0
- data/lib/dh_easy/core/mock.rb +45 -0
- data/lib/dh_easy/core/mock/fake_db.rb +561 -0
- data/lib/dh_easy/core/mock/fake_executor.rb +373 -0
- data/lib/dh_easy/core/mock/fake_finisher.rb +28 -0
- data/lib/dh_easy/core/mock/fake_parser.rb +33 -0
- data/lib/dh_easy/core/mock/fake_seeder.rb +28 -0
- data/lib/dh_easy/core/plugin.rb +19 -0
- data/lib/dh_easy/core/plugin/collection_vault.rb +23 -0
- data/lib/dh_easy/core/plugin/config_behavior.rb +43 -0
- data/lib/dh_easy/core/plugin/context_integrator.rb +60 -0
- data/lib/dh_easy/core/plugin/executor.rb +19 -0
- data/lib/dh_easy/core/plugin/executor_behavior.rb +32 -0
- data/lib/dh_easy/core/plugin/finisher.rb +19 -0
- data/lib/dh_easy/core/plugin/finisher_behavior.rb +9 -0
- data/lib/dh_easy/core/plugin/initialize_hook.rb +17 -0
- data/lib/dh_easy/core/plugin/parser.rb +19 -0
- data/lib/dh_easy/core/plugin/parser_behavior.rb +17 -0
- data/lib/dh_easy/core/plugin/seeder.rb +44 -0
- data/lib/dh_easy/core/plugin/seeder_behavior.rb +9 -0
- data/lib/dh_easy/core/smart_collection.rb +236 -0
- data/lib/dh_easy/core/version.rb +6 -0
- metadata +249 -0
@@ -0,0 +1,117 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6
|
+
<title>
|
7
|
+
Module: DhEasy::Core::Helper
|
8
|
+
|
9
|
+
— Documentation by YARD 0.9.20
|
10
|
+
|
11
|
+
</title>
|
12
|
+
|
13
|
+
<link rel="stylesheet" href="../../css/style.css" type="text/css" charset="utf-8" />
|
14
|
+
|
15
|
+
<link rel="stylesheet" href="../../css/common.css" type="text/css" charset="utf-8" />
|
16
|
+
|
17
|
+
<script type="text/javascript" charset="utf-8">
|
18
|
+
pathId = "DhEasy::Core::Helper";
|
19
|
+
relpath = '../../';
|
20
|
+
</script>
|
21
|
+
|
22
|
+
|
23
|
+
<script type="text/javascript" charset="utf-8" src="../../js/jquery.js"></script>
|
24
|
+
|
25
|
+
<script type="text/javascript" charset="utf-8" src="../../js/app.js"></script>
|
26
|
+
|
27
|
+
|
28
|
+
</head>
|
29
|
+
<body>
|
30
|
+
<div class="nav_wrap">
|
31
|
+
<iframe id="nav" src="../../class_list.html?1"></iframe>
|
32
|
+
<div id="resizer"></div>
|
33
|
+
</div>
|
34
|
+
|
35
|
+
<div id="main" tabindex="-1">
|
36
|
+
<div id="header">
|
37
|
+
<div id="menu">
|
38
|
+
|
39
|
+
<a href="../../_index.html">Index (H)</a> »
|
40
|
+
<span class='title'><span class='object_link'><a href="../../DhEasy.html" title="DhEasy (module)">DhEasy</a></span></span> » <span class='title'><span class='object_link'><a href="../Core.html" title="DhEasy::Core (module)">Core</a></span></span>
|
41
|
+
»
|
42
|
+
<span class="title">Helper</span>
|
43
|
+
|
44
|
+
</div>
|
45
|
+
|
46
|
+
<div id="search">
|
47
|
+
|
48
|
+
<a class="full_list_link" id="class_list_link"
|
49
|
+
href="../../class_list.html">
|
50
|
+
|
51
|
+
<svg width="24" height="24">
|
52
|
+
<rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
|
53
|
+
<rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
|
54
|
+
<rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
|
55
|
+
</svg>
|
56
|
+
</a>
|
57
|
+
|
58
|
+
</div>
|
59
|
+
<div class="clear"></div>
|
60
|
+
</div>
|
61
|
+
|
62
|
+
<div id="content"><h1>Module: DhEasy::Core::Helper
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
</h1>
|
67
|
+
<div class="box_info">
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
<dl>
|
80
|
+
<dt>Defined in:</dt>
|
81
|
+
<dd>lib/dh_easy/core/helper.rb<span class="defines">,<br />
|
82
|
+
lib/dh_easy/core/helper/cookie.rb</span>
|
83
|
+
</dd>
|
84
|
+
</dl>
|
85
|
+
|
86
|
+
</div>
|
87
|
+
|
88
|
+
<h2>Defined Under Namespace</h2>
|
89
|
+
<p class="children">
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
<strong class="classes">Classes:</strong> <span class='object_link'><a href="Helper/Cookie.html" title="DhEasy::Core::Helper::Cookie (class)">Cookie</a></span>
|
95
|
+
|
96
|
+
|
97
|
+
</p>
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
</div>
|
108
|
+
|
109
|
+
<div id="footer">
|
110
|
+
Generated on Wed Dec 4 23:00:02 2019 by
|
111
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
112
|
+
0.9.20 (ruby-2.5.3).
|
113
|
+
</div>
|
114
|
+
|
115
|
+
</div>
|
116
|
+
</body>
|
117
|
+
</html>
|
@@ -0,0 +1,1070 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6
|
+
<title>
|
7
|
+
Class: DhEasy::Core::Helper::Cookie
|
8
|
+
|
9
|
+
— Documentation by YARD 0.9.20
|
10
|
+
|
11
|
+
</title>
|
12
|
+
|
13
|
+
<link rel="stylesheet" href="../../../css/style.css" type="text/css" charset="utf-8" />
|
14
|
+
|
15
|
+
<link rel="stylesheet" href="../../../css/common.css" type="text/css" charset="utf-8" />
|
16
|
+
|
17
|
+
<script type="text/javascript" charset="utf-8">
|
18
|
+
pathId = "DhEasy::Core::Helper::Cookie";
|
19
|
+
relpath = '../../../';
|
20
|
+
</script>
|
21
|
+
|
22
|
+
|
23
|
+
<script type="text/javascript" charset="utf-8" src="../../../js/jquery.js"></script>
|
24
|
+
|
25
|
+
<script type="text/javascript" charset="utf-8" src="../../../js/app.js"></script>
|
26
|
+
|
27
|
+
|
28
|
+
</head>
|
29
|
+
<body>
|
30
|
+
<div class="nav_wrap">
|
31
|
+
<iframe id="nav" src="../../../class_list.html?1"></iframe>
|
32
|
+
<div id="resizer"></div>
|
33
|
+
</div>
|
34
|
+
|
35
|
+
<div id="main" tabindex="-1">
|
36
|
+
<div id="header">
|
37
|
+
<div id="menu">
|
38
|
+
|
39
|
+
<a href="../../../_index.html">Index (C)</a> »
|
40
|
+
<span class='title'><span class='object_link'><a href="../../../DhEasy.html" title="DhEasy (module)">DhEasy</a></span></span> » <span class='title'><span class='object_link'><a href="../../Core.html" title="DhEasy::Core (module)">Core</a></span></span> » <span class='title'><span class='object_link'><a href="../Helper.html" title="DhEasy::Core::Helper (module)">Helper</a></span></span>
|
41
|
+
»
|
42
|
+
<span class="title">Cookie</span>
|
43
|
+
|
44
|
+
</div>
|
45
|
+
|
46
|
+
<div id="search">
|
47
|
+
|
48
|
+
<a class="full_list_link" id="class_list_link"
|
49
|
+
href="../../../class_list.html">
|
50
|
+
|
51
|
+
<svg width="24" height="24">
|
52
|
+
<rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
|
53
|
+
<rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
|
54
|
+
<rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
|
55
|
+
</svg>
|
56
|
+
</a>
|
57
|
+
|
58
|
+
</div>
|
59
|
+
<div class="clear"></div>
|
60
|
+
</div>
|
61
|
+
|
62
|
+
<div id="content"><h1>Class: DhEasy::Core::Helper::Cookie
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
</h1>
|
67
|
+
<div class="box_info">
|
68
|
+
|
69
|
+
<dl>
|
70
|
+
<dt>Inherits:</dt>
|
71
|
+
<dd>
|
72
|
+
<span class="inheritName">Object</span>
|
73
|
+
|
74
|
+
<ul class="fullTree">
|
75
|
+
<li>Object</li>
|
76
|
+
|
77
|
+
<li class="next">DhEasy::Core::Helper::Cookie</li>
|
78
|
+
|
79
|
+
</ul>
|
80
|
+
<a href="#" class="inheritanceTree">show all</a>
|
81
|
+
|
82
|
+
</dd>
|
83
|
+
</dl>
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
<dl>
|
96
|
+
<dt>Defined in:</dt>
|
97
|
+
<dd>lib/dh_easy/core/helper/cookie.rb</dd>
|
98
|
+
</dl>
|
99
|
+
|
100
|
+
</div>
|
101
|
+
|
102
|
+
<h2>Overview</h2><div class="docstring">
|
103
|
+
<div class="discussion">
|
104
|
+
|
105
|
+
<p>Helper used for lower level cookie management.</p>
|
106
|
+
|
107
|
+
|
108
|
+
</div>
|
109
|
+
</div>
|
110
|
+
<div class="tags">
|
111
|
+
|
112
|
+
|
113
|
+
</div>
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
<h2>
|
122
|
+
Class Method Summary
|
123
|
+
<small><a href="#" class="summary_toggle">collapse</a></small>
|
124
|
+
</h2>
|
125
|
+
|
126
|
+
<ul class="summary">
|
127
|
+
|
128
|
+
<li class="public ">
|
129
|
+
<span class="summary_signature">
|
130
|
+
|
131
|
+
<a href="#encode_to_header-class_method" title="encode_to_header (class method)">.<strong>encode_to_header</strong>(cookie_hash) ⇒ String </a>
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
</span>
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
<span class="summary_desc"><div class='inline'>
|
146
|
+
<p>Encode cookies as request cookie string.</p>
|
147
|
+
</div></span>
|
148
|
+
|
149
|
+
</li>
|
150
|
+
|
151
|
+
|
152
|
+
<li class="public ">
|
153
|
+
<span class="summary_signature">
|
154
|
+
|
155
|
+
<a href="#include%3F-class_method" title="include? (class method)">.<strong>include?</strong>(base_cookie_hash, cookie_hash) ⇒ Boolean </a>
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
</span>
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
|
168
|
+
|
169
|
+
<span class="summary_desc"><div class='inline'>
|
170
|
+
<p>Compare if cookie is included into base cookie.</p>
|
171
|
+
</div></span>
|
172
|
+
|
173
|
+
</li>
|
174
|
+
|
175
|
+
|
176
|
+
<li class="public ">
|
177
|
+
<span class="summary_signature">
|
178
|
+
|
179
|
+
<a href="#parse_from_request-class_method" title="parse_from_request (class method)">.<strong>parse_from_request</strong>(cookies, cookie_hash = {}) ⇒ Hash </a>
|
180
|
+
|
181
|
+
|
182
|
+
|
183
|
+
</span>
|
184
|
+
|
185
|
+
|
186
|
+
|
187
|
+
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
<span class="summary_desc"><div class='inline'>
|
194
|
+
<p>Parse request cookies on different formats.</p>
|
195
|
+
</div></span>
|
196
|
+
|
197
|
+
</li>
|
198
|
+
|
199
|
+
|
200
|
+
<li class="public ">
|
201
|
+
<span class="summary_signature">
|
202
|
+
|
203
|
+
<a href="#parse_from_response-class_method" title="parse_from_response (class method)">.<strong>parse_from_response</strong>(cookies, cookie_hash = {}) ⇒ Hash </a>
|
204
|
+
|
205
|
+
|
206
|
+
|
207
|
+
</span>
|
208
|
+
|
209
|
+
|
210
|
+
|
211
|
+
|
212
|
+
|
213
|
+
|
214
|
+
|
215
|
+
|
216
|
+
|
217
|
+
<span class="summary_desc"><div class='inline'>
|
218
|
+
<p>Parse response cookies on different formats.</p>
|
219
|
+
</div></span>
|
220
|
+
|
221
|
+
</li>
|
222
|
+
|
223
|
+
|
224
|
+
<li class="public ">
|
225
|
+
<span class="summary_signature">
|
226
|
+
|
227
|
+
<a href="#update-class_method" title="update (class method)">.<strong>update</strong>(request_cookies, response_cookies) ⇒ String </a>
|
228
|
+
|
229
|
+
|
230
|
+
|
231
|
+
</span>
|
232
|
+
|
233
|
+
|
234
|
+
|
235
|
+
|
236
|
+
|
237
|
+
|
238
|
+
|
239
|
+
|
240
|
+
|
241
|
+
<span class="summary_desc"><div class='inline'>
|
242
|
+
<p>Apply request and response cookies as a string with request format.</p>
|
243
|
+
</div></span>
|
244
|
+
|
245
|
+
</li>
|
246
|
+
|
247
|
+
|
248
|
+
<li class="public ">
|
249
|
+
<span class="summary_signature">
|
250
|
+
|
251
|
+
<a href="#update_as_hash-class_method" title="update_as_hash (class method)">.<strong>update_as_hash</strong>(request_cookies, response_cookies) ⇒ Hash </a>
|
252
|
+
|
253
|
+
|
254
|
+
|
255
|
+
</span>
|
256
|
+
|
257
|
+
|
258
|
+
|
259
|
+
|
260
|
+
|
261
|
+
|
262
|
+
|
263
|
+
|
264
|
+
|
265
|
+
<span class="summary_desc"><div class='inline'>
|
266
|
+
<p>Apply request and response cookies as a hash.</p>
|
267
|
+
</div></span>
|
268
|
+
|
269
|
+
</li>
|
270
|
+
|
271
|
+
|
272
|
+
</ul>
|
273
|
+
|
274
|
+
|
275
|
+
|
276
|
+
|
277
|
+
<div id="class_method_details" class="method_details_list">
|
278
|
+
<h2>Class Method Details</h2>
|
279
|
+
|
280
|
+
|
281
|
+
<div class="method_details first">
|
282
|
+
<h3 class="signature first" id="encode_to_header-class_method">
|
283
|
+
|
284
|
+
.<strong>encode_to_header</strong>(cookie_hash) ⇒ <tt>String</tt>
|
285
|
+
|
286
|
+
|
287
|
+
|
288
|
+
|
289
|
+
|
290
|
+
</h3><div class="docstring">
|
291
|
+
<div class="discussion">
|
292
|
+
|
293
|
+
<p>Encode cookies as request cookie string.</p>
|
294
|
+
|
295
|
+
|
296
|
+
</div>
|
297
|
+
</div>
|
298
|
+
<div class="tags">
|
299
|
+
|
300
|
+
<div class="examples">
|
301
|
+
<p class="tag_title">Examples:</p>
|
302
|
+
|
303
|
+
|
304
|
+
<pre class="example code"><code><span class='id identifier rubyid_cookie_hash'>cookie_hash</span> <span class='op'>=</span> <span class='lbrace'>{</span>
|
305
|
+
<span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>aaa</span><span class='tstring_end'>'</span></span> <span class='op'>=></span> <span class='int'>111</span><span class='comma'>,</span>
|
306
|
+
<span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>bbb</span><span class='tstring_end'>'</span></span> <span class='op'>=></span> <span class='int'>222</span>
|
307
|
+
<span class='rbrace'>}</span>
|
308
|
+
<span class='id identifier rubyid_encode_to_header'>encode_to_header</span> <span class='id identifier rubyid_cookie_hash'>cookie_hash</span>
|
309
|
+
<span class='comment'># => 'aaa=111; bbb=222'</span></code></pre>
|
310
|
+
|
311
|
+
</div>
|
312
|
+
<p class="tag_title">Parameters:</p>
|
313
|
+
<ul class="param">
|
314
|
+
|
315
|
+
<li>
|
316
|
+
|
317
|
+
<span class='name'>cookie_hash</span>
|
318
|
+
|
319
|
+
|
320
|
+
<span class='type'>(<tt>Hash</tt>)</span>
|
321
|
+
|
322
|
+
|
323
|
+
|
324
|
+
—
|
325
|
+
<div class='inline'>
|
326
|
+
<p>Hash with cookies.</p>
|
327
|
+
</div>
|
328
|
+
|
329
|
+
</li>
|
330
|
+
|
331
|
+
</ul>
|
332
|
+
|
333
|
+
<p class="tag_title">Returns:</p>
|
334
|
+
<ul class="return">
|
335
|
+
|
336
|
+
<li>
|
337
|
+
|
338
|
+
|
339
|
+
<span class='type'>(<tt>String</tt>)</span>
|
340
|
+
|
341
|
+
|
342
|
+
|
343
|
+
</li>
|
344
|
+
|
345
|
+
</ul>
|
346
|
+
|
347
|
+
</div><table class="source_code">
|
348
|
+
<tr>
|
349
|
+
<td>
|
350
|
+
<pre class="lines">
|
351
|
+
|
352
|
+
|
353
|
+
140
|
354
|
+
141
|
355
|
+
142</pre>
|
356
|
+
</td>
|
357
|
+
<td>
|
358
|
+
<pre class="code"><span class="info file"># File 'lib/dh_easy/core/helper/cookie.rb', line 140</span>
|
359
|
+
|
360
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_encode_to_header'>encode_to_header</span> <span class='id identifier rubyid_cookie_hash'>cookie_hash</span>
|
361
|
+
<span class='id identifier rubyid_cookie_hash'>cookie_hash</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_k'>k</span><span class='comma'>,</span><span class='id identifier rubyid_v'>v</span><span class='op'>|</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_k'>k</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_v'>v</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span><span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_join'>join</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>; </span><span class='tstring_end'>'</span></span>
|
362
|
+
<span class='kw'>end</span></pre>
|
363
|
+
</td>
|
364
|
+
</tr>
|
365
|
+
</table>
|
366
|
+
</div>
|
367
|
+
|
368
|
+
<div class="method_details ">
|
369
|
+
<h3 class="signature " id="include?-class_method">
|
370
|
+
|
371
|
+
.<strong>include?</strong>(base_cookie_hash, cookie_hash) ⇒ <tt>Boolean</tt>
|
372
|
+
|
373
|
+
|
374
|
+
|
375
|
+
|
376
|
+
|
377
|
+
</h3><div class="docstring">
|
378
|
+
<div class="discussion">
|
379
|
+
|
380
|
+
<p>Compare if cookie is included into base cookie</p>
|
381
|
+
|
382
|
+
|
383
|
+
</div>
|
384
|
+
</div>
|
385
|
+
<div class="tags">
|
386
|
+
|
387
|
+
<div class="examples">
|
388
|
+
<p class="tag_title">Examples:</p>
|
389
|
+
|
390
|
+
|
391
|
+
<p class="example_title"><div class='inline'>
|
392
|
+
<p>Check a success match.</p>
|
393
|
+
</div></p>
|
394
|
+
|
395
|
+
<pre class="example code"><code><span class='id identifier rubyid_base_cookie_hash'>base_cookie_hash</span> <span class='op'>=</span> <span class='lbrace'>{</span>
|
396
|
+
<span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>aaa</span><span class='tstring_end'>'</span></span> <span class='op'>=></span> <span class='int'>111</span><span class='comma'>,</span>
|
397
|
+
<span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>bbb</span><span class='tstring_end'>'</span></span> <span class='op'>=></span> <span class='int'>222</span><span class='comma'>,</span>
|
398
|
+
<span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>ccc</span><span class='tstring_end'>'</span></span> <span class='op'>=></span> <span class='int'>333</span><span class='comma'>,</span>
|
399
|
+
<span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>ddd</span><span class='tstring_end'>'</span></span> <span class='op'>=></span> <span class='int'>444</span>
|
400
|
+
<span class='rbrace'>}</span>
|
401
|
+
<span class='id identifier rubyid_cookie_hash'>cookie_hash</span> <span class='op'>=</span> <span class='lbrace'>{</span>
|
402
|
+
<span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>bbb</span><span class='tstring_end'>'</span></span> <span class='op'>=></span> <span class='int'>222</span><span class='comma'>,</span>
|
403
|
+
<span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>ddd</span><span class='tstring_end'>'</span></span> <span class='op'>=></span> <span class='int'>444</span>
|
404
|
+
<span class='rbrace'>}</span>
|
405
|
+
<span class='id identifier rubyid_include?'>include?</span> <span class='id identifier rubyid_base_cookie_hash'>base_cookie_hash</span><span class='comma'>,</span> <span class='id identifier rubyid_cookie_hash'>cookie_hash</span>
|
406
|
+
<span class='comment'># => true</span></code></pre>
|
407
|
+
|
408
|
+
|
409
|
+
<p class="example_title"><div class='inline'>
|
410
|
+
<p>Check with fail match.</p>
|
411
|
+
</div></p>
|
412
|
+
|
413
|
+
<pre class="example code"><code><span class='id identifier rubyid_base_cookie_hash'>base_cookie_hash</span> <span class='op'>=</span> <span class='lbrace'>{</span>
|
414
|
+
<span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>aaa</span><span class='tstring_end'>'</span></span> <span class='op'>=></span> <span class='int'>111</span><span class='comma'>,</span>
|
415
|
+
<span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>bbb</span><span class='tstring_end'>'</span></span> <span class='op'>=></span> <span class='int'>222</span><span class='comma'>,</span>
|
416
|
+
<span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>ccc</span><span class='tstring_end'>'</span></span> <span class='op'>=></span> <span class='int'>333</span><span class='comma'>,</span>
|
417
|
+
<span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>ddd</span><span class='tstring_end'>'</span></span> <span class='op'>=></span> <span class='int'>444</span>
|
418
|
+
<span class='rbrace'>}</span>
|
419
|
+
<span class='id identifier rubyid_cookie_hash'>cookie_hash</span> <span class='op'>=</span> <span class='lbrace'>{</span>
|
420
|
+
<span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>bbb</span><span class='tstring_end'>'</span></span> <span class='op'>=></span> <span class='int'>555</span><span class='comma'>,</span>
|
421
|
+
<span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>ddd</span><span class='tstring_end'>'</span></span> <span class='op'>=></span> <span class='int'>444</span>
|
422
|
+
<span class='rbrace'>}</span>
|
423
|
+
<span class='id identifier rubyid_include?'>include?</span> <span class='id identifier rubyid_base_cookie_hash'>base_cookie_hash</span><span class='comma'>,</span> <span class='id identifier rubyid_cookie_hash'>cookie_hash</span>
|
424
|
+
<span class='comment'># => false</span></code></pre>
|
425
|
+
|
426
|
+
</div>
|
427
|
+
<p class="tag_title">Parameters:</p>
|
428
|
+
<ul class="param">
|
429
|
+
|
430
|
+
<li>
|
431
|
+
|
432
|
+
<span class='name'>base_cookie_hash</span>
|
433
|
+
|
434
|
+
|
435
|
+
<span class='type'>(<tt>Hash</tt>)</span>
|
436
|
+
|
437
|
+
|
438
|
+
|
439
|
+
—
|
440
|
+
<div class='inline'>
|
441
|
+
<p>Hash that represent universe.</p>
|
442
|
+
</div>
|
443
|
+
|
444
|
+
</li>
|
445
|
+
|
446
|
+
<li>
|
447
|
+
|
448
|
+
<span class='name'>cookie_hash</span>
|
449
|
+
|
450
|
+
|
451
|
+
<span class='type'>(<tt>Hash</tt>)</span>
|
452
|
+
|
453
|
+
|
454
|
+
|
455
|
+
—
|
456
|
+
<div class='inline'>
|
457
|
+
<p>Hash that represents to compare.</p>
|
458
|
+
</div>
|
459
|
+
|
460
|
+
</li>
|
461
|
+
|
462
|
+
</ul>
|
463
|
+
|
464
|
+
<p class="tag_title">Returns:</p>
|
465
|
+
<ul class="return">
|
466
|
+
|
467
|
+
<li>
|
468
|
+
|
469
|
+
|
470
|
+
<span class='type'>(<tt>Boolean</tt>)</span>
|
471
|
+
|
472
|
+
|
473
|
+
|
474
|
+
</li>
|
475
|
+
|
476
|
+
</ul>
|
477
|
+
|
478
|
+
</div><table class="source_code">
|
479
|
+
<tr>
|
480
|
+
<td>
|
481
|
+
<pre class="lines">
|
482
|
+
|
483
|
+
|
484
|
+
199
|
485
|
+
200
|
486
|
+
201
|
487
|
+
202
|
488
|
+
203
|
489
|
+
204</pre>
|
490
|
+
</td>
|
491
|
+
<td>
|
492
|
+
<pre class="code"><span class="info file"># File 'lib/dh_easy/core/helper/cookie.rb', line 199</span>
|
493
|
+
|
494
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_include?'>include?</span> <span class='id identifier rubyid_base_cookie_hash'>base_cookie_hash</span><span class='comma'>,</span> <span class='id identifier rubyid_cookie_hash'>cookie_hash</span>
|
495
|
+
<span class='id identifier rubyid_cookie_hash'>cookie_hash</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='op'>|</span>
|
496
|
+
<span class='kw'>return</span> <span class='kw'>false</span> <span class='kw'>unless</span> <span class='id identifier rubyid_base_cookie_hash'>base_cookie_hash</span><span class='period'>.</span><span class='id identifier rubyid_has_key?'>has_key?</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span> <span class='op'>&&</span> <span class='id identifier rubyid_base_cookie_hash'>base_cookie_hash</span><span class='lbracket'>[</span><span class='id identifier rubyid_key'>key</span><span class='rbracket'>]</span> <span class='op'>==</span> <span class='id identifier rubyid_value'>value</span>
|
497
|
+
<span class='kw'>end</span>
|
498
|
+
<span class='kw'>true</span>
|
499
|
+
<span class='kw'>end</span></pre>
|
500
|
+
</td>
|
501
|
+
</tr>
|
502
|
+
</table>
|
503
|
+
</div>
|
504
|
+
|
505
|
+
<div class="method_details ">
|
506
|
+
<h3 class="signature " id="parse_from_request-class_method">
|
507
|
+
|
508
|
+
.<strong>parse_from_request</strong>(cookies, cookie_hash = {}) ⇒ <tt>Hash</tt>
|
509
|
+
|
510
|
+
|
511
|
+
|
512
|
+
|
513
|
+
|
514
|
+
</h3><div class="docstring">
|
515
|
+
<div class="discussion">
|
516
|
+
|
517
|
+
<p>Parse request cookies on different formats.</p>
|
518
|
+
|
519
|
+
|
520
|
+
</div>
|
521
|
+
</div>
|
522
|
+
<div class="tags">
|
523
|
+
|
524
|
+
<div class="examples">
|
525
|
+
<p class="tag_title">Examples:</p>
|
526
|
+
|
527
|
+
|
528
|
+
<p class="example_title"><div class='inline'>
|
529
|
+
<p>Parse from string.</p>
|
530
|
+
</div></p>
|
531
|
+
|
532
|
+
<pre class="example code"><code><span class='id identifier rubyid_parse_from_request'>parse_from_request</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>aaa=111; bbb=222</span><span class='tstring_end'>'</span></span>
|
533
|
+
<span class='comment'># => {'aaa' => 111, 'bbb' => 222}</span></code></pre>
|
534
|
+
|
535
|
+
|
536
|
+
<p class="example_title"><div class='inline'>
|
537
|
+
<p>Parse from array.</p>
|
538
|
+
</div></p>
|
539
|
+
|
540
|
+
<pre class="example code"><code><span class='id identifier rubyid_cookies'>cookies</span> <span class='op'>=</span> <span class='lbracket'>[</span>
|
541
|
+
<span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>aaa=111</span><span class='tstring_end'>'</span></span><span class='comma'>,</span>
|
542
|
+
<span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>bbb=222</span><span class='tstring_end'>'</span></span>
|
543
|
+
<span class='rbracket'>]</span>
|
544
|
+
<span class='id identifier rubyid_parse_from_response'>parse_from_response</span> <span class='id identifier rubyid_cookies'>cookies</span>
|
545
|
+
<span class='comment'># => {'aaa' => 111, 'bbb' => 222}</span></code></pre>
|
546
|
+
|
547
|
+
|
548
|
+
<p class="example_title"><div class='inline'>
|
549
|
+
<p>Parse with `cookie_hash`.</p>
|
550
|
+
</div></p>
|
551
|
+
|
552
|
+
<pre class="example code"><code><span class='id identifier rubyid_cookie_hash'>cookie_hash</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>ccc</span><span class='tstring_end'>'</span></span> <span class='op'>=></span> <span class='int'>333</span><span class='rbrace'>}</span>
|
553
|
+
<span class='id identifier rubyid_parse_from_request'>parse_from_request</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>aaa=111; bbb=222</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='id identifier rubyid_cookie_hash'>cookie_hash</span>
|
554
|
+
<span class='id identifier rubyid_cookie_hash'>cookie_hash</span>
|
555
|
+
<span class='comment'># => {'aaa' => 1, 'bbb' => 2, 'ccc' => 333}</span></code></pre>
|
556
|
+
|
557
|
+
</div>
|
558
|
+
<p class="tag_title">Parameters:</p>
|
559
|
+
<ul class="param">
|
560
|
+
|
561
|
+
<li>
|
562
|
+
|
563
|
+
<span class='name'>cookies</span>
|
564
|
+
|
565
|
+
|
566
|
+
<span class='type'>(<tt>String</tt>, <tt>Hash</tt>, <tt>Array</tt>)</span>
|
567
|
+
|
568
|
+
|
569
|
+
|
570
|
+
—
|
571
|
+
<div class='inline'>
|
572
|
+
<p>Cookies to parse.</p>
|
573
|
+
</div>
|
574
|
+
|
575
|
+
</li>
|
576
|
+
|
577
|
+
<li>
|
578
|
+
|
579
|
+
<span class='name'>cookie_hash</span>
|
580
|
+
|
581
|
+
|
582
|
+
<span class='type'>(<tt>Hash</tt>)</span>
|
583
|
+
|
584
|
+
|
585
|
+
<em class="default">(defaults to: <tt>{}</tt>)</em>
|
586
|
+
|
587
|
+
|
588
|
+
—
|
589
|
+
<div class='inline'>
|
590
|
+
<p>({}) External hash to store parsed cookies.</p>
|
591
|
+
</div>
|
592
|
+
|
593
|
+
</li>
|
594
|
+
|
595
|
+
</ul>
|
596
|
+
|
597
|
+
<p class="tag_title">Returns:</p>
|
598
|
+
<ul class="return">
|
599
|
+
|
600
|
+
<li>
|
601
|
+
|
602
|
+
|
603
|
+
<span class='type'>(<tt>Hash</tt>)</span>
|
604
|
+
|
605
|
+
|
606
|
+
|
607
|
+
</li>
|
608
|
+
|
609
|
+
</ul>
|
610
|
+
|
611
|
+
</div><table class="source_code">
|
612
|
+
<tr>
|
613
|
+
<td>
|
614
|
+
<pre class="lines">
|
615
|
+
|
616
|
+
|
617
|
+
31
|
618
|
+
32
|
619
|
+
33
|
620
|
+
34
|
621
|
+
35
|
622
|
+
36
|
623
|
+
37
|
624
|
+
38
|
625
|
+
39
|
626
|
+
40
|
627
|
+
41
|
628
|
+
42
|
629
|
+
43
|
630
|
+
44
|
631
|
+
45
|
632
|
+
46
|
633
|
+
47</pre>
|
634
|
+
</td>
|
635
|
+
<td>
|
636
|
+
<pre class="code"><span class="info file"># File 'lib/dh_easy/core/helper/cookie.rb', line 31</span>
|
637
|
+
|
638
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_parse_from_request'>parse_from_request</span> <span class='id identifier rubyid_cookies'>cookies</span><span class='comma'>,</span> <span class='id identifier rubyid_cookie_hash'>cookie_hash</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
|
639
|
+
<span class='comment'># Retrieve from hash
|
640
|
+
</span> <span class='kw'>if</span> <span class='id identifier rubyid_cookies'>cookies</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span> <span class='const'>Hash</span>
|
641
|
+
<span class='id identifier rubyid_cookie_hash'>cookie_hash</span><span class='period'>.</span><span class='id identifier rubyid_merge!'>merge!</span> <span class='id identifier rubyid_cookies'>cookies</span>
|
642
|
+
<span class='kw'>return</span> <span class='id identifier rubyid_cookie_hash'>cookie_hash</span>
|
643
|
+
<span class='kw'>end</span>
|
644
|
+
|
645
|
+
<span class='comment'># Extract from string
|
646
|
+
</span> <span class='id identifier rubyid_cookies'>cookies</span> <span class='op'>=</span> <span class='id identifier rubyid_cookies'>cookies</span><span class='period'>.</span><span class='id identifier rubyid_split'>split</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>; </span><span class='tstring_end'>'</span></span> <span class='kw'>if</span> <span class='id identifier rubyid_cookies'>cookies</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span> <span class='const'>String</span>
|
647
|
+
|
648
|
+
<span class='comment'># Extract from array
|
649
|
+
</span> <span class='id identifier rubyid_cookies'>cookies</span><span class='op'>&.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_raw_cookie'>raw_cookie</span><span class='op'>|</span>
|
650
|
+
<span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='id identifier rubyid_raw_cookie'>raw_cookie</span><span class='period'>.</span><span class='id identifier rubyid_split'>split</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>=</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='int'>2</span><span class='rparen'>)</span>
|
651
|
+
<span class='id identifier rubyid_cookie_hash'>cookie_hash</span><span class='lbracket'>[</span><span class='id identifier rubyid_key'>key</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span>
|
652
|
+
<span class='kw'>end</span>
|
653
|
+
<span class='id identifier rubyid_cookie_hash'>cookie_hash</span>
|
654
|
+
<span class='kw'>end</span></pre>
|
655
|
+
</td>
|
656
|
+
</tr>
|
657
|
+
</table>
|
658
|
+
</div>
|
659
|
+
|
660
|
+
<div class="method_details ">
|
661
|
+
<h3 class="signature " id="parse_from_response-class_method">
|
662
|
+
|
663
|
+
.<strong>parse_from_response</strong>(cookies, cookie_hash = {}) ⇒ <tt>Hash</tt>
|
664
|
+
|
665
|
+
|
666
|
+
|
667
|
+
|
668
|
+
|
669
|
+
</h3><div class="docstring">
|
670
|
+
<div class="discussion">
|
671
|
+
|
672
|
+
<p>Parse response cookies on different formats.</p>
|
673
|
+
|
674
|
+
|
675
|
+
</div>
|
676
|
+
</div>
|
677
|
+
<div class="tags">
|
678
|
+
|
679
|
+
<div class="examples">
|
680
|
+
<p class="tag_title">Examples:</p>
|
681
|
+
|
682
|
+
|
683
|
+
<p class="example_title"><div class='inline'>
|
684
|
+
<p>Parse from string</p>
|
685
|
+
</div></p>
|
686
|
+
|
687
|
+
<pre class="example code"><code><span class='id identifier rubyid_parse_from_response'>parse_from_response</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>aaa=111; bbb=222</span><span class='tstring_end'>'</span></span>
|
688
|
+
<span class='comment'># => {'aaa' => 111, 'bbb' => 222}</span></code></pre>
|
689
|
+
|
690
|
+
|
691
|
+
<p class="example_title"><div class='inline'>
|
692
|
+
<p>Parse from array.</p>
|
693
|
+
</div></p>
|
694
|
+
|
695
|
+
<pre class="example code"><code><span class='id identifier rubyid_cookies'>cookies</span> <span class='op'>=</span> <span class='lbracket'>[</span>
|
696
|
+
<span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>aaa=111; Expires=Thu, Jan 01 1970 00:00:00 UTC; path=/</span><span class='tstring_end'>'</span></span><span class='comma'>,</span>
|
697
|
+
<span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>bbb=222; path=/</span><span class='tstring_end'>'</span></span><span class='comma'>,</span>
|
698
|
+
<span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>ccc=333; path=/; expires=Wed, Jan 01 3000 00:00:00 UTC</span><span class='tstring_end'>'</span></span>
|
699
|
+
<span class='rbracket'>]</span>
|
700
|
+
<span class='id identifier rubyid_parse_from_response'>parse_from_response</span> <span class='id identifier rubyid_cookies'>cookies</span>
|
701
|
+
<span class='comment'># => {'bbb' => 222, 'ccc' => 333}</span></code></pre>
|
702
|
+
|
703
|
+
|
704
|
+
<p class="example_title"><div class='inline'>
|
705
|
+
<p>Parse with `cookie_hash`.</p>
|
706
|
+
</div></p>
|
707
|
+
|
708
|
+
<pre class="example code"><code><span class='id identifier rubyid_cookie_hash'>cookie_hash</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>ccc</span><span class='tstring_end'>'</span></span> <span class='op'>=></span> <span class='int'>333</span><span class='rbrace'>}</span>
|
709
|
+
<span class='id identifier rubyid_parse_from_response'>parse_from_response</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>aaa=111; bbb=222</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='id identifier rubyid_cookie_hash'>cookie_hash</span>
|
710
|
+
<span class='id identifier rubyid_cookie_hash'>cookie_hash</span>
|
711
|
+
<span class='comment'># => {'aaa' => 111, 'bbb' => 222, 'ccc' => 333}</span></code></pre>
|
712
|
+
|
713
|
+
</div>
|
714
|
+
<p class="tag_title">Parameters:</p>
|
715
|
+
<ul class="param">
|
716
|
+
|
717
|
+
<li>
|
718
|
+
|
719
|
+
<span class='name'>cookies</span>
|
720
|
+
|
721
|
+
|
722
|
+
<span class='type'>(<tt>String</tt>, <tt>Hash</tt>, <tt>Array</tt>)</span>
|
723
|
+
|
724
|
+
|
725
|
+
|
726
|
+
—
|
727
|
+
<div class='inline'>
|
728
|
+
<p>Cookies to parse.</p>
|
729
|
+
</div>
|
730
|
+
|
731
|
+
</li>
|
732
|
+
|
733
|
+
<li>
|
734
|
+
|
735
|
+
<span class='name'>cookie_hash</span>
|
736
|
+
|
737
|
+
|
738
|
+
<span class='type'>(<tt>Hash</tt>)</span>
|
739
|
+
|
740
|
+
|
741
|
+
<em class="default">(defaults to: <tt>{}</tt>)</em>
|
742
|
+
|
743
|
+
|
744
|
+
—
|
745
|
+
<div class='inline'>
|
746
|
+
<p>({}) External hash to store parsed cookies.</p>
|
747
|
+
</div>
|
748
|
+
|
749
|
+
</li>
|
750
|
+
|
751
|
+
</ul>
|
752
|
+
|
753
|
+
<p class="tag_title">Returns:</p>
|
754
|
+
<ul class="return">
|
755
|
+
|
756
|
+
<li>
|
757
|
+
|
758
|
+
|
759
|
+
<span class='type'>(<tt>Hash</tt>)</span>
|
760
|
+
|
761
|
+
|
762
|
+
|
763
|
+
</li>
|
764
|
+
|
765
|
+
</ul>
|
766
|
+
|
767
|
+
</div><table class="source_code">
|
768
|
+
<tr>
|
769
|
+
<td>
|
770
|
+
<pre class="lines">
|
771
|
+
|
772
|
+
|
773
|
+
74
|
774
|
+
75
|
775
|
+
76
|
776
|
+
77
|
777
|
+
78
|
778
|
+
79
|
779
|
+
80
|
780
|
+
81
|
781
|
+
82
|
782
|
+
83
|
783
|
+
84
|
784
|
+
85
|
785
|
+
86
|
786
|
+
87
|
787
|
+
88
|
788
|
+
89
|
789
|
+
90
|
790
|
+
91
|
791
|
+
92
|
792
|
+
93
|
793
|
+
94
|
794
|
+
95
|
795
|
+
96
|
796
|
+
97
|
797
|
+
98
|
798
|
+
99
|
799
|
+
100
|
800
|
+
101
|
801
|
+
102</pre>
|
802
|
+
</td>
|
803
|
+
<td>
|
804
|
+
<pre class="code"><span class="info file"># File 'lib/dh_easy/core/helper/cookie.rb', line 74</span>
|
805
|
+
|
806
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_parse_from_response'>parse_from_response</span> <span class='id identifier rubyid_cookies'>cookies</span><span class='comma'>,</span> <span class='id identifier rubyid_cookie_hash'>cookie_hash</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
|
807
|
+
<span class='comment'># Retrieve from hash
|
808
|
+
</span> <span class='kw'>if</span> <span class='id identifier rubyid_cookies'>cookies</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span> <span class='const'>Hash</span>
|
809
|
+
<span class='id identifier rubyid_cookie_hash'>cookie_hash</span><span class='period'>.</span><span class='id identifier rubyid_merge!'>merge!</span> <span class='id identifier rubyid_cookies'>cookies</span>
|
810
|
+
<span class='kw'>return</span> <span class='id identifier rubyid_cookie_hash'>cookie_hash</span>
|
811
|
+
<span class='kw'>end</span>
|
812
|
+
<span class='comment'># Retrieve from String
|
813
|
+
</span> <span class='id identifier rubyid_cookies'>cookies</span> <span class='op'>=</span> <span class='id identifier rubyid_cookies'>cookies</span><span class='period'>.</span><span class='id identifier rubyid_split'>split</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>; </span><span class='tstring_end'>'</span></span> <span class='kw'>if</span> <span class='id identifier rubyid_cookies'>cookies</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span> <span class='const'>String</span>
|
814
|
+
|
815
|
+
<span class='comment'># Extract from array
|
816
|
+
</span> <span class='id identifier rubyid_info'>info</span> <span class='op'>=</span> <span class='id identifier rubyid_cookie'>cookie</span> <span class='op'>=</span> <span class='id identifier rubyid_expires'>expires</span> <span class='op'>=</span> <span class='id identifier rubyid_key'>key</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='kw'>nil</span>
|
817
|
+
<span class='id identifier rubyid_cookies'>cookies</span><span class='op'>&.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_raw_cookie'>raw_cookie</span><span class='op'>|</span>
|
818
|
+
<span class='comment'># Extract cookie data
|
819
|
+
</span> <span class='id identifier rubyid_key_pair'>key_pair</span> <span class='op'>=</span> <span class='id identifier rubyid_raw_cookie'>raw_cookie</span><span class='period'>.</span><span class='id identifier rubyid_scan'>scan</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>(?:;\s+([^\=]+)=([^;]*))</span><span class='regexp_end'>/i</span></span><span class='rparen'>)</span> <span class='op'>||</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
|
820
|
+
<span class='id identifier rubyid_cookie'>cookie</span> <span class='op'>=</span> <span class='id identifier rubyid_key_pair'>key_pair</span><span class='period'>.</span><span class='id identifier rubyid_inject'>inject</span><span class='lparen'>(</span><span class='const'>Hash</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='rparen'>)</span><span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_h'>h</span><span class='comma'>,</span><span class='id identifier rubyid_i'>i</span><span class='op'>|</span><span class='id identifier rubyid_h'>h</span><span class='lbracket'>[</span><span class='id identifier rubyid_i'>i</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='period'>.</span><span class='id identifier rubyid_downcase'>downcase</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_i'>i</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span><span class='semicolon'>;</span> <span class='id identifier rubyid_h'>h</span><span class='rbrace'>}</span>
|
821
|
+
<span class='id identifier rubyid_cookie'>cookie</span><span class='lbracket'>[</span><span class='symbol'>:key</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_cookie'>cookie</span><span class='lbracket'>[</span><span class='symbol'>:value</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_raw_cookie'>raw_cookie</span><span class='period'>.</span><span class='id identifier rubyid_match'>match</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>^\s*(?<key>[^\=]+)\=(?<value>[^;]*)</span><span class='regexp_end'>/i</span></span><span class='rparen'>)</span><span class='op'>&.</span><span class='id identifier rubyid_captures'>captures</span>
|
822
|
+
|
823
|
+
<span class='comment'># Check cookie expire
|
824
|
+
</span> <span class='id identifier rubyid_expires'>expires</span> <span class='op'>=</span> <span class='id identifier rubyid_cookie'>cookie</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>expires</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> <span class='op'>?</span> <span class='kw'>nil</span> <span class='op'>:</span> <span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_parse'>parse</span><span class='lparen'>(</span><span class='id identifier rubyid_cookie'>cookie</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>expires</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span><span class='rparen'>)</span>
|
825
|
+
<span class='kw'>if</span> <span class='op'>!</span><span class='id identifier rubyid_expires'>expires</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> <span class='op'>&&</span> <span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_now'>now</span> <span class='op'>></span> <span class='id identifier rubyid_expires'>expires</span>
|
826
|
+
<span class='id identifier rubyid_cookie_hash'>cookie_hash</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span> <span class='id identifier rubyid_cookie'>cookie</span><span class='lbracket'>[</span><span class='symbol'>:key</span><span class='rbracket'>]</span>
|
827
|
+
<span class='kw'>next</span>
|
828
|
+
<span class='kw'>end</span>
|
829
|
+
|
830
|
+
<span class='comment'># Save cookie
|
831
|
+
</span> <span class='id identifier rubyid_cookie_hash'>cookie_hash</span><span class='lbracket'>[</span><span class='id identifier rubyid_cookie'>cookie</span><span class='lbracket'>[</span><span class='symbol'>:key</span><span class='rbracket'>]</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_cookie'>cookie</span><span class='lbracket'>[</span><span class='symbol'>:value</span><span class='rbracket'>]</span>
|
832
|
+
<span class='kw'>end</span>
|
833
|
+
<span class='id identifier rubyid_cookie_hash'>cookie_hash</span>
|
834
|
+
<span class='kw'>end</span></pre>
|
835
|
+
</td>
|
836
|
+
</tr>
|
837
|
+
</table>
|
838
|
+
</div>
|
839
|
+
|
840
|
+
<div class="method_details ">
|
841
|
+
<h3 class="signature " id="update-class_method">
|
842
|
+
|
843
|
+
.<strong>update</strong>(request_cookies, response_cookies) ⇒ <tt>String</tt>
|
844
|
+
|
845
|
+
|
846
|
+
|
847
|
+
|
848
|
+
|
849
|
+
</h3><div class="docstring">
|
850
|
+
<div class="discussion">
|
851
|
+
|
852
|
+
<p>Apply request and response cookies as a string with request format.</p>
|
853
|
+
|
854
|
+
|
855
|
+
</div>
|
856
|
+
</div>
|
857
|
+
<div class="tags">
|
858
|
+
|
859
|
+
<div class="examples">
|
860
|
+
<p class="tag_title">Examples:</p>
|
861
|
+
|
862
|
+
|
863
|
+
<pre class="example code"><code>request_cookies = 'aaa=111; ddd=444'
|
864
|
+
response_cookies = [
|
865
|
+
'aaa=111; Expires=Thu, Jan 01 1970 00:00:00 UTC; path=/',
|
866
|
+
'bbb=222; path=/',
|
867
|
+
'ccc=333; path=/; expires=Wed, Jan 01 3000 00:00:00 UTC'
|
868
|
+
]
|
869
|
+
update_as_hash , response_cookies
|
870
|
+
# => 'bbb=222; ccc=333; ddd=444'</code></pre>
|
871
|
+
|
872
|
+
</div>
|
873
|
+
<p class="tag_title">Parameters:</p>
|
874
|
+
<ul class="param">
|
875
|
+
|
876
|
+
<li>
|
877
|
+
|
878
|
+
<span class='name'>request_cookies</span>
|
879
|
+
|
880
|
+
|
881
|
+
<span class='type'>(<tt>String</tt>, <tt>Array</tt>, <tt>Hash</tt>)</span>
|
882
|
+
|
883
|
+
|
884
|
+
|
885
|
+
—
|
886
|
+
<div class='inline'>
|
887
|
+
<p>Cookies to parse.</p>
|
888
|
+
</div>
|
889
|
+
|
890
|
+
</li>
|
891
|
+
|
892
|
+
<li>
|
893
|
+
|
894
|
+
<span class='name'>response_cookies</span>
|
895
|
+
|
896
|
+
|
897
|
+
<span class='type'>(<tt>String</tt>, <tt>Array</tt>, <tt>Hash</tt>)</span>
|
898
|
+
|
899
|
+
|
900
|
+
|
901
|
+
—
|
902
|
+
<div class='inline'>
|
903
|
+
<p>Cookies to parse.</p>
|
904
|
+
</div>
|
905
|
+
|
906
|
+
</li>
|
907
|
+
|
908
|
+
</ul>
|
909
|
+
|
910
|
+
<p class="tag_title">Returns:</p>
|
911
|
+
<ul class="return">
|
912
|
+
|
913
|
+
<li>
|
914
|
+
|
915
|
+
|
916
|
+
<span class='type'>(<tt>String</tt>)</span>
|
917
|
+
|
918
|
+
|
919
|
+
|
920
|
+
</li>
|
921
|
+
|
922
|
+
</ul>
|
923
|
+
|
924
|
+
</div><table class="source_code">
|
925
|
+
<tr>
|
926
|
+
<td>
|
927
|
+
<pre class="lines">
|
928
|
+
|
929
|
+
|
930
|
+
160
|
931
|
+
161
|
932
|
+
162
|
933
|
+
163</pre>
|
934
|
+
</td>
|
935
|
+
<td>
|
936
|
+
<pre class="code"><span class="info file"># File 'lib/dh_easy/core/helper/cookie.rb', line 160</span>
|
937
|
+
|
938
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_update'>update</span> <span class='id identifier rubyid_request_cookies'>request_cookies</span><span class='comma'>,</span> <span class='id identifier rubyid_response_cookies'>response_cookies</span>
|
939
|
+
<span class='id identifier rubyid_cookie_hash'>cookie_hash</span> <span class='op'>=</span> <span class='id identifier rubyid_update_as_hash'>update_as_hash</span> <span class='id identifier rubyid_request_cookies'>request_cookies</span><span class='comma'>,</span> <span class='id identifier rubyid_response_cookies'>response_cookies</span>
|
940
|
+
<span class='id identifier rubyid_encode_to_header'>encode_to_header</span> <span class='id identifier rubyid_cookie_hash'>cookie_hash</span>
|
941
|
+
<span class='kw'>end</span></pre>
|
942
|
+
</td>
|
943
|
+
</tr>
|
944
|
+
</table>
|
945
|
+
</div>
|
946
|
+
|
947
|
+
<div class="method_details ">
|
948
|
+
<h3 class="signature " id="update_as_hash-class_method">
|
949
|
+
|
950
|
+
.<strong>update_as_hash</strong>(request_cookies, response_cookies) ⇒ <tt>Hash</tt>
|
951
|
+
|
952
|
+
|
953
|
+
|
954
|
+
|
955
|
+
|
956
|
+
</h3><div class="docstring">
|
957
|
+
<div class="discussion">
|
958
|
+
|
959
|
+
<p>Apply request and response cookies as a hash.</p>
|
960
|
+
|
961
|
+
|
962
|
+
</div>
|
963
|
+
</div>
|
964
|
+
<div class="tags">
|
965
|
+
|
966
|
+
<div class="examples">
|
967
|
+
<p class="tag_title">Examples:</p>
|
968
|
+
|
969
|
+
|
970
|
+
<pre class="example code"><code>request_cookies = 'aaa=111; ddd=444'
|
971
|
+
response_cookies = [
|
972
|
+
'aaa=111; Expires=Thu, Jan 01 1970 00:00:00 UTC; path=/',
|
973
|
+
'bbb=222; path=/',
|
974
|
+
'ccc=333; path=/; expires=Wed, Jan 01 3000 00:00:00 UTC'
|
975
|
+
]
|
976
|
+
update_as_hash , response_cookies
|
977
|
+
# => {'bbb' => 222, 'ccc' => 333, 'ddd' => 444}</code></pre>
|
978
|
+
|
979
|
+
</div>
|
980
|
+
<p class="tag_title">Parameters:</p>
|
981
|
+
<ul class="param">
|
982
|
+
|
983
|
+
<li>
|
984
|
+
|
985
|
+
<span class='name'>request_cookies</span>
|
986
|
+
|
987
|
+
|
988
|
+
<span class='type'>(<tt>String</tt>, <tt>Array</tt>, <tt>Hash</tt>)</span>
|
989
|
+
|
990
|
+
|
991
|
+
|
992
|
+
—
|
993
|
+
<div class='inline'>
|
994
|
+
<p>Cookies to parse.</p>
|
995
|
+
</div>
|
996
|
+
|
997
|
+
</li>
|
998
|
+
|
999
|
+
<li>
|
1000
|
+
|
1001
|
+
<span class='name'>response_cookies</span>
|
1002
|
+
|
1003
|
+
|
1004
|
+
<span class='type'>(<tt>String</tt>, <tt>Array</tt>, <tt>Hash</tt>)</span>
|
1005
|
+
|
1006
|
+
|
1007
|
+
|
1008
|
+
—
|
1009
|
+
<div class='inline'>
|
1010
|
+
<p>Cookies to parse.</p>
|
1011
|
+
</div>
|
1012
|
+
|
1013
|
+
</li>
|
1014
|
+
|
1015
|
+
</ul>
|
1016
|
+
|
1017
|
+
<p class="tag_title">Returns:</p>
|
1018
|
+
<ul class="return">
|
1019
|
+
|
1020
|
+
<li>
|
1021
|
+
|
1022
|
+
|
1023
|
+
<span class='type'>(<tt>Hash</tt>)</span>
|
1024
|
+
|
1025
|
+
|
1026
|
+
|
1027
|
+
</li>
|
1028
|
+
|
1029
|
+
</ul>
|
1030
|
+
|
1031
|
+
</div><table class="source_code">
|
1032
|
+
<tr>
|
1033
|
+
<td>
|
1034
|
+
<pre class="lines">
|
1035
|
+
|
1036
|
+
|
1037
|
+
120
|
1038
|
+
121
|
1039
|
+
122
|
1040
|
+
123
|
1041
|
+
124
|
1042
|
+
125</pre>
|
1043
|
+
</td>
|
1044
|
+
<td>
|
1045
|
+
<pre class="code"><span class="info file"># File 'lib/dh_easy/core/helper/cookie.rb', line 120</span>
|
1046
|
+
|
1047
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_update_as_hash'>update_as_hash</span> <span class='id identifier rubyid_request_cookies'>request_cookies</span><span class='comma'>,</span> <span class='id identifier rubyid_response_cookies'>response_cookies</span>
|
1048
|
+
<span class='id identifier rubyid_cookie_hash'>cookie_hash</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
|
1049
|
+
<span class='id identifier rubyid_parse_from_request'>parse_from_request</span> <span class='id identifier rubyid_request_cookies'>request_cookies</span><span class='comma'>,</span> <span class='id identifier rubyid_cookie_hash'>cookie_hash</span>
|
1050
|
+
<span class='id identifier rubyid_parse_from_response'>parse_from_response</span> <span class='id identifier rubyid_response_cookies'>response_cookies</span><span class='comma'>,</span> <span class='id identifier rubyid_cookie_hash'>cookie_hash</span>
|
1051
|
+
<span class='id identifier rubyid_cookie_hash'>cookie_hash</span>
|
1052
|
+
<span class='kw'>end</span></pre>
|
1053
|
+
</td>
|
1054
|
+
</tr>
|
1055
|
+
</table>
|
1056
|
+
</div>
|
1057
|
+
|
1058
|
+
</div>
|
1059
|
+
|
1060
|
+
</div>
|
1061
|
+
|
1062
|
+
<div id="footer">
|
1063
|
+
Generated on Wed Dec 4 23:00:02 2019 by
|
1064
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
1065
|
+
0.9.20 (ruby-2.5.3).
|
1066
|
+
</div>
|
1067
|
+
|
1068
|
+
</div>
|
1069
|
+
</body>
|
1070
|
+
</html>
|