contacts_txt 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +3 -2
- data/lib/contacts_txt.rb +95 -5
- metadata +29 -24
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9abd4607e4765b8edaa26fa9880f4152f5187868ce84e11308fcc6b3918c734d
|
4
|
+
data.tar.gz: 39609f542c37597a33cb42723488431cbd19cfec2c873919d69581d5f5c9d2c1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e99e8c0f20abedcbc47487dceea18a24f6166c84ebb8bff71f9bbfbf064979e8e4fcb2343642a08f566863bebe9034d654aff136114a4652393fc93aee3f4504
|
7
|
+
data.tar.gz: b6524180f0d62331a283a181534ab742f050f7d228e10973ee4a7899e20ac70702b8d9927be103bbd04984866441f394f57d9203e12f68058a3bdb99832e1df7
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
@@ -1,2 +1,3 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
J�2�-���
|
2
|
+
�-�K���]��N�����l�0O��3�l�Pݨؔm���{��R�}:EڗQ�V+� :������P:a�
|
3
|
+
�Ɲa��FW$�� �����X��B�9`+�f��C����2�V���a�_����l]Ѣ���5���G��K=�njƢw��ܼ���?QP0rgHm�=�����Ag��Z���8:9��,uX(�36u��E�<��Ӆ�.1-�����S�#���� n���Qa���ϝJ��JG�%�q|����t�k�b��������<���Y�S�|ו���dC�\8^��I����8(4[�:���<��U������ ogP�1K}(ϧ� � -���~Hb�9�
|
data/lib/contacts_txt.rb
CHANGED
@@ -38,6 +38,10 @@ class ContactsTxt
|
|
38
38
|
|
39
39
|
end
|
40
40
|
|
41
|
+
def all()
|
42
|
+
@dx.all
|
43
|
+
end
|
44
|
+
|
41
45
|
def dx()
|
42
46
|
@dx
|
43
47
|
end
|
@@ -56,14 +60,25 @@ class ContactsTxt
|
|
56
60
|
|
57
61
|
end
|
58
62
|
|
59
|
-
def find_by_name(
|
63
|
+
def find_by_name(s)
|
60
64
|
|
65
|
+
# Appending a hashtag to the name can help with finding the specific record
|
66
|
+
# e.g. 'Peter#plumber' or 'Peter #plumber'
|
67
|
+
|
68
|
+
raw_name, tag = s.split('#',2).map(&:strip)
|
69
|
+
|
61
70
|
name = Regexp.new "\b#{raw_name}\b|#{raw_name}", Regexp::IGNORECASE
|
62
71
|
puts 'name: ' + name.inspect if @debug
|
63
72
|
|
64
|
-
@dx.all.select do |x|
|
73
|
+
a = @dx.all.select do |x|
|
65
74
|
x.fullname =~ name or x.firstname =~ name or x.lastname =~ name
|
66
75
|
end
|
76
|
+
|
77
|
+
if tag then
|
78
|
+
a.find {|x| x.tags.split.map(&:downcase).include? tag.downcase }
|
79
|
+
else
|
80
|
+
a
|
81
|
+
end
|
67
82
|
|
68
83
|
end
|
69
84
|
|
@@ -113,6 +128,58 @@ class ContactsTxt
|
|
113
128
|
@dx.filter {|x| x.mobile.length > 0}
|
114
129
|
end
|
115
130
|
|
131
|
+
def multi_tel_index()
|
132
|
+
|
133
|
+
a = @dx.all.map do |x|
|
134
|
+
|
135
|
+
tel = %i(tel mobile mobile2).detect do |name|
|
136
|
+
!x.method(name).call.empty?
|
137
|
+
end
|
138
|
+
next unless tel
|
139
|
+
"%s %s" % [x.fullname, x.method(tel).call]
|
140
|
+
end.compact
|
141
|
+
|
142
|
+
|
143
|
+
# group by first name
|
144
|
+
r = a.group_by {|x| x[0]}
|
145
|
+
|
146
|
+
a2 = a.clone
|
147
|
+
|
148
|
+
# group by last name
|
149
|
+
r2 = a.group_by {|x| x.split(/ /,2).last[0]}
|
150
|
+
c = r2.merge(r)
|
151
|
+
|
152
|
+
c.each do |k, v|
|
153
|
+
|
154
|
+
puts "k: %s v: %s" % [k, v]
|
155
|
+
v.concat(r2[k]) if r2[k]
|
156
|
+
|
157
|
+
end
|
158
|
+
|
159
|
+
h = c.sort.each {|k,v| v.uniq!}.to_h
|
160
|
+
|
161
|
+
out = []
|
162
|
+
|
163
|
+
h.each do |k,v|
|
164
|
+
|
165
|
+
out << ' ' + (' ' * 30) + k
|
166
|
+
|
167
|
+
v.each do |x|
|
168
|
+
|
169
|
+
name, phone = x.split(/(?=\d)/,2)
|
170
|
+
out << "\n" + (name.length >= 29 ? name[0..26] + '...' : name)
|
171
|
+
tel = (' ' + ' ' * (26 - phone.length)) + 't: ' + phone
|
172
|
+
out << tel + "\n"
|
173
|
+
out << ('-' * 30)
|
174
|
+
|
175
|
+
end
|
176
|
+
|
177
|
+
end
|
178
|
+
|
179
|
+
puts out.join("\n")
|
180
|
+
|
181
|
+
end
|
182
|
+
|
116
183
|
def save(filename=@filename)
|
117
184
|
|
118
185
|
s = dx_to_s(@dx)
|
@@ -121,6 +188,10 @@ class ContactsTxt
|
|
121
188
|
|
122
189
|
end
|
123
190
|
|
191
|
+
def to_dx()
|
192
|
+
@dx
|
193
|
+
end
|
194
|
+
|
124
195
|
def to_s()
|
125
196
|
dx_to_s @dx
|
126
197
|
end
|
@@ -193,7 +264,9 @@ class ContactsTxtAgent < ContactsTxt
|
|
193
264
|
|
194
265
|
def find_mobile_by_name(s)
|
195
266
|
|
196
|
-
|
267
|
+
result = find_by_name(s)
|
268
|
+
|
269
|
+
r = validate(result)
|
197
270
|
|
198
271
|
numbers = [r.sms.empty? ? r.mobile : r.sms, r.mobile].uniq\
|
199
272
|
.map {|x| x.sub(/\([^\)]+\)/,'').strip}
|
@@ -217,7 +290,8 @@ class ContactsTxtAgent < ContactsTxt
|
|
217
290
|
|
218
291
|
def find_tel_by_name(s)
|
219
292
|
|
220
|
-
|
293
|
+
result = find_by_name(s)
|
294
|
+
r = validate(result)
|
221
295
|
|
222
296
|
h = {}
|
223
297
|
|
@@ -229,5 +303,21 @@ class ContactsTxtAgent < ContactsTxt
|
|
229
303
|
|
230
304
|
h[:tags] = r.tags.to_s
|
231
305
|
h
|
232
|
-
end
|
306
|
+
end
|
307
|
+
|
308
|
+
private
|
309
|
+
|
310
|
+
def validate(result)
|
311
|
+
|
312
|
+
case result.class.to_s
|
313
|
+
when 'RecordX'
|
314
|
+
result
|
315
|
+
when 'Array'
|
316
|
+
result.first
|
317
|
+
when 'NilClass'
|
318
|
+
return "I couldn't find that name."
|
319
|
+
end
|
320
|
+
|
321
|
+
end
|
322
|
+
|
233
323
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: contacts_txt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -10,27 +10,32 @@ bindir: bin
|
|
10
10
|
cert_chain:
|
11
11
|
- |
|
12
12
|
-----BEGIN CERTIFICATE-----
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
13
|
+
MIIEXjCCAsagAwIBAgIBATANBgkqhkiG9w0BAQsFADAsMSowKAYDVQQDDCFnZW1t
|
14
|
+
YXN0ZXIvREM9amFtZXNyb2JlcnRzb24vREM9ZXUwHhcNMjAwMTA1MTUxNjU1WhcN
|
15
|
+
MjEwMTA0MTUxNjU1WjAsMSowKAYDVQQDDCFnZW1tYXN0ZXIvREM9amFtZXNyb2Jl
|
16
|
+
cnRzb24vREM9ZXUwggGiMA0GCSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQCjBEU5
|
17
|
+
87uGRPHAB6oJBWp9y6sv/xAllgf0n0JW2CVWO7AA7D6lY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sDmCsb57rSch74/9Wenof/LnOUbUQth2NzJCdIreYaWR4maJEtHXHUq8glNsY
|
33
|
+
BivuQJVyHs/VvJ5b3/+l79zPdwOrPqZc3kSI4Pkd88ORXBwKjdSPi9elu1BmLU3M
|
34
|
+
vD5QednPC6Uz+TsskfllqEFDePfvEZbdIxgDeDjcodiGw1hVkvjsxrarBfqW/ozO
|
35
|
+
qmCJIuCwTOavNpNa1QrbiPivF5XoxOM1dEMfedK9qPxJhfovq0ZnfkMZW1R3/Qk7
|
36
|
+
N1r4i3xYGxWWiZWLrlorY10U
|
32
37
|
-----END CERTIFICATE-----
|
33
|
-
date:
|
38
|
+
date: 2020-01-05 00:00:00.000000000 Z
|
34
39
|
dependencies:
|
35
40
|
- !ruby/object:Gem::Dependency
|
36
41
|
name: dynarex
|
@@ -41,7 +46,7 @@ dependencies:
|
|
41
46
|
version: '1.8'
|
42
47
|
- - ">="
|
43
48
|
- !ruby/object:Gem::Version
|
44
|
-
version: 1.8.
|
49
|
+
version: 1.8.21
|
45
50
|
type: :runtime
|
46
51
|
prerelease: false
|
47
52
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -51,7 +56,7 @@ dependencies:
|
|
51
56
|
version: '1.8'
|
52
57
|
- - ">="
|
53
58
|
- !ruby/object:Gem::Version
|
54
|
-
version: 1.8.
|
59
|
+
version: 1.8.21
|
55
60
|
description:
|
56
61
|
email: james@jamesrobertson.eu
|
57
62
|
executables: []
|
@@ -78,7 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
78
83
|
- !ruby/object:Gem::Version
|
79
84
|
version: '0'
|
80
85
|
requirements: []
|
81
|
-
rubygems_version: 3.0.
|
86
|
+
rubygems_version: 3.0.3
|
82
87
|
signing_key:
|
83
88
|
specification_version: 4
|
84
89
|
summary: Reads a contacts.txt file
|
metadata.gz.sig
CHANGED
Binary file
|