contacts_txt 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0b1275007e1f8ef531ebeee9f8a3fda50991d07f
4
- data.tar.gz: fa8cb894c0defecdd41b9dc15fe84fbf90262467
3
+ metadata.gz: 8a2c14d80c95502b1db1c6aeb4687853807cba32
4
+ data.tar.gz: e7ed2b0253993915768a102bde50a3e033518e78
5
5
  SHA512:
6
- metadata.gz: 660552a683c9c1b5bc933f0a0a558ac06a904f575b936fc8ff1e0959b5c620b347833b8eb5f0dcfce706288cf13845840b754ce50a92ddf956fcc2664da1c13e
7
- data.tar.gz: 3c82b345017bfdbeb3138d542fc13eaa731fc34e8a5bbfe966062b75514813ff1fb64de6d7f4c887fe7427c278dcfa02f0a9bc19777975cd7898ab5327047206
6
+ metadata.gz: 766950c9290b976600fd622a0c4763d982708e61cf6e85a93bf8d710c728283a7a3c638d145cb0be4f78814d6190f5bd01083ebe3bfbf78a61c0c4b220567124
7
+ data.tar.gz: 3708b321cfde13a3503c67bbf586f73a98d5a7876604a774d3663726737d6e2798d2d7cf1ffba81f2bf6365e562e812e862bcb9813f8fc13785f2ff420ce5ae6
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -38,15 +38,33 @@ class ContactsTxt
38
38
  @dx
39
39
  end
40
40
 
41
+ def find_by_mobile(raw_number, countrycode='44')
42
+
43
+ number = Regexp.new number.sub(/^(?:0|#{countrycode})/,'').gsub(/ */,'')
44
+
45
+ @dx.all.find {|x| x.mobile.gsub(/ */,'') =~ number }
46
+
47
+ end
48
+
41
49
  def find_by_name(raw_name)
42
50
 
43
- name = Regexp.new raw_name
51
+ name = Regexp.new raw_name, Regexp::IGNORECASE
44
52
 
45
53
  @dx.all.select do |x|
46
54
  x.fullname =~ name or x.firstname =~ name or x.lastname =~ name
47
55
  end
48
56
 
49
57
  end
58
+
59
+ def find_by_sms(raw_number, countrycode='44')
60
+
61
+ number = Regexp.new raw_number\
62
+ .sub(/^(?:0|#{countrycode})/,'').gsub(/ */,'')
63
+
64
+ @dx.all.find {|x| x.sms.gsub(/ */,'') =~ number \
65
+ or x.mobile.gsub(/ */,'') =~ number }
66
+
67
+ end
50
68
 
51
69
  # returns a Dynarex object
52
70
  #
@@ -60,7 +78,7 @@ class ContactsTxt
60
78
 
61
79
  def save(filename=@filename)
62
80
 
63
- s = dx_to_s(@dx, title: File.basename(filename) )
81
+ s = dx_to_s(@dx)
64
82
  File.write File.join(@path, filename), s
65
83
  @dx.save File.join(@path, filename.sub(/\.txt$/,'.xml'))
66
84
 
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.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -31,7 +31,7 @@ cert_chain:
31
31
  Ebw/4t8+mfs6ivuW6xdj3SlqhEXlfJ83mZuvJ3LtQteR5p0R8DSLcTXMkOrWD6wC
32
32
  07GXbdChvjqXQg==
33
33
  -----END CERTIFICATE-----
34
- date: 2017-09-25 00:00:00.000000000 Z
34
+ date: 2017-09-29 00:00:00.000000000 Z
35
35
  dependencies:
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: dynarex
metadata.gz.sig CHANGED
Binary file