postcode_gem 0.3.13 → 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: fc78a23dd3c7fb5436238970d3b2344f9011e9c17c6e68cf659d2ed0f46bf5ac
4
- data.tar.gz: d0ef9d082147e2a4af2ffc84cd6f4da1bfb6c23b50a55541f7f45136beacdd32
3
+ metadata.gz: 300e8e0ba97b59765e3c6d0c17a7cd6d8b924b519814d37a7025ec5c8e60e1cc
4
+ data.tar.gz: 5074ea5e61e294f48d1f207672dc42fd4bab8c8a3d54dc61467a950989c2fd24
5
5
  SHA512:
6
- metadata.gz: 7ceec948c0e15464e0dbc304f3fe8e492116560c745ad0c2dd5662cbfae160ccdc1eea96de2532853379412f9e09865f3ec0fd484454003d131fe0fbfcc393ff
7
- data.tar.gz: 0b3449c7c19c06f5e0542889b6e0f5edcf4c8bad85ed1a4e31444990440ea8064b1ce5493b8c3a02332a569b33c428e6de1c8776997d7b8d0753cfd4a60f56d0
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,3 +1,3 @@
1
1
  module PostcodeGem
2
- VERSION = "0.3.13"
2
+ VERSION = "0.3.14"
3
3
  end
data/lib/postcode_gem.rb CHANGED
@@ -1,35 +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
- module_function
9
- def export_json
10
- PostcodeGem::Export.execute
11
- end
12
8
 
13
9
  def output_zipcode
14
- @data = JSON.parse(File.open('data/postcode_areacode.json').read)
10
+ @data = PostcodeData::DATA
15
11
  prompt = TTY::Prompt.new
16
12
  @country = prompt.select('Enter the country you want to select', %w(Vietnam England Japan))
17
13
  print "Enter the city or area code you want to search: "
18
14
  @city_zipcode = gets.chomp
19
15
  @firstWord = @city_zipcode.split('')[0]
20
- @city = @data["#{@country}"].values
21
- @zipcode = @data["#{@country}"].keys
22
- @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]
23
19
 
24
20
  if @data_country.has_key?(@city_zipcode)
25
21
  puts @data_country.values_at("#{@city_zipcode}")
26
22
  elsif @data_country.has_key?(@city_zipcode) == false && /[0-9]/.match(@firstWord)
27
- 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) }
28
24
  end
29
25
  if @data_country.has_value?(@city_zipcode)
30
26
  puts @data_country.key(@city_zipcode)
31
27
  elsif @data_country.has_value?(@city_zipcode) == false && /[a-z]/.match(@firstWord)
32
- 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) }
33
29
  end
34
30
  end
35
31
  module_function :output_zipcode
@@ -42,3 +38,5 @@ class Show
42
38
  end
43
39
  end
44
40
 
41
+ Show.new.call_result
42
+
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.13
4
+ version: 0.3.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - PhuongTr1501