torasup 0.0.14 → 0.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/torasup/version.rb +1 -1
- data/lib/torasup.rb +1 -1
- data/spec/torasup/configuration_spec.rb +23 -10
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 02c09491e5cda23554f00cc013fded14e8d838c6
|
4
|
+
data.tar.gz: a6ff34c7db89102b4a78c409becdeff38d7551e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 20ab556f408911e118d895335f3bf2759ca688a42972152f7ba52c834b34dd43d2b885845e36d260f7616cce3d7528a98d27f376889d3ab506a75bd9cfcc9bd0
|
7
|
+
data.tar.gz: 54263d8a2b91be632769031b7ac8d5f937c4db7751d4671f8b6466b527f0124f893f5837f51da0cbc2813ca8ad6979341fb1855a0d40c3ae463cd7a31103ce3e
|
data/lib/torasup/version.rb
CHANGED
data/lib/torasup.rb
CHANGED
@@ -23,7 +23,7 @@ module Torasup
|
|
23
23
|
@international_dialing_codes = {}
|
24
24
|
ISO3166::Country.all.each do |country|
|
25
25
|
dialing_code = country.country_code
|
26
|
-
@international_dialing_codes[dialing_code] = country.alpha2 if !@international_dialing_codes[dialing_code]
|
26
|
+
@international_dialing_codes[dialing_code] = country.alpha2 if !@international_dialing_codes[dialing_code] || configuration.default_countries.include?(country.alpha2)
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
@@ -32,19 +32,32 @@ describe Torasup do
|
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
-
describe "#default_countries=(
|
36
|
-
|
37
|
-
allow(Torasup).to receive(:load_international_dialing_codes!)
|
38
|
-
end
|
35
|
+
describe "#default_countries=(value)" do
|
36
|
+
let(:torasup_number) { Torasup::PhoneNumber.new("+1 415-234 5678") }
|
39
37
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
38
|
+
context "configuring" do
|
39
|
+
before do
|
40
|
+
allow(Torasup).to receive(:load_international_dialing_codes!)
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should set the default countries and reload the data" do
|
44
|
+
Torasup.configure do |config|
|
45
|
+
expect(Torasup).to receive(:load_international_dialing_codes!)
|
46
|
+
expect(config.default_countries).to eq(["US", "GB", "AU", "IT", "RU", "NO"])
|
47
|
+
config.default_countries = ["US", "GB"]
|
48
|
+
expect(config.default_countries).to eq(["US", "GB"])
|
49
|
+
end
|
46
50
|
end
|
47
51
|
end
|
52
|
+
|
53
|
+
context "by default" do
|
54
|
+
it { expect(torasup_number.country_id).to eq("us") }
|
55
|
+
end
|
56
|
+
|
57
|
+
context "overriding defaults" do
|
58
|
+
before { Torasup.configure { |config| config.default_countries = ["CA"] } }
|
59
|
+
it { expect(torasup_number.country_id).to eq("ca") }
|
60
|
+
end
|
48
61
|
end
|
49
62
|
|
50
63
|
describe "#custom_pstn_data_file=('path_to_yaml_file.yaml')" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: torasup
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Wilkie
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-09-
|
11
|
+
date: 2015-09-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: countries
|