postcode_gem 0.3.9 → 0.3.14

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
  SHA256:
3
- metadata.gz: dafcef03748643c5e9931a78a01839618da5af5e56ee3d49e8b5da7706703f78
4
- data.tar.gz: 171f1ef0bd9b454fe0abff98bb1df0ea14953721666ca3fc75eda8617f24e1b9
3
+ metadata.gz: 300e8e0ba97b59765e3c6d0c17a7cd6d8b924b519814d37a7025ec5c8e60e1cc
4
+ data.tar.gz: 5074ea5e61e294f48d1f207672dc42fd4bab8c8a3d54dc61467a950989c2fd24
5
5
  SHA512:
6
- metadata.gz: '08c9bb8d7b241ec0e724baed9ce7bcbe26bad7dc91839614908e68e9bd4c8f87101c32ecc67c2f347149aec3792e169ab13733441006be86677834942cc879e1'
7
- data.tar.gz: 3da5caaba7367d8d5664153ebaef34b2b2725821f7eefb40a1e7cea0ab922706101a30698b91eed5e13b696a78dfbf5dc63ffeeed78e841c15bbc5da4be234a6
6
+ metadata.gz: 79df5efb542878f0bc91608284677a2a1ff37e91ae2125674ece10f4042e76e83ba3eb542e817217d6620269fef144d303f14b331c284ce2a249e7326f6876a1
7
+ data.tar.gz: bfe984b9946b2100ad8ad1f4192ceef75e5db9e0f28de09ffadc3a67f82951082eb247936792ae08822e8dd01c48e917be6025d619ee636f4a6b26b1064bc7f9
data/Gemfile CHANGED
@@ -9,3 +9,4 @@ gem 'tty-spinner'
9
9
  gem 'tty-table'
10
10
  gem 'pry'
11
11
  gem 'json'
12
+ gem 'nokogiri'
@@ -1,30 +1,31 @@
1
1
  require_relative '../lib/postcode_gem/version'
2
- require "json"
2
+ require_relative '../lib/postcode_gem/postcode_data'
3
3
  require "tty-prompt"
4
4
  require "pry"
5
5
 
6
6
  module PostcodeGem
7
7
  attr_accessor :country, :city, :zipcode
8
+
8
9
  def output_zipcode
9
- @data = JSON.load(File.read("#{Dir.pwd}/data/postcode_areacode.json"))
10
+ @data = PostcodeData::DATA
10
11
  prompt = TTY::Prompt.new
11
12
  @country = prompt.select('Enter the country you want to select', %w(Vietnam England Japan))
12
13
  print "Enter the city or area code you want to search: "
13
14
  @city_zipcode = gets.chomp
14
15
  @firstWord = @city_zipcode.split('')[0]
15
- @city = @data["#{@country}"].values
16
- @zipcode = @data["#{@country}"].keys
17
- @data_country = @data["#{@country}"]
16
+ @city = @data[@country.to_sym].values
17
+ @zipcode = @data[@country.to_sym].keys
18
+ @data_country = @data[@country.to_sym]
18
19
 
19
20
  if @data_country.has_key?(@city_zipcode)
20
21
  puts @data_country.values_at("#{@city_zipcode}")
21
22
  elsif @data_country.has_key?(@city_zipcode) == false && /[0-9]/.match(@firstWord)
22
- puts @zipcode.map { |v| puts v if v.start_with?(@firstWord) }
23
+ puts @zipcode.map { |v| puts v if v.to_s.start_with?(@firstWord) }
23
24
  end
24
25
  if @data_country.has_value?(@city_zipcode)
25
26
  puts @data_country.key(@city_zipcode)
26
27
  elsif @data_country.has_value?(@city_zipcode) == false && /[a-z]/.match(@firstWord)
27
- puts @city.map { |v| puts v if v.start_with?(@firstWord) }
28
+ puts @city.map { |v| puts v if v.to_s.start_with?(@firstWord) }
28
29
  end
29
30
  end
30
31
  module_function :output_zipcode
@@ -37,3 +38,5 @@ class Show
37
38
  end
38
39
  end
39
40
 
41
+ Show.new.call_result
42
+
@@ -1,3 +1,3 @@
1
1
  module PostcodeGem
2
- VERSION = "0.3.9"
2
+ VERSION = "0.3.14"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: postcode_gem
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.9
4
+ version: 0.3.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - PhuongTr1501