privacy_mask_tools 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +10 -0
- data/doc/PrivacyMaskTools.html +15 -4
- data/doc/PrivacyMaskTools/Base.html +3 -3
- data/doc/PrivacyMaskTools/Matcher.html +468 -41
- data/doc/_index.html +1 -1
- data/doc/file.README.html +14 -1
- data/doc/index.html +14 -1
- data/doc/method_list.html +24 -0
- data/doc/top-level-namespace.html +1 -1
- data/lib/privacy_mask_tools/matcher.rb +86 -17
- data/lib/privacy_mask_tools/version.rb +3 -2
- data/privacy_mask_tools.gemspec +2 -2
- data/spec/privacy_mask_tools/matcher_spec.rb +76 -13
- metadata +9 -8
data/README.markdown
CHANGED
@@ -25,6 +25,16 @@ end</code></pre>
|
|
25
25
|
<pre><code>x = Obj.new
|
26
26
|
x.mobile_number_masking</code></pre>
|
27
27
|
|
28
|
+
## Note on Patches/Pull Requests
|
29
|
+
|
30
|
+
* Fork the project.
|
31
|
+
* Make your feature addition or bug fix.
|
32
|
+
* Add tests for it. This is important so I don't break it in a
|
33
|
+
future version unintentionally.
|
34
|
+
* Commit, do not mess with rakefile, version, or history.
|
35
|
+
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
36
|
+
* Send me a pull request. Bonus points for topic branches.
|
37
|
+
|
28
38
|
## Copyright
|
29
39
|
|
30
40
|
Copyright (c) 2011 NAMAKESUGI, released under the MIT license
|
data/doc/PrivacyMaskTools.html
CHANGED
@@ -77,7 +77,18 @@
|
|
77
77
|
</dl>
|
78
78
|
<div class="clear"></div>
|
79
79
|
|
80
|
-
<h2>
|
80
|
+
<h2>Overview</h2><div class="docstring">
|
81
|
+
<div class="discussion">
|
82
|
+
<p>
|
83
|
+
VERSION NUMBER
|
84
|
+
</p>
|
85
|
+
|
86
|
+
|
87
|
+
</div>
|
88
|
+
</div>
|
89
|
+
<div class="tags">
|
90
|
+
|
91
|
+
</div><h2>Defined Under Namespace</h2>
|
81
92
|
<p class="children">
|
82
93
|
|
83
94
|
|
@@ -98,7 +109,7 @@
|
|
98
109
|
<div class="docstring">
|
99
110
|
<div class="discussion">
|
100
111
|
<p>
|
101
|
-
|
112
|
+
Setted Version Number
|
102
113
|
</p>
|
103
114
|
|
104
115
|
|
@@ -108,7 +119,7 @@ VERSION Number
|
|
108
119
|
|
109
120
|
</div>
|
110
121
|
</dt>
|
111
|
-
<dd><pre class="code"><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>0.1.
|
122
|
+
<dd><pre class="code"><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>0.1.3</span><span class='tstring_end'>"</span></span></pre></dd>
|
112
123
|
|
113
124
|
</dl>
|
114
125
|
|
@@ -122,7 +133,7 @@ VERSION Number
|
|
122
133
|
</div>
|
123
134
|
|
124
135
|
<div id="footer">
|
125
|
-
Generated on Sat Aug 20
|
136
|
+
Generated on Sat Aug 20 16:40:06 2011 by
|
126
137
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
127
138
|
0.7.2 (ruby-1.9.2).
|
128
139
|
</div>
|
@@ -122,7 +122,7 @@ PrivacyMaskTools::Matcherをincludeしselfで使用できるようにしてい
|
|
122
122
|
|
123
123
|
|
124
124
|
<h3 class="inherited">Constants included from <span class='object_link'><a href="Matcher.html" title="PrivacyMaskTools::Matcher (module)">Matcher</a></span></h3>
|
125
|
-
<p class="inherited"><span class='object_link'><a href="Matcher.html#JARGON_MOBILE_NUMBER_REGEXP-constant" title="PrivacyMaskTools::Matcher::JARGON_MOBILE_NUMBER_REGEXP (constant)">JARGON_MOBILE_NUMBER_REGEXP</a></span>, <span class='object_link'><a href="Matcher.html#MOBILE_NUMBER_REGEXP-constant" title="PrivacyMaskTools::Matcher::MOBILE_NUMBER_REGEXP (constant)">MOBILE_NUMBER_REGEXP</a></span></p>
|
125
|
+
<p class="inherited"><span class='object_link'><a href="Matcher.html#JARGON_MOBILE_NUMBER_REGEXP-constant" title="PrivacyMaskTools::Matcher::JARGON_MOBILE_NUMBER_REGEXP (constant)">JARGON_MOBILE_NUMBER_REGEXP</a></span>, <span class='object_link'><a href="Matcher.html#JARGON_PHONE_NUMBER_REGEXP-constant" title="PrivacyMaskTools::Matcher::JARGON_PHONE_NUMBER_REGEXP (constant)">JARGON_PHONE_NUMBER_REGEXP</a></span>, <span class='object_link'><a href="Matcher.html#MOBILE_NUMBER_REGEXP-constant" title="PrivacyMaskTools::Matcher::MOBILE_NUMBER_REGEXP (constant)">MOBILE_NUMBER_REGEXP</a></span>, <span class='object_link'><a href="Matcher.html#PHONE_NUMBER_REGEXP-constant" title="PrivacyMaskTools::Matcher::PHONE_NUMBER_REGEXP (constant)">PHONE_NUMBER_REGEXP</a></span></p>
|
126
126
|
|
127
127
|
|
128
128
|
|
@@ -139,13 +139,13 @@ PrivacyMaskTools::Matcherをincludeしselfで使用できるようにしてい
|
|
139
139
|
<h2>Method Summary</h2>
|
140
140
|
|
141
141
|
<h3 class="inherited">Methods included from <span class='object_link'><a href="Matcher.html" title="PrivacyMaskTools::Matcher (module)">Matcher</a></span></h3>
|
142
|
-
<p class="inherited"><span class='object_link'><a href="Matcher.html#has_jargon_mobile_number%3F-instance_method" title="PrivacyMaskTools::Matcher#has_jargon_mobile_number? (method)">has_jargon_mobile_number?</a></span>, <span class='object_link'><a href="Matcher.html#has_mobile_number%3F-instance_method" title="PrivacyMaskTools::Matcher#has_mobile_number? (method)">has_mobile_number?</a></span>, <span class='object_link'><a href="Matcher.html#mobile_number_masking-instance_method" title="PrivacyMaskTools::Matcher#mobile_number_masking (method)">mobile_number_masking</a></span></p>
|
142
|
+
<p class="inherited"><span class='object_link'><a href="Matcher.html#has_jargon_mobile_number%3F-instance_method" title="PrivacyMaskTools::Matcher#has_jargon_mobile_number? (method)">has_jargon_mobile_number?</a></span>, <span class='object_link'><a href="Matcher.html#has_jargon_phone_number%3F-instance_method" title="PrivacyMaskTools::Matcher#has_jargon_phone_number? (method)">has_jargon_phone_number?</a></span>, <span class='object_link'><a href="Matcher.html#has_mobile_number%3F-instance_method" title="PrivacyMaskTools::Matcher#has_mobile_number? (method)">has_mobile_number?</a></span>, <span class='object_link'><a href="Matcher.html#has_phone_number%3F-instance_method" title="PrivacyMaskTools::Matcher#has_phone_number? (method)">has_phone_number?</a></span>, <span class='object_link'><a href="Matcher.html#mobile_number_masking-instance_method" title="PrivacyMaskTools::Matcher#mobile_number_masking (method)">mobile_number_masking</a></span>, <span class='object_link'><a href="Matcher.html#phone_nomber_masking-instance_method" title="PrivacyMaskTools::Matcher#phone_nomber_masking (method)">phone_nomber_masking</a></span></p>
|
143
143
|
|
144
144
|
|
145
145
|
</div>
|
146
146
|
|
147
147
|
<div id="footer">
|
148
|
-
Generated on Sat Aug 20
|
148
|
+
Generated on Sat Aug 20 16:40:06 2011 by
|
149
149
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
150
150
|
0.7.2 (ruby-1.9.2).
|
151
151
|
</div>
|
@@ -81,7 +81,18 @@
|
|
81
81
|
</dl>
|
82
82
|
<div class="clear"></div>
|
83
83
|
|
84
|
+
<h2>Overview</h2><div class="docstring">
|
85
|
+
<div class="discussion">
|
86
|
+
<p>
|
87
|
+
個人情報Matcher 判定・マスキング・抽出の3つの機能を保持しています
|
88
|
+
</p>
|
84
89
|
|
90
|
+
|
91
|
+
</div>
|
92
|
+
</div>
|
93
|
+
<div class="tags">
|
94
|
+
|
95
|
+
</div>
|
85
96
|
<h2>Constant Summary</h2>
|
86
97
|
|
87
98
|
<dl class="constants">
|
@@ -90,7 +101,7 @@
|
|
90
101
|
<div class="docstring">
|
91
102
|
<div class="discussion">
|
92
103
|
<p>
|
93
|
-
|
104
|
+
携帯番号+IPフォン ソフト判定用正規表現
|
94
105
|
</p>
|
95
106
|
|
96
107
|
|
@@ -100,13 +111,29 @@
|
|
100
111
|
|
101
112
|
</div>
|
102
113
|
</dt>
|
103
|
-
<dd><pre class="code"><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>(([00][7-97-9][00])[-ー)
|
114
|
+
<dd><pre class="code"><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>([((]?([00][557-97-9][00])[-ー()()・ ]*([0-90-9]{4})[-ー()()・ ]*([0-90-9]{4})(?![0-90-9]))</span><span class='regexp_end'>/</span></span></pre></dd>
|
104
115
|
|
105
116
|
<dt id="JARGON_MOBILE_NUMBER_REGEXP-constant" class="">JARGON_MOBILE_NUMBER_REGEXP =
|
106
117
|
<div class="docstring">
|
107
118
|
<div class="discussion">
|
108
119
|
<p>
|
109
|
-
|
120
|
+
携帯番号+IPフォン ハード判定用正規表現
|
121
|
+
</p>
|
122
|
+
|
123
|
+
|
124
|
+
</div>
|
125
|
+
</div>
|
126
|
+
<div class="tags">
|
127
|
+
|
128
|
+
</div>
|
129
|
+
</dt>
|
130
|
+
<dd><pre class="code"><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>([((]?([00oO〇十]?[55⑤五7-97-9⑦-⑨七-九][00十〇])[-ー()()・ ]*([0-90-9oO①-⑨一-四〇壱弐参]{4})[-ー()()・ ]*([0-90-9oO①-⑨一-四〇壱弐参]{4})(?![0-90-9]))</span><span class='regexp_end'>/</span></span></pre></dd>
|
131
|
+
|
132
|
+
<dt id="PHONE_NUMBER_REGEXP-constant" class="">PHONE_NUMBER_REGEXP =
|
133
|
+
<div class="docstring">
|
134
|
+
<div class="discussion">
|
135
|
+
<p>
|
136
|
+
固定電話 ソフト判定用正規表現
|
110
137
|
</p>
|
111
138
|
|
112
139
|
|
@@ -116,7 +143,23 @@
|
|
116
143
|
|
117
144
|
</div>
|
118
145
|
</dt>
|
119
|
-
<dd><pre class="code"><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>(([00
|
146
|
+
<dd><pre class="code"><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>([((]?(([00][334466])[-ー()()・ ]*([0-90-9]{4})|([00][1-91-9]{2})[-ー()()・ ]*([0-90-9]{3})|([00][1-91-9]{2}[0-90-9])[-ー()()・ ]*([0-90-9]{2})|([00][1-91-9]{2}[0-90-9]{2})[-ー()()・ ]*([0-90-9]))[-ー()()・ ]*([0-90-9]{4})(?![0-90-9]))</span><span class='regexp_end'>/</span></span></pre></dd>
|
147
|
+
|
148
|
+
<dt id="JARGON_PHONE_NUMBER_REGEXP-constant" class="">JARGON_PHONE_NUMBER_REGEXP =
|
149
|
+
<div class="docstring">
|
150
|
+
<div class="discussion">
|
151
|
+
<p>
|
152
|
+
固定電話 ハード判定用正規表現
|
153
|
+
</p>
|
154
|
+
|
155
|
+
|
156
|
+
</div>
|
157
|
+
</div>
|
158
|
+
<div class="tags">
|
159
|
+
|
160
|
+
</div>
|
161
|
+
</dt>
|
162
|
+
<dd><pre class="code"><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>([((]?(([00oO〇十][33三参③44四④66六⑥])[-ー()()・ ]*([0-90-9oO①-⑨一-四〇壱弐参]{4})|([00oO〇十][1-91-9一-九四①-⑨壱弐参]{2})[-ー()()・ ]*([0-90-9oO①-⑨一-四〇壱弐参]{3})|([00oO〇十][1-91-9一-九四①-⑨壱弐参]{2}[0-90-9oO①-⑨一-四〇壱弐参])[-ー()()・ ]*([0-90-9oO①-⑨一-四〇壱弐参]{2})|([00oO〇十][1-91-9一-九四①-⑨壱弐参]{2}[0-90-9oO①-⑨一-四〇壱弐参]{2})[-ー()()・ ]*([0-90-9oO①-⑨一-四〇壱弐参]))[-ー()()・ ]*([0-90-9oO①-⑨一-四〇壱弐参]{4})(?![0-90-9]))</span><span class='regexp_end'>/</span></span></pre></dd>
|
120
163
|
|
121
164
|
</dl>
|
122
165
|
|
@@ -154,6 +197,30 @@
|
|
154
197
|
</p>
|
155
198
|
</div></span>
|
156
199
|
|
200
|
+
</li>
|
201
|
+
|
202
|
+
|
203
|
+
<li class="public ">
|
204
|
+
<span class="summary_signature">
|
205
|
+
|
206
|
+
<a href="#has_jargon_phone_number%3F-instance_method" title="#has_jargon_phone_number? (instance method)">- (Boolean) <strong>has_jargon_phone_number?</strong>(text) </a>
|
207
|
+
|
208
|
+
|
209
|
+
|
210
|
+
</span>
|
211
|
+
|
212
|
+
|
213
|
+
|
214
|
+
|
215
|
+
|
216
|
+
|
217
|
+
|
218
|
+
|
219
|
+
<span class="summary_desc"><div class='inline'><p>
|
220
|
+
固定電話番号が含まれているかチェックします.
|
221
|
+
</p>
|
222
|
+
</div></span>
|
223
|
+
|
157
224
|
</li>
|
158
225
|
|
159
226
|
|
@@ -184,7 +251,31 @@
|
|
184
251
|
<li class="public ">
|
185
252
|
<span class="summary_signature">
|
186
253
|
|
187
|
-
<a href="#
|
254
|
+
<a href="#has_phone_number%3F-instance_method" title="#has_phone_number? (instance method)">- (Boolean) <strong>has_phone_number?</strong>(text, jargon = false) </a>
|
255
|
+
|
256
|
+
|
257
|
+
|
258
|
+
</span>
|
259
|
+
|
260
|
+
|
261
|
+
|
262
|
+
|
263
|
+
|
264
|
+
|
265
|
+
|
266
|
+
|
267
|
+
<span class="summary_desc"><div class='inline'><p>
|
268
|
+
固定電話番号が含まれているかチェックします.
|
269
|
+
</p>
|
270
|
+
</div></span>
|
271
|
+
|
272
|
+
</li>
|
273
|
+
|
274
|
+
|
275
|
+
<li class="public ">
|
276
|
+
<span class="summary_signature">
|
277
|
+
|
278
|
+
<a href="#mobile_number_masking-instance_method" title="#mobile_number_masking (instance method)">- (String) <strong>mobile_number_masking</strong>(text, word = "*", jargon = false) </a>
|
188
279
|
|
189
280
|
|
190
281
|
|
@@ -202,6 +293,30 @@
|
|
202
293
|
</p>
|
203
294
|
</div></span>
|
204
295
|
|
296
|
+
</li>
|
297
|
+
|
298
|
+
|
299
|
+
<li class="public ">
|
300
|
+
<span class="summary_signature">
|
301
|
+
|
302
|
+
<a href="#phone_nomber_masking-instance_method" title="#phone_nomber_masking (instance method)">- (String) <strong>phone_nomber_masking</strong>(text, word = "*", jargon = false) </a>
|
303
|
+
|
304
|
+
|
305
|
+
|
306
|
+
</span>
|
307
|
+
|
308
|
+
|
309
|
+
|
310
|
+
|
311
|
+
|
312
|
+
|
313
|
+
|
314
|
+
|
315
|
+
<span class="summary_desc"><div class='inline'><p>
|
316
|
+
固定電話らしき箇所をマスキングします.
|
317
|
+
</p>
|
318
|
+
</div></span>
|
319
|
+
|
205
320
|
</li>
|
206
321
|
|
207
322
|
|
@@ -227,9 +342,9 @@
|
|
227
342
|
携帯番号が含まれているかチェックします
|
228
343
|
</p>
|
229
344
|
<pre class="code">
|
230
|
-
|
231
|
-
|
232
|
-
|
345
|
+
隠語らしきもの(漢数字・丸付き数字・〇など)も判定します
|
346
|
+
そのため正常な文字列も置換する確率が高くなります
|
347
|
+
現時点ではテストが不十分です</pre>
|
233
348
|
|
234
349
|
|
235
350
|
</div>
|
@@ -276,12 +391,12 @@
|
|
276
391
|
<pre class="lines">
|
277
392
|
|
278
393
|
|
279
|
-
|
280
|
-
|
281
|
-
|
394
|
+
41
|
395
|
+
42
|
396
|
+
43</pre>
|
282
397
|
</td>
|
283
398
|
<td>
|
284
|
-
<pre class="code"><span class="info file"># File 'lib/privacy_mask_tools/matcher.rb', line
|
399
|
+
<pre class="code"><span class="info file"># File 'lib/privacy_mask_tools/matcher.rb', line 41</span>
|
285
400
|
|
286
401
|
<span class='kw'>def</span> <span class='id has_jargon_mobile_number?'>has_jargon_mobile_number?</span><span class='lparen'>(</span><span class='id text'>text</span><span class='rparen'>)</span>
|
287
402
|
<span class='id has_mobile_number?'>has_mobile_number?</span><span class='lparen'>(</span><span class='id text'>text</span><span class='comma'>,</span><span class='kw'>true</span><span class='rparen'>)</span>
|
@@ -289,6 +404,82 @@
|
|
289
404
|
</td>
|
290
405
|
</tr>
|
291
406
|
</table>
|
407
|
+
</div>
|
408
|
+
|
409
|
+
<div class="method_details ">
|
410
|
+
<p class="signature " id="has_jargon_phone_number?-instance_method">
|
411
|
+
|
412
|
+
- (<tt>Boolean</tt>) <strong>has_jargon_phone_number?</strong>(text)
|
413
|
+
|
414
|
+
|
415
|
+
|
416
|
+
</p><div class="docstring">
|
417
|
+
<div class="discussion">
|
418
|
+
<p>
|
419
|
+
固定電話番号が含まれているかチェックします
|
420
|
+
</p>
|
421
|
+
<p>
|
422
|
+
基本的な仕様はhas_jargon_mobile_number?と同一です
|
423
|
+
</p>
|
424
|
+
|
425
|
+
|
426
|
+
</div>
|
427
|
+
</div>
|
428
|
+
<div class="tags">
|
429
|
+
<h3>Parameters:</h3>
|
430
|
+
<ul class="param">
|
431
|
+
|
432
|
+
<li>
|
433
|
+
|
434
|
+
<span class='name'>チェック対象の文字列</span>
|
435
|
+
|
436
|
+
|
437
|
+
<span class='type'>(<tt>String</tt>)</span>
|
438
|
+
|
439
|
+
|
440
|
+
|
441
|
+
</li>
|
442
|
+
|
443
|
+
</ul>
|
444
|
+
<h3>Returns:</h3>
|
445
|
+
<ul class="return">
|
446
|
+
|
447
|
+
<li>
|
448
|
+
|
449
|
+
|
450
|
+
<span class='type'>(<tt>Boolean</tt>)</span>
|
451
|
+
|
452
|
+
|
453
|
+
|
454
|
+
—
|
455
|
+
<div class='inline'><p>
|
456
|
+
含まれている場合 true 含まれていない場合 false
|
457
|
+
</p>
|
458
|
+
</div>
|
459
|
+
|
460
|
+
</li>
|
461
|
+
|
462
|
+
</ul>
|
463
|
+
|
464
|
+
</div><table class="source_code">
|
465
|
+
<tr>
|
466
|
+
<td>
|
467
|
+
<pre class="lines">
|
468
|
+
|
469
|
+
|
470
|
+
65
|
471
|
+
66
|
472
|
+
67</pre>
|
473
|
+
</td>
|
474
|
+
<td>
|
475
|
+
<pre class="code"><span class="info file"># File 'lib/privacy_mask_tools/matcher.rb', line 65</span>
|
476
|
+
|
477
|
+
<span class='kw'>def</span> <span class='id has_jargon_phone_number?'>has_jargon_phone_number?</span><span class='lparen'>(</span><span class='id text'>text</span><span class='rparen'>)</span>
|
478
|
+
<span class='id has_phone_number?'>has_phone_number?</span><span class='lparen'>(</span><span class='id text'>text</span><span class='comma'>,</span> <span class='kw'>true</span><span class='rparen'>)</span>
|
479
|
+
<span class='kw'>end</span></pre>
|
480
|
+
</td>
|
481
|
+
</tr>
|
482
|
+
</table>
|
292
483
|
</div>
|
293
484
|
|
294
485
|
<div class="method_details ">
|
@@ -304,7 +495,10 @@
|
|
304
495
|
携帯番号が含まれているかチェックします
|
305
496
|
</p>
|
306
497
|
<pre class="code">
|
307
|
-
|
498
|
+
jargonをfalseにした場合は判定条件はゆるめです
|
499
|
+
そのため、漢数字や丸数字はパスしてしまいます
|
500
|
+
ただし、セパレータ部分は強めの制限となっており、スペースも許容しています
|
501
|
+
そのため"000 9999 9999"もマッチします</pre>
|
308
502
|
|
309
503
|
|
310
504
|
</div>
|
@@ -362,13 +556,13 @@
|
|
362
556
|
<pre class="lines">
|
363
557
|
|
364
558
|
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
559
|
+
28
|
560
|
+
29
|
561
|
+
30
|
562
|
+
31</pre>
|
369
563
|
</td>
|
370
564
|
<td>
|
371
|
-
<pre class="code"><span class="info file"># File 'lib/privacy_mask_tools/matcher.rb', line
|
565
|
+
<pre class="code"><span class="info file"># File 'lib/privacy_mask_tools/matcher.rb', line 28</span>
|
372
566
|
|
373
567
|
<span class='kw'>def</span> <span class='id has_mobile_number?'>has_mobile_number?</span><span class='lparen'>(</span><span class='id text'>text</span><span class='comma'>,</span> <span class='id jargon'>jargon</span><span class='op'>=</span><span class='kw'>false</span><span class='rparen'>)</span>
|
374
568
|
<span class='id reg'>reg</span> <span class='op'>=</span> <span class='id jargon'>jargon</span> <span class='op'>?</span> <span class='const'>JARGON_MOBILE_NUMBER_REGEXP</span> <span class='op'>:</span> <span class='const'>MOBILE_NUMBER_REGEXP</span>
|
@@ -377,12 +571,101 @@
|
|
377
571
|
</td>
|
378
572
|
</tr>
|
379
573
|
</table>
|
574
|
+
</div>
|
575
|
+
|
576
|
+
<div class="method_details ">
|
577
|
+
<p class="signature " id="has_phone_number?-instance_method">
|
578
|
+
|
579
|
+
- (<tt>Boolean</tt>) <strong>has_phone_number?</strong>(text, jargon = false)
|
580
|
+
|
581
|
+
|
582
|
+
|
583
|
+
</p><div class="docstring">
|
584
|
+
<div class="discussion">
|
585
|
+
<p>
|
586
|
+
固定電話番号が含まれているかチェックします
|
587
|
+
</p>
|
588
|
+
<p>
|
589
|
+
基本的な仕様はhas_mobile_number?と同一です
|
590
|
+
</p>
|
591
|
+
|
592
|
+
|
593
|
+
</div>
|
594
|
+
</div>
|
595
|
+
<div class="tags">
|
596
|
+
<h3>Parameters:</h3>
|
597
|
+
<ul class="param">
|
598
|
+
|
599
|
+
<li>
|
600
|
+
|
601
|
+
<span class='name'>チェック対象の文字列</span>
|
602
|
+
|
603
|
+
|
604
|
+
<span class='type'>(<tt>String</tt>)</span>
|
605
|
+
|
606
|
+
|
607
|
+
|
608
|
+
</li>
|
609
|
+
|
610
|
+
<li>
|
611
|
+
|
612
|
+
<span class='name'></span>
|
613
|
+
|
614
|
+
|
615
|
+
<span class='type'>(<tt>Boolean</tt>)</span>
|
616
|
+
|
617
|
+
|
618
|
+
|
619
|
+
</li>
|
620
|
+
|
621
|
+
</ul>
|
622
|
+
<h3>Returns:</h3>
|
623
|
+
<ul class="return">
|
624
|
+
|
625
|
+
<li>
|
626
|
+
|
627
|
+
|
628
|
+
<span class='type'>(<tt>Boolean</tt>)</span>
|
629
|
+
|
630
|
+
|
631
|
+
|
632
|
+
—
|
633
|
+
<div class='inline'><p>
|
634
|
+
含まれている場合 true 含まれていない場合 false
|
635
|
+
</p>
|
636
|
+
</div>
|
637
|
+
|
638
|
+
</li>
|
639
|
+
|
640
|
+
</ul>
|
641
|
+
|
642
|
+
</div><table class="source_code">
|
643
|
+
<tr>
|
644
|
+
<td>
|
645
|
+
<pre class="lines">
|
646
|
+
|
647
|
+
|
648
|
+
53
|
649
|
+
54
|
650
|
+
55
|
651
|
+
56</pre>
|
652
|
+
</td>
|
653
|
+
<td>
|
654
|
+
<pre class="code"><span class="info file"># File 'lib/privacy_mask_tools/matcher.rb', line 53</span>
|
655
|
+
|
656
|
+
<span class='kw'>def</span> <span class='id has_phone_number?'>has_phone_number?</span><span class='lparen'>(</span><span class='id text'>text</span><span class='comma'>,</span> <span class='id jargon'>jargon</span><span class='op'>=</span><span class='kw'>false</span><span class='rparen'>)</span>
|
657
|
+
<span class='id reg'>reg</span> <span class='op'>=</span> <span class='id jargon'>jargon</span> <span class='op'>?</span> <span class='const'>JARGON_PHONE_NUMBER_REGEXP</span> <span class='op'>:</span> <span class='const'>PHONE_NUMBER_REGEXP</span>
|
658
|
+
<span class='op'>!</span><span class='id text'>text</span><span class='period'>.</span><span class='id match'>match</span><span class='lparen'>(</span><span class='id reg'>reg</span><span class='rparen'>)</span><span class='period'>.</span><span class='id tapp'>tapp</span><span class='period'>.</span><span class='id nil?'>nil?</span>
|
659
|
+
<span class='kw'>end</span></pre>
|
660
|
+
</td>
|
661
|
+
</tr>
|
662
|
+
</table>
|
380
663
|
</div>
|
381
664
|
|
382
665
|
<div class="method_details ">
|
383
666
|
<p class="signature " id="mobile_number_masking-instance_method">
|
384
667
|
|
385
|
-
- (<tt>String</tt>) <strong>mobile_number_masking</strong>(text,
|
668
|
+
- (<tt>String</tt>) <strong>mobile_number_masking</strong>(text, word = "*", jargon = false)
|
386
669
|
|
387
670
|
|
388
671
|
|
@@ -391,6 +674,9 @@
|
|
391
674
|
<p>
|
392
675
|
携帯番号らしき箇所をマスキングします
|
393
676
|
</p>
|
677
|
+
<pre class="code">
|
678
|
+
<span class='id wordに2文字以上を与えるとマッチした部分をその2文字で置き換えます'>wordに2文字以上を与えるとマッチした部分をその2文字で置き換えます</span>
|
679
|
+
<span class='id wordが1文字だとマッチした部分それぞれの数値をその文字で置き換えます'>wordが1文字だとマッチした部分それぞれの数値をその文字で置き換えます</span></pre>
|
394
680
|
|
395
681
|
|
396
682
|
</div>
|
@@ -401,8 +687,10 @@
|
|
401
687
|
<h3>Examples:</h3>
|
402
688
|
|
403
689
|
<h4><div class='inline'></div></h4>
|
404
|
-
<pre class="example code"
|
405
|
-
|
690
|
+
<pre class="example code">mobile_number_masking("携帯番号 : 080-7900-5678"
|
691
|
+
# => "携帯番号 : xxx-xxxx-xxxx"
|
692
|
+
mobile_number_masking("携帯番号 : 080-7900-5678", "[Tel No]")
|
693
|
+
# => "携帯番号 : [Tel No]"</pre>
|
406
694
|
|
407
695
|
</div>
|
408
696
|
<h3>Parameters:</h3>
|
@@ -468,31 +756,170 @@
|
|
468
756
|
<pre class="lines">
|
469
757
|
|
470
758
|
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
759
|
+
81
|
760
|
+
82
|
761
|
+
83
|
762
|
+
84
|
763
|
+
85
|
764
|
+
86
|
765
|
+
87
|
766
|
+
88
|
767
|
+
89
|
768
|
+
90
|
769
|
+
91
|
770
|
+
92
|
771
|
+
93
|
772
|
+
94
|
773
|
+
95
|
774
|
+
96</pre>
|
483
775
|
</td>
|
484
776
|
<td>
|
485
|
-
<pre class="code"><span class="info file"># File 'lib/privacy_mask_tools/matcher.rb', line
|
777
|
+
<pre class="code"><span class="info file"># File 'lib/privacy_mask_tools/matcher.rb', line 81</span>
|
486
778
|
|
487
|
-
<span class='kw'>def</span> <span class='id mobile_number_masking'>mobile_number_masking</span><span class='lparen'>(</span><span class='id text'>text</span><span class='comma'>,</span> <span class='id
|
779
|
+
<span class='kw'>def</span> <span class='id mobile_number_masking'>mobile_number_masking</span><span class='lparen'>(</span><span class='id text'>text</span><span class='comma'>,</span> <span class='id word'>word</span><span class='op'>=</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='id jargon'>jargon</span><span class='op'>=</span><span class='kw'>false</span><span class='rparen'>)</span>
|
488
780
|
<span class='id reg'>reg</span> <span class='op'>=</span> <span class='id jargon'>jargon</span> <span class='op'>?</span> <span class='const'>JARGON_MOBILE_NUMBER_REGEXP</span> <span class='op'>:</span> <span class='const'>MOBILE_NUMBER_REGEXP</span>
|
489
781
|
<span class='id text'>text</span><span class='period'>.</span><span class='id scan'>scan</span><span class='lparen'>(</span><span class='id reg'>reg</span><span class='rparen'>)</span><span class='period'>.</span><span class='id each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id f'>f</span><span class='op'>|</span>
|
490
|
-
<span class='
|
491
|
-
|
492
|
-
|
493
|
-
<span class='id replace_word'>replace_word</span
|
782
|
+
<span class='kw'>if</span> <span class='id word'>word</span><span class='period'>.</span><span class='id size'>size</span> <span class='op'>>=</span> <span class='int'>2</span>
|
783
|
+
<span class='id text'>text</span> <span class='op'>=</span> <span class='id text'>text</span><span class='period'>.</span><span class='id sub'>sub</span><span class='lparen'>(</span><span class='id f'>f</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id word'>word</span><span class='rparen'>)</span>
|
784
|
+
<span class='kw'>else</span>
|
785
|
+
<span class='id replace_word'>replace_word</span> <span class='op'>=</span> <span class='id f'>f</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id dup'>dup</span>
|
786
|
+
<span class='id f'>f</span><span class='period'>.</span><span class='id each_with_index'>each_with_index</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id g'>g</span><span class='comma'>,</span> <span class='id index'>index</span><span class='op'>|</span>
|
787
|
+
<span class='kw'>next</span> <span class='kw'>if</span> <span class='id index'>index</span> <span class='op'>==</span> <span class='int'>0</span>
|
788
|
+
<span class='id replace_word'>replace_word</span><span class='period'>.</span><span class='id sub!'>sub!</span><span class='lparen'>(</span><span class='id g'>g</span><span class='comma'>,</span> <span class='id word'>word</span><span class='op'>*</span><span class='id g'>g</span><span class='period'>.</span><span class='id size'>size</span><span class='rparen'>)</span>
|
789
|
+
<span class='kw'>end</span>
|
790
|
+
<span class='id text'>text</span> <span class='op'>=</span> <span class='id text'>text</span><span class='period'>.</span><span class='id sub'>sub</span><span class='lparen'>(</span><span class='id f'>f</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id replace_word'>replace_word</span><span class='rparen'>)</span>
|
791
|
+
<span class='kw'>end</span>
|
792
|
+
<span class='kw'>end</span>
|
793
|
+
<span class='id text'>text</span>
|
794
|
+
<span class='kw'>end</span></pre>
|
795
|
+
</td>
|
796
|
+
</tr>
|
797
|
+
</table>
|
798
|
+
</div>
|
799
|
+
|
800
|
+
<div class="method_details ">
|
801
|
+
<p class="signature " id="phone_nomber_masking-instance_method">
|
802
|
+
|
803
|
+
- (<tt>String</tt>) <strong>phone_nomber_masking</strong>(text, word = "*", jargon = false)
|
804
|
+
|
805
|
+
|
806
|
+
|
807
|
+
</p><div class="docstring">
|
808
|
+
<div class="discussion">
|
809
|
+
<p>
|
810
|
+
固定電話らしき箇所をマスキングします
|
811
|
+
</p>
|
812
|
+
<p>
|
813
|
+
基本的な仕様はmobile_number_maskingと同一です
|
814
|
+
</p>
|
815
|
+
|
816
|
+
|
817
|
+
</div>
|
818
|
+
</div>
|
819
|
+
<div class="tags">
|
820
|
+
<h3>Parameters:</h3>
|
821
|
+
<ul class="param">
|
822
|
+
|
823
|
+
<li>
|
824
|
+
|
825
|
+
<span class='name'>マスキング対象の文字列</span>
|
826
|
+
|
827
|
+
|
828
|
+
<span class='type'>(<tt>String</tt>)</span>
|
829
|
+
|
830
|
+
|
831
|
+
|
832
|
+
</li>
|
833
|
+
|
834
|
+
<li>
|
835
|
+
|
836
|
+
<span class='name'>マッチした部分の置換文字</span>
|
837
|
+
|
838
|
+
|
839
|
+
<span class='type'>(<tt>String</tt>)</span>
|
840
|
+
|
841
|
+
|
842
|
+
|
843
|
+
</li>
|
844
|
+
|
845
|
+
<li>
|
846
|
+
|
847
|
+
<span class='name'>隠語判定を強化フラグ</span>
|
848
|
+
|
849
|
+
|
850
|
+
<span class='type'>(<tt>Boolean</tt>)</span>
|
851
|
+
|
852
|
+
|
853
|
+
|
854
|
+
</li>
|
855
|
+
|
856
|
+
</ul>
|
857
|
+
<h3>Returns:</h3>
|
858
|
+
<ul class="return">
|
859
|
+
|
860
|
+
<li>
|
861
|
+
|
862
|
+
|
863
|
+
<span class='type'>(<tt>String</tt>)</span>
|
864
|
+
|
865
|
+
|
866
|
+
|
867
|
+
—
|
868
|
+
<div class='inline'><p>
|
869
|
+
マスキング後の文字列
|
870
|
+
</p>
|
871
|
+
</div>
|
872
|
+
|
873
|
+
</li>
|
874
|
+
|
875
|
+
</ul>
|
876
|
+
|
877
|
+
<h3>See Also:</h3>
|
878
|
+
<ul class="see">
|
879
|
+
|
880
|
+
<li>mobile_number_masking</li>
|
881
|
+
|
882
|
+
</ul>
|
883
|
+
|
884
|
+
</div><table class="source_code">
|
885
|
+
<tr>
|
886
|
+
<td>
|
887
|
+
<pre class="lines">
|
888
|
+
|
889
|
+
|
890
|
+
106
|
891
|
+
107
|
892
|
+
108
|
893
|
+
109
|
894
|
+
110
|
895
|
+
111
|
896
|
+
112
|
897
|
+
113
|
898
|
+
114
|
899
|
+
115
|
900
|
+
116
|
901
|
+
117
|
902
|
+
118
|
903
|
+
119
|
904
|
+
120
|
905
|
+
121</pre>
|
906
|
+
</td>
|
907
|
+
<td>
|
908
|
+
<pre class="code"><span class="info file"># File 'lib/privacy_mask_tools/matcher.rb', line 106</span>
|
909
|
+
|
910
|
+
<span class='kw'>def</span> <span class='id phone_nomber_masking'>phone_nomber_masking</span><span class='lparen'>(</span><span class='id text'>text</span><span class='comma'>,</span> <span class='id word'>word</span><span class='op'>=</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='id jargon'>jargon</span><span class='op'>=</span><span class='kw'>false</span><span class='rparen'>)</span>
|
911
|
+
<span class='id reg'>reg</span> <span class='op'>=</span> <span class='id jargon'>jargon</span> <span class='op'>?</span> <span class='const'>JARGON_PHONE_NUMBER_REGEXP</span> <span class='op'>:</span> <span class='const'>PHONE_NUMBER_REGEXP</span>
|
912
|
+
<span class='id text'>text</span><span class='period'>.</span><span class='id scan'>scan</span><span class='lparen'>(</span><span class='id reg'>reg</span><span class='rparen'>)</span><span class='period'>.</span><span class='id tapp'>tapp</span><span class='period'>.</span><span class='id each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id f'>f</span><span class='op'>|</span>
|
913
|
+
<span class='kw'>if</span> <span class='id word'>word</span><span class='period'>.</span><span class='id size'>size</span> <span class='op'>>=</span> <span class='int'>2</span>
|
914
|
+
<span class='id text'>text</span> <span class='op'>=</span> <span class='id text'>text</span><span class='period'>.</span><span class='id sub'>sub</span><span class='lparen'>(</span><span class='id f'>f</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id word'>word</span><span class='rparen'>)</span>
|
915
|
+
<span class='kw'>else</span>
|
916
|
+
<span class='id replace_word'>replace_word</span> <span class='op'>=</span> <span class='id f'>f</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id dup'>dup</span>
|
917
|
+
<span class='id f'>f</span><span class='period'>.</span><span class='id each_with_index'>each_with_index</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id g'>g</span><span class='comma'>,</span> <span class='id index'>index</span><span class='op'>|</span>
|
918
|
+
<span class='kw'>next</span> <span class='kw'>if</span> <span class='id index'>index</span> <span class='op'><=</span> <span class='int'>1</span> <span class='kw'>or</span> <span class='id g'>g</span><span class='period'>.</span><span class='id nil?'>nil?</span>
|
919
|
+
<span class='id replace_word'>replace_word</span><span class='period'>.</span><span class='id sub!'>sub!</span><span class='lparen'>(</span><span class='id g'>g</span><span class='comma'>,</span> <span class='id word'>word</span><span class='op'>*</span><span class='id g'>g</span><span class='period'>.</span><span class='id size'>size</span><span class='rparen'>)</span>
|
920
|
+
<span class='kw'>end</span>
|
921
|
+
<span class='id text'>text</span> <span class='op'>=</span> <span class='id text'>text</span><span class='period'>.</span><span class='id sub'>sub</span><span class='lparen'>(</span><span class='id f'>f</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id replace_word'>replace_word</span><span class='rparen'>)</span>
|
494
922
|
<span class='kw'>end</span>
|
495
|
-
<span class='id text'>text</span> <span class='op'>=</span> <span class='id text'>text</span><span class='period'>.</span><span class='id sub'>sub</span><span class='lparen'>(</span><span class='id f'>f</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id replace_word'>replace_word</span><span class='rparen'>)</span>
|
496
923
|
<span class='kw'>end</span>
|
497
924
|
<span class='id text'>text</span>
|
498
925
|
<span class='kw'>end</span></pre>
|
@@ -506,7 +933,7 @@
|
|
506
933
|
</div>
|
507
934
|
|
508
935
|
<div id="footer">
|
509
|
-
Generated on Sat Aug 20
|
936
|
+
Generated on Sat Aug 20 16:40:06 2011 by
|
510
937
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
511
938
|
0.7.2 (ruby-1.9.2).
|
512
939
|
</div>
|
data/doc/_index.html
CHANGED
@@ -127,7 +127,7 @@
|
|
127
127
|
</div>
|
128
128
|
|
129
129
|
<div id="footer">
|
130
|
-
Generated on Sat Aug 20
|
130
|
+
Generated on Sat Aug 20 16:40:06 2011 by
|
131
131
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
132
132
|
0.7.2 (ruby-1.9.2).
|
133
133
|
</div>
|
data/doc/file.README.html
CHANGED
@@ -88,13 +88,26 @@
|
|
88
88
|
<span class='id x'>x</span><span class='period'>.</span><span class='id mobile_number_masking'>mobile_number_masking</span></pre>
|
89
89
|
|
90
90
|
|
91
|
+
<h2>Note on Patches/Pull Requests</h2>
|
92
|
+
|
93
|
+
<ul>
|
94
|
+
<li>Fork the project.</li>
|
95
|
+
<li>Make your feature addition or bug fix.</li>
|
96
|
+
<li>Add tests for it. This is important so I don't break it in a
|
97
|
+
future version unintentionally.</li>
|
98
|
+
<li>Commit, do not mess with rakefile, version, or history.
|
99
|
+
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)</li>
|
100
|
+
<li>Send me a pull request. Bonus points for topic branches.</li>
|
101
|
+
</ul>
|
102
|
+
|
103
|
+
|
91
104
|
<h2>Copyright</h2>
|
92
105
|
|
93
106
|
<p>Copyright (c) 2011 NAMAKESUGI, released under the MIT license</p>
|
94
107
|
</div></div>
|
95
108
|
|
96
109
|
<div id="footer">
|
97
|
-
Generated on Sat Aug 20
|
110
|
+
Generated on Sat Aug 20 16:40:06 2011 by
|
98
111
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
99
112
|
0.7.2 (ruby-1.9.2).
|
100
113
|
</div>
|
data/doc/index.html
CHANGED
@@ -88,13 +88,26 @@
|
|
88
88
|
<span class='id x'>x</span><span class='period'>.</span><span class='id mobile_number_masking'>mobile_number_masking</span></pre>
|
89
89
|
|
90
90
|
|
91
|
+
<h2>Note on Patches/Pull Requests</h2>
|
92
|
+
|
93
|
+
<ul>
|
94
|
+
<li>Fork the project.</li>
|
95
|
+
<li>Make your feature addition or bug fix.</li>
|
96
|
+
<li>Add tests for it. This is important so I don't break it in a
|
97
|
+
future version unintentionally.</li>
|
98
|
+
<li>Commit, do not mess with rakefile, version, or history.
|
99
|
+
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)</li>
|
100
|
+
<li>Send me a pull request. Bonus points for topic branches.</li>
|
101
|
+
</ul>
|
102
|
+
|
103
|
+
|
91
104
|
<h2>Copyright</h2>
|
92
105
|
|
93
106
|
<p>Copyright (c) 2011 NAMAKESUGI, released under the MIT license</p>
|
94
107
|
</div></div>
|
95
108
|
|
96
109
|
<div id="footer">
|
97
|
-
Generated on Sat Aug 20
|
110
|
+
Generated on Sat Aug 20 16:40:06 2011 by
|
98
111
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
99
112
|
0.7.2 (ruby-1.9.2).
|
100
113
|
</div>
|
data/doc/method_list.html
CHANGED
@@ -49,6 +49,14 @@
|
|
49
49
|
|
50
50
|
|
51
51
|
<li class="r2 ">
|
52
|
+
<span class='object_link'><a href="PrivacyMaskTools/Matcher.html#has_jargon_phone_number%3F-instance_method" title="PrivacyMaskTools::Matcher#has_jargon_phone_number? (method)">#has_jargon_phone_number?</a></span>
|
53
|
+
|
54
|
+
<small>PrivacyMaskTools::Matcher</small>
|
55
|
+
|
56
|
+
</li>
|
57
|
+
|
58
|
+
|
59
|
+
<li class="r1 ">
|
52
60
|
<span class='object_link'><a href="PrivacyMaskTools/Matcher.html#has_mobile_number%3F-instance_method" title="PrivacyMaskTools::Matcher#has_mobile_number? (method)">#has_mobile_number?</a></span>
|
53
61
|
|
54
62
|
<small>PrivacyMaskTools::Matcher</small>
|
@@ -56,6 +64,14 @@
|
|
56
64
|
</li>
|
57
65
|
|
58
66
|
|
67
|
+
<li class="r2 ">
|
68
|
+
<span class='object_link'><a href="PrivacyMaskTools/Matcher.html#has_phone_number%3F-instance_method" title="PrivacyMaskTools::Matcher#has_phone_number? (method)">#has_phone_number?</a></span>
|
69
|
+
|
70
|
+
<small>PrivacyMaskTools::Matcher</small>
|
71
|
+
|
72
|
+
</li>
|
73
|
+
|
74
|
+
|
59
75
|
<li class="r1 ">
|
60
76
|
<span class='object_link'><a href="PrivacyMaskTools/Matcher.html#mobile_number_masking-instance_method" title="PrivacyMaskTools::Matcher#mobile_number_masking (method)">#mobile_number_masking</a></span>
|
61
77
|
|
@@ -64,6 +80,14 @@
|
|
64
80
|
</li>
|
65
81
|
|
66
82
|
|
83
|
+
<li class="r2 ">
|
84
|
+
<span class='object_link'><a href="PrivacyMaskTools/Matcher.html#phone_nomber_masking-instance_method" title="PrivacyMaskTools::Matcher#phone_nomber_masking (method)">#phone_nomber_masking</a></span>
|
85
|
+
|
86
|
+
<small>PrivacyMaskTools::Matcher</small>
|
87
|
+
|
88
|
+
</li>
|
89
|
+
|
90
|
+
|
67
91
|
</ul>
|
68
92
|
</div>
|
69
93
|
</body>
|
@@ -1,55 +1,124 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
|
+
# 個人情報Matcher
|
4
|
+
# 判定・マスキング・抽出の3つの機能を保持しています
|
3
5
|
module PrivacyMaskTools::Matcher
|
4
|
-
#
|
5
|
-
MOBILE_NUMBER_REGEXP = /(([00][7-97-9][00])[-ー)
|
6
|
+
# 携帯番号+IPフォン ソフト判定用正規表現
|
7
|
+
MOBILE_NUMBER_REGEXP = /([((]?([00][557-97-9][00])[-ー()()・ ]*([0-90-9]{4})[-ー()()・ ]*([0-90-9]{4})(?![0-90-9]))/
|
6
8
|
|
7
|
-
#
|
8
|
-
JARGON_MOBILE_NUMBER_REGEXP = /(([00oO〇十]?[7-9
|
9
|
+
# 携帯番号+IPフォン ハード判定用正規表現
|
10
|
+
JARGON_MOBILE_NUMBER_REGEXP = /([((]?([00oO〇十]?[55⑤五7-97-9⑦-⑨七-九][00十〇])[-ー()()・ ]*([0-90-9oO①-⑨一-四〇壱弐参]{4})[-ー()()・ ]*([0-90-9oO①-⑨一-四〇壱弐参]{4})(?![0-90-9]))/
|
11
|
+
|
12
|
+
# 固定電話 ソフト判定用正規表現
|
13
|
+
PHONE_NUMBER_REGEXP = /([((]?(([00][334466])[-ー()()・ ]*([0-90-9]{4})|([00][1-91-9]{2})[-ー()()・ ]*([0-90-9]{3})|([00][1-91-9]{2}[0-90-9])[-ー()()・ ]*([0-90-9]{2})|([00][1-91-9]{2}[0-90-9]{2})[-ー()()・ ]*([0-90-9]))[-ー()()・ ]*([0-90-9]{4})(?![0-90-9]))/
|
14
|
+
|
15
|
+
# 固定電話 ハード判定用正規表現
|
16
|
+
JARGON_PHONE_NUMBER_REGEXP = /([((]?(([00oO〇十][33三参③44四④66六⑥])[-ー()()・ ]*([0-90-9oO①-⑨一-四〇壱弐参]{4})|([00oO〇十][1-91-9一-九四①-⑨壱弐参]{2})[-ー()()・ ]*([0-90-9oO①-⑨一-四〇壱弐参]{3})|([00oO〇十][1-91-9一-九四①-⑨壱弐参]{2}[0-90-9oO①-⑨一-四〇壱弐参])[-ー()()・ ]*([0-90-9oO①-⑨一-四〇壱弐参]{2})|([00oO〇十][1-91-9一-九四①-⑨壱弐参]{2}[0-90-9oO①-⑨一-四〇壱弐参]{2})[-ー()()・ ]*([0-90-9oO①-⑨一-四〇壱弐参]))[-ー()()・ ]*([0-90-9oO①-⑨一-四〇壱弐参]{4})(?![0-90-9]))/
|
9
17
|
|
10
18
|
# 携帯番号が含まれているかチェックします
|
11
|
-
#
|
19
|
+
# jargonをfalseにした場合は判定条件はゆるめです
|
20
|
+
# そのため、漢数字や丸数字はパスしてしまいます
|
21
|
+
# ただし、セパレータ部分は強めの制限となっており、スペースも許容しています
|
22
|
+
# そのため"000 9999 9999"もマッチします
|
12
23
|
# @param [String] チェック対象の文字列
|
13
24
|
# @param [Boolean] 隠語判定強化フラグ(漢数字・丸付き数値にもマッチ)
|
14
25
|
# @return [Boolean]
|
15
|
-
#
|
16
|
-
#
|
26
|
+
# 含まれている場合 true
|
27
|
+
# 含まれていない場合 false
|
17
28
|
def has_mobile_number?(text, jargon=false)
|
18
29
|
reg = jargon ? JARGON_MOBILE_NUMBER_REGEXP : MOBILE_NUMBER_REGEXP
|
19
30
|
!text.match(reg).nil?
|
20
31
|
end
|
21
32
|
|
22
33
|
# 携帯番号が含まれているかチェックします
|
23
|
-
#
|
34
|
+
# 隠語らしきもの(漢数字・丸付き数字・〇など)も判定します
|
24
35
|
# そのため正常な文字列も置換する確率が高くなります
|
25
36
|
# 現時点ではテストが不十分です
|
26
37
|
# @param [String] チェック対象の文字列
|
27
38
|
# @return [Boolean]
|
28
|
-
#
|
29
|
-
#
|
39
|
+
# 含まれている場合 true
|
40
|
+
# 含まれていない場合 false
|
30
41
|
def has_jargon_mobile_number?(text)
|
31
42
|
has_mobile_number?(text,true)
|
32
43
|
end
|
33
44
|
|
45
|
+
# 固定電話番号が含まれているかチェックします
|
46
|
+
#
|
47
|
+
# 基本的な仕様はhas_mobile_number?と同一です
|
48
|
+
# @param [String] チェック対象の文字列
|
49
|
+
# @param [Boolean]
|
50
|
+
# @return [Boolean]
|
51
|
+
# 含まれている場合 true
|
52
|
+
# 含まれていない場合 false
|
53
|
+
def has_phone_number?(text, jargon=false)
|
54
|
+
reg = jargon ? JARGON_PHONE_NUMBER_REGEXP : PHONE_NUMBER_REGEXP
|
55
|
+
!text.match(reg).nil?
|
56
|
+
end
|
57
|
+
|
58
|
+
# 固定電話番号が含まれているかチェックします
|
59
|
+
#
|
60
|
+
# 基本的な仕様はhas_jargon_mobile_number?と同一です
|
61
|
+
# @param [String] チェック対象の文字列
|
62
|
+
# @return [Boolean]
|
63
|
+
# 含まれている場合 true
|
64
|
+
# 含まれていない場合 false
|
65
|
+
def has_jargon_phone_number?(text)
|
66
|
+
has_phone_number?(text, true)
|
67
|
+
end
|
68
|
+
|
34
69
|
# 携帯番号らしき箇所をマスキングします
|
70
|
+
# wordに2文字以上を与えるとマッチした部分をその2文字で置き換えます
|
71
|
+
# wordが1文字だとマッチした部分それぞれの数値をその文字で置き換えます
|
35
72
|
# @param [String] マスキング対象の文字列
|
36
73
|
# @param [String] マッチした部分の置換文字
|
37
74
|
# @param [Boolean] 隠語判定を強化フラグ
|
38
75
|
# @return [String] マスキング後の文字列
|
39
76
|
# @example
|
40
|
-
# mobile_number_masking("携帯番号 :
|
77
|
+
# mobile_number_masking("携帯番号 : 080-7900-5678"
|
41
78
|
# # => "携帯番号 : xxx-xxxx-xxxx"
|
42
|
-
|
79
|
+
# mobile_number_masking("携帯番号 : 080-7900-5678", "[Tel No]")
|
80
|
+
# # => "携帯番号 : [Tel No]"
|
81
|
+
def mobile_number_masking(text, word="*", jargon=false)
|
43
82
|
reg = jargon ? JARGON_MOBILE_NUMBER_REGEXP : MOBILE_NUMBER_REGEXP
|
44
83
|
text.scan(reg).each do |f|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
replace_word
|
84
|
+
if word.size >= 2
|
85
|
+
text = text.sub(f[0], word)
|
86
|
+
else
|
87
|
+
replace_word = f[0].dup
|
88
|
+
f.each_with_index do |g, index|
|
89
|
+
next if index == 0
|
90
|
+
replace_word.sub!(g, word*g.size)
|
91
|
+
end
|
92
|
+
text = text.sub(f[0], replace_word)
|
49
93
|
end
|
50
|
-
text = text.sub(f[0], replace_word)
|
51
94
|
end
|
52
95
|
text
|
53
96
|
end
|
97
|
+
|
98
|
+
# 固定電話らしき箇所をマスキングします
|
99
|
+
#
|
100
|
+
# 基本的な仕様はmobile_number_maskingと同一です
|
101
|
+
# @see mobile_number_masking
|
102
|
+
# @param [String] マスキング対象の文字列
|
103
|
+
# @param [String] マッチした部分の置換文字
|
104
|
+
# @param [Boolean] 隠語判定を強化フラグ
|
105
|
+
# @return [String] マスキング後の文字列
|
106
|
+
def phone_nomber_masking(text, word="*", jargon=false)
|
107
|
+
reg = jargon ? JARGON_PHONE_NUMBER_REGEXP : PHONE_NUMBER_REGEXP
|
108
|
+
text.scan(reg).each do |f|
|
109
|
+
if word.size >= 2
|
110
|
+
text = text.sub(f[0], word)
|
111
|
+
else
|
112
|
+
replace_word = f[0].dup
|
113
|
+
f.each_with_index do |g, index|
|
114
|
+
next if index <= 1 or g.nil?
|
115
|
+
replace_word.sub!(g, word*g.size)
|
116
|
+
end
|
117
|
+
text = text.sub(f[0], replace_word)
|
118
|
+
end
|
119
|
+
end
|
120
|
+
text
|
121
|
+
end
|
122
|
+
|
54
123
|
end
|
55
124
|
|
data/privacy_mask_tools.gemspec
CHANGED
@@ -7,9 +7,9 @@ Gem::Specification.new do |s|
|
|
7
7
|
s.version = PrivacyMaskTools::VERSION
|
8
8
|
s.authors = ["namakesugi"]
|
9
9
|
s.email = ["info@namakesugi.net"]
|
10
|
-
s.homepage = ""
|
10
|
+
s.homepage = "https://github.com/namakesugi/privacy_mask_tools"
|
11
11
|
s.summary = %q{privacy data masking tools for japanese}
|
12
|
-
s.description = %q{
|
12
|
+
s.description = %q{this module can find privacy data from text data. Try PrivacyMaskTools::Base.has_mobile_number?("<Text Data>")}
|
13
13
|
|
14
14
|
s.rubyforge_project = "privacy_mask_tools"
|
15
15
|
|
@@ -7,23 +7,33 @@ describe PrivacyMaskTools::Matcher do
|
|
7
7
|
include PrivacyMaskTools::Matcher
|
8
8
|
end
|
9
9
|
|
10
|
+
describe "Rubyにおける日本語のテスト" do
|
11
|
+
it "'/[一-四]/'で一から十までの漢数字にマッチすること" do
|
12
|
+
"一二三四五六七八九十".scan(/[一-四]/).length.should eql 10
|
13
|
+
end
|
14
|
+
|
15
|
+
it "'/[①-⑨]/'で①から⑨までの丸付き数値にマッチすること" do
|
16
|
+
"①②③④⑤⑥⑦⑧⑨".scan(/[①-⑨]/).length.should eql 9
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
10
20
|
let!(:matcher) { Obj.new }
|
11
21
|
|
12
22
|
describe ".has_mobile_number?" do
|
13
23
|
describe "携帯番号が含まれている" do
|
14
|
-
it { matcher.has_mobile_number?("
|
15
|
-
it { matcher.has_mobile_number?("
|
16
|
-
it { matcher.has_mobile_number?("
|
24
|
+
it { matcher.has_mobile_number?("08076000000").should be_true }
|
25
|
+
it { matcher.has_mobile_number?("080-7600-0000").should be_true }
|
26
|
+
it { matcher.has_mobile_number?("a080-7600-0000a").should be_true }
|
17
27
|
context "連続する数値中に含まれる場合" do
|
18
|
-
it { matcher.has_mobile_number?("
|
28
|
+
it { matcher.has_mobile_number?("008076000000").should be_true }
|
19
29
|
end
|
20
30
|
context "スペースが含まれる場合" do
|
21
|
-
it { matcher.has_mobile_number?("
|
22
|
-
it { matcher.has_mobile_number?("
|
31
|
+
it { matcher.has_mobile_number?("080 7600 0000").should be_true }
|
32
|
+
it { matcher.has_mobile_number?("080 (7600) 0000").should be_true }
|
23
33
|
end
|
24
34
|
context "全角数字が含まれている場合" do
|
25
|
-
it { matcher.has_mobile_number?("
|
26
|
-
it { matcher.has_mobile_number?("0
|
35
|
+
it { matcher.has_mobile_number?("08076345678").should be_true }
|
36
|
+
it { matcher.has_mobile_number?("080(7934)5678").should be_true }
|
27
37
|
end
|
28
38
|
end
|
29
39
|
|
@@ -39,15 +49,68 @@ describe PrivacyMaskTools::Matcher do
|
|
39
49
|
end
|
40
50
|
end
|
41
51
|
|
42
|
-
describe ".has_jargon_mobile_number" do
|
43
|
-
|
52
|
+
describe ".has_jargon_mobile_number?" do
|
53
|
+
context "漢数字・丸付き数字・o等が含まれている場合" do
|
54
|
+
it { matcher.has_jargon_mobile_number?("0⑧0-1②参四-oO十〇").should be_true }
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
describe ".has_phone_number?" do
|
59
|
+
context "([00][334466])[-ー()()・ ]*([0-90-9]{4})の場合" do
|
60
|
+
it { matcher.has_phone_number?("03-0000-1234").should be_true }
|
61
|
+
it { matcher.has_phone_number?("04-0000ー1234").should be_true }
|
62
|
+
it { matcher.has_phone_number?("0600000000").should be_true }
|
63
|
+
it { matcher.has_phone_number?("080-7900-0000").should be_false }
|
64
|
+
end
|
65
|
+
context "([00][1-91-9]{2})[-ー()()・ ]*([0-90-9]{4})の場合" do
|
66
|
+
it { matcher.has_phone_number?("011-000ー0000").should be_true }
|
67
|
+
it { matcher.has_phone_number?("099-999ー0000").should be_true }
|
68
|
+
it { matcher.has_phone_number?("0190000000").should be_true }
|
69
|
+
it { matcher.has_phone_number?("(019)000-00000").should be_false }
|
70
|
+
end
|
71
|
+
context "([00][1-91-9]{2}[0-90-9])[-ー()()・ ]*([0-90-9]{2}の場合" do
|
72
|
+
it { matcher.has_phone_number?("0110-00-0000").should be_true }
|
73
|
+
it { matcher.has_phone_number?("0990・00・0000").should be_true }
|
74
|
+
it { matcher.has_phone_number?("0110000000").should be_true }
|
75
|
+
end
|
76
|
+
context "([00][1-91-9]{2}[0-90-9]{2})[-ー()()・ ]*([0-90-9])の場合" do
|
77
|
+
it { matcher.has_phone_number?("01100-0-0000").should be_true }
|
78
|
+
it { matcher.has_phone_number?("09999ー9ー9999").should be_true }
|
79
|
+
it { matcher.has_phone_number?("0190900000").should be_true }
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
describe ".has_jargon_phone_number?" do
|
84
|
+
context "([00oO〇十][33三参③44四④66六⑥])[-ー()()・ ]*([0-90-9oO①-⑨一-四〇壱弐参]{4})の場合" do
|
85
|
+
it { matcher.has_jargon_phone_number?("o三-①②③④-①②③④").should be_true }
|
86
|
+
it { matcher.has_jargon_phone_number?("O参-⑤⑥⑦⑧-⑤⑥⑦⑧").should be_true }
|
87
|
+
it { matcher.has_jargon_phone_number?("〇③-⑨一二三-⑨一二三").should be_true }
|
88
|
+
it { matcher.has_jargon_phone_number?("〇四-四五六七-四五六七").should be_true }
|
89
|
+
it { matcher.has_jargon_phone_number?("〇④-八九〇壱-八九〇壱").should be_true }
|
90
|
+
it { matcher.has_jargon_phone_number?("〇六-弐参oO-弐参oO").should be_true }
|
91
|
+
it { matcher.has_jargon_phone_number?("〇⑥11111111").should be_true }
|
92
|
+
end
|
93
|
+
# TODO more test
|
44
94
|
end
|
45
95
|
|
46
96
|
describe ".mobile_number_masking" do
|
47
|
-
it { matcher.mobile_number_masking("
|
48
|
-
it { matcher.mobile_number_masking("
|
97
|
+
it { matcher.mobile_number_masking("080-7900-0000").should eql "***-****-****" }
|
98
|
+
it { matcher.mobile_number_masking("08079000000","x").should eql "xxxxxxxxxxx" }
|
49
99
|
context "複数マッチする箇所がある場合" do
|
50
|
-
it { matcher.mobile_number_masking("abc:
|
100
|
+
it { matcher.mobile_number_masking("abc:080-7900-0000\n090 080-7800-0000").should eql "abc:***-****-****\n090 ***-****-****" }
|
101
|
+
end
|
102
|
+
|
103
|
+
context "subに2文字以上与えた場合" do
|
104
|
+
it { matcher.mobile_number_masking("電話番号は 080(7600)0000.1です", "No").should eql "電話番号は No.1です" }
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
describe ".phone_nomber_masking" do
|
109
|
+
it { matcher.phone_nomber_masking("03-0000-1234").should eql "**-****-****" }
|
110
|
+
it { matcher.phone_nomber_masking("これが私の番号です 03・0000・9999", "○").should eql "これが私の番号です ○○・○○○○・○○○○" }
|
111
|
+
|
112
|
+
context "subに2文字以上与えた場合" do
|
113
|
+
it { matcher.phone_nomber_masking("これが私の番号です\r\n 03・0000・9999", "No").should eql "これが私の番号です\r\n No" }
|
51
114
|
end
|
52
115
|
end
|
53
116
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: privacy_mask_tools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-08-
|
12
|
+
date: 2011-08-20 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &71821410 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 2.6.0
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *71821410
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: tapp
|
27
|
-
requirement: &
|
27
|
+
requirement: &71821160 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,8 +32,9 @@ dependencies:
|
|
32
32
|
version: 1.0.0
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
36
|
-
description:
|
35
|
+
version_requirements: *71821160
|
36
|
+
description: this module can find privacy data from text data. Try PrivacyMaskTools::Base.has_mobile_number?("<Text
|
37
|
+
Data>")
|
37
38
|
email:
|
38
39
|
- info@namakesugi.net
|
39
40
|
executables: []
|
@@ -71,7 +72,7 @@ files:
|
|
71
72
|
- spec/privacy_mask_tools/base_spec.rb
|
72
73
|
- spec/privacy_mask_tools/matcher_spec.rb
|
73
74
|
- spec/spec_helper.rb
|
74
|
-
homepage:
|
75
|
+
homepage: https://github.com/namakesugi/privacy_mask_tools
|
75
76
|
licenses: []
|
76
77
|
post_install_message:
|
77
78
|
rdoc_options: []
|