pincode_finder 0.1.2

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 858a84640a57fedc687e52a9e1fa29e0f85a1b2de9b44096bd74232a8da015a5
4
+ data.tar.gz: 34450494e9a7e41b9beaf160f95041d90c3de16b3bf2cf183c4a15a2c25d6111
5
+ SHA512:
6
+ metadata.gz: 32b93766384dd4cbff6d6a77f7f0584205f560fed96cb8a59772910a0953cfd3ce167c9fa306010a3656129dc2082bdd213e2cb94e689e3e3937c8f08e4138b4
7
+ data.tar.gz: 15725e99cc9a852f23f75a90cc153bfa956ca881927489c464928b430435a3115ec5352014f0469a225b17aadd7c671cb77e6e5f377c8a92cda270ca023f154a
Binary file
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PincodeFinder
4
+ VERSION = "0.1.2"
5
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+ require "json"
3
+ require 'zlib'
4
+ require_relative "pincode_finder/version"
5
+
6
+ module PincodeFinder
7
+ class Error < StandardError; end
8
+ data_file = File.expand_path('../data/pincode_data.json.gz', __dir__)
9
+
10
+ DATA = Zlib::GzipReader.open(data_file) do |gz|
11
+ JSON.parse(gz.read)
12
+ end
13
+
14
+ def self.find(pincode)
15
+ result = DATA.find { |entry| entry["pincode"].to_s == pincode.to_s }
16
+ if result
17
+ {
18
+ pincode: result["pincode"],
19
+ district: result["district"],
20
+ state: result["state"]
21
+ }
22
+ else
23
+ { error: "Pincode not found" }
24
+ end
25
+ end
26
+ end
metadata ADDED
@@ -0,0 +1,48 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pincode_finder
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.2
5
+ platform: ruby
6
+ authors:
7
+ - Aadhi
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2024-08-28 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: This gem takes a pincode as input and returns the associated district
14
+ and state.
15
+ email:
16
+ - aadhi@flaerhomes.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - data/pincode_data.json.gz
22
+ - lib/pincode_finder.rb
23
+ - lib/pincode_finder/version.rb
24
+ homepage: https://github.com/aadhi-flaerhomes/pincode_finder
25
+ licenses:
26
+ - MIT
27
+ metadata:
28
+ homepage_uri: https://github.com/aadhi-flaerhomes/pincode_finder
29
+ post_install_message:
30
+ rdoc_options: []
31
+ require_paths:
32
+ - lib
33
+ required_ruby_version: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - ">="
36
+ - !ruby/object:Gem::Version
37
+ version: 3.0.0
38
+ required_rubygems_version: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: '0'
43
+ requirements: []
44
+ rubygems_version: 3.5.10
45
+ signing_key:
46
+ specification_version: 4
47
+ summary: A gem to find Indian pincodes.
48
+ test_files: []