phony_rails 0.12.1 → 0.12.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: 89bf28723abfacd4fca598089c2c674668d21bed
4
- data.tar.gz: a8611d6f572bb2e2713abff5d3846e09fb2fd1a6
3
+ metadata.gz: 69276a65ab509580ebd6b96adb01c6ae03ff2bf8
4
+ data.tar.gz: 3faddbca4183fee934927c93787223f8a46b4c00
5
5
  SHA512:
6
- metadata.gz: d157afaff06b65a3f1af8f0c5aed1392eeb638071dc6dfec09a572c777f9a7427c35dc2c05180a9eccc42f2a72f39ca0bd1ba0a0aabcaaaf7185b2df2a33c683
7
- data.tar.gz: f025d73b8f87578ce4866f1a0a012e32ab4e37ecb26d358c0040f8430daa5e15c18641a36d5cd23cc221e186b110c41627ce1df60b8880adb73d22a3b751d8ca
6
+ metadata.gz: 852574f157477ddf3d38658f778f394e423db680ba326cd182ac691619eabf652aeee20612f51744d971bdfecd0e880edfa338928c0750c5b6cba10bf42867bb
7
+ data.tar.gz: 58d821718858e450291e23a006099630eb259284186e2aeb3c60fdc717cb12f406f2ba535b71de7c432d8bacc60be3a5944b7b81e79ee2792672cc10d320d8fd
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ language: ruby
2
+ rvm:
3
+ - "1.9.3"
4
+ - "2.1.3"
5
+ - "2.2.1"
6
+ - rbx
7
+ script: bundle exec rspec spec
data/Gemfile CHANGED
@@ -13,17 +13,3 @@ gem 'rspec', '~> 2.14.0'
13
13
  gem 'guard', '~> 2.10.1'
14
14
  gem 'guard-bundler', '~> 2.0.0'
15
15
  gem 'guard-rspec', '~> 4.2.0'
16
-
17
- case RbConfig::CONFIG['host_os']
18
- when /darwin/i
19
- gem 'growl'
20
- gem 'rb-fsevent'
21
- when /linux/i
22
- gem 'libnotify'
23
- gem 'rb-inotify'
24
- when /mswin|windows/i
25
- gem 'rb-fchange'
26
- gem 'rb-notifu'
27
- gem 'win32console'
28
- end
29
-
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- phony_rails (0.12.0)
4
+ phony_rails (0.12.1)
5
5
  activesupport (>= 3.0)
6
6
  countries (~> 0.8, >= 0.8.2)
7
7
  phony (~> 2.12)
@@ -36,7 +36,6 @@ GEM
36
36
  diff-lcs (1.2.5)
37
37
  ffi (1.9.8)
38
38
  formatador (0.2.5)
39
- growl (1.0.3)
40
39
  guard (2.10.5)
41
40
  formatador (>= 0.2.4)
42
41
  listen (~> 2.7)
@@ -105,13 +104,11 @@ PLATFORMS
105
104
  DEPENDENCIES
106
105
  activerecord (>= 3.0)
107
106
  countries
108
- growl
109
107
  guard (~> 2.10.1)
110
108
  guard-bundler (~> 2.0.0)
111
109
  guard-rspec (~> 4.2.0)
112
110
  mongoid (>= 3.0)
113
111
  phony_rails!
114
112
  rake
115
- rb-fsevent
116
113
  rspec (~> 2.14.0)
117
114
  sqlite3
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # PhonyRails
1
+ # PhonyRails [![Build Status](https://travis-ci.org/joost/phony_rails.svg?branch=master)](https://travis-ci.org/joost/phony_rails)
2
2
 
3
3
  This small Gem adds useful methods to your Rails app to validate, display and save phone numbers.
4
4
  It uses the super awesome Phony gem (https://github.com/floere/phony).
@@ -1,3 +1,3 @@
1
1
  module PhonyRails
2
- VERSION = "0.12.1"
2
+ VERSION = "0.12.2"
3
3
  end
data/lib/phony_rails.rb CHANGED
@@ -33,7 +33,12 @@ module PhonyRails
33
33
  end
34
34
  elsif _default_country_number = options[:default_country_number] || country_number_for(options[:default_country_code])
35
35
  options[:add_plus] = true if options[:add_plus].nil?
36
- number = "#{_default_country_number}#{number}" unless Phony.plausible?(number)
36
+ # We try to add the default country number and see if it is a
37
+ # correct phone number. See https://github.com/joost/phony_rails/issues/87#issuecomment-89324426
38
+ if Phony.plausible?("#{_default_country_number}#{number}") || !Phony.plausible?(number) || country_code_from_number(number).nil?
39
+ number = "#{_default_country_number}#{number}"
40
+ end
41
+ # number = "#{_default_country_number}#{number}" unless Phony.plausible?(number)
37
42
  end
38
43
  normalized_number = Phony.normalize(number)
39
44
  options[:add_plus] = true if options[:add_plus].nil? && Phony.plausible?(normalized_number)
@@ -89,19 +89,24 @@ describe PhonyRails do
89
89
  describe "specific tests from issues" do
90
90
 
91
91
  # https://github.com/joost/phony_rails/issues/79
92
- it "should pass issue Github issue #42" do
92
+ it "should pass Github issue #42" do
93
93
  "8887716095".phony_formatted(format: :international, normalize: 'US', raise: true).should eq('+1 888 771 6095')
94
94
  end
95
95
 
96
96
  # https://github.com/joost/phony_rails/issues/42
97
- it "should pass issue Github issue #42" do
97
+ it "should pass Github issue #42" do
98
98
  PhonyRails.normalize_number("0606060606", default_country_code: 'FR').should eq('+33606060606')
99
99
  end
100
100
 
101
- it "should pass issue Github issue #85" do
101
+ it "should pass Github issue #85" do
102
102
  PhonyRails.normalize_number("47386160", default_country_code: 'NO').should eq('+4747386160')
103
103
  PhonyRails.normalize_number("47386160", country_number: '47').should eq('+4747386160')
104
104
  end
105
+
106
+ it "should pass Github issue #87" do
107
+ PhonyRails.normalize_number('2318725305', country_code: 'US').should eq('+12318725305')
108
+ PhonyRails.normalize_number('2318725305', default_country_code: 'US').should eq('+12318725305')
109
+ end
105
110
  end
106
111
 
107
112
  it "should not change original String" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: phony_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.1
4
+ version: 0.12.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joost Hietbrink
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-01 00:00:00.000000000 Z
11
+ date: 2015-04-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: phony
@@ -96,6 +96,7 @@ extra_rdoc_files: []
96
96
  files:
97
97
  - ".gitignore"
98
98
  - ".rspec"
99
+ - ".travis.yml"
99
100
  - Gemfile
100
101
  - Gemfile.lock
101
102
  - Guardfile