cdek 0.3.11 → 0.3.12
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/cdek/city_suggestions.rb +18 -4
- data/lib/cdek/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5dfa6bb78c45fc7a0bf40bf04cdf59999b7598766cf0ef5c3b086b699db45f38
|
|
4
|
+
data.tar.gz: c9f43b02cfc8b5314ad3b4338f8786e319216b0e72878e2f82a817f4cbca76f9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8e532a826e6bcacae86aaf2f1f4ee23f14ae1358889c344a632cc76107deb7e359d16b61983921a7fdc2f4b7e274f262d7fa10f010af9b2e276dec5c6af96267
|
|
7
|
+
data.tar.gz: ed305863d0c728ba013f3f6b7e363e54e6e973dd0e67d76c28468750f685157af106a6a13a2aa7cfa43e8d6eff0f6d389f4f0701c51680f368f35a3562572780
|
|
@@ -41,7 +41,8 @@ module Cdek
|
|
|
41
41
|
def suggestion_payload(city)
|
|
42
42
|
if city.is_a?(Hash)
|
|
43
43
|
code = city["code"] || city[:code]
|
|
44
|
-
|
|
44
|
+
full_name = city["full_name"] || city[:full_name]
|
|
45
|
+
city_name = city["city"] || city[:city] || city["name"] || city[:name] || city_name_from_full_name(full_name)
|
|
45
46
|
region = city["region"] || city[:region]
|
|
46
47
|
country = city["country"] || city[:country]
|
|
47
48
|
country_code_value = city["country_code"] || city[:country_code]
|
|
@@ -50,17 +51,30 @@ module Cdek
|
|
|
50
51
|
{
|
|
51
52
|
code: code,
|
|
52
53
|
city: city_name,
|
|
54
|
+
full_name: full_name,
|
|
53
55
|
region: region,
|
|
54
56
|
country: country,
|
|
55
57
|
country_code: country_code_value,
|
|
56
|
-
label: label_for(city_name, region)
|
|
58
|
+
label: label_for(city_name, region, full_name)
|
|
57
59
|
}
|
|
58
60
|
end
|
|
59
61
|
end
|
|
60
62
|
end
|
|
61
63
|
|
|
62
|
-
def
|
|
63
|
-
|
|
64
|
+
def city_name_from_full_name(full_name)
|
|
65
|
+
value = full_name.to_s.split(",").first.to_s.strip
|
|
66
|
+
|
|
67
|
+
unless value.empty?
|
|
68
|
+
value
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def label_for(city_name, region, full_name)
|
|
73
|
+
if full_name.to_s.strip.empty?
|
|
74
|
+
[city_name, region].compact.map(&:to_s).reject(&:empty?).uniq.join(", ")
|
|
75
|
+
else
|
|
76
|
+
full_name.to_s.strip
|
|
77
|
+
end
|
|
64
78
|
end
|
|
65
79
|
|
|
66
80
|
def normalized_query
|
data/lib/cdek/version.rb
CHANGED