thai_geodata 0.1.0

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.
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ThaiGeodata
4
+ VERSION = '0.1.0'
5
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'json'
4
+ require_relative 'thai_geodata/version'
5
+
6
+ # ThaiGeodata provides in-memory lookup of Thailand’s provinces, districts
7
+ # and subdistricts (with postal codes) from static JSON data.
8
+ module ThaiGeodata
9
+ DATA_PATH = File.join(__dir__, 'thai_geodata', 'data')
10
+
11
+ def self.provinces
12
+ @provinces ||= load_json('provinces.json')
13
+ end
14
+
15
+ def self.districts
16
+ @districts ||= load_json('districts.json')
17
+ end
18
+
19
+ def self.subdistricts
20
+ @subdistricts ||= load_json('subdistricts.json')
21
+ end
22
+
23
+ def self.load_json(file)
24
+ JSON.parse(File.read(File.join(DATA_PATH, file)))
25
+ end
26
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'minitest/autorun'
4
+ require_relative '../lib/thai_geodata'
5
+
6
+ class ThaiGeodataTest < Minitest::Test
7
+ def test_provinces_loaded
8
+ assert ThaiGeodata.provinces.any?
9
+ end
10
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ # thai_geodata.gemspec
4
+
5
+ # Load the version constant so s.version = ThaiGeodata::VERSION works
6
+ require_relative 'lib/thai_geodata/version'
7
+
8
+ Gem::Specification.new do |s|
9
+ s.name = 'thai_geodata'
10
+ s.version = ThaiGeodata::VERSION
11
+ s.summary = 'Thailand geography data: provinces, districts, subdistricts, postal codes'
12
+ s.description = 'A Ruby gem wrapping the MIT-licensed Thailand Geography JSON dataset, with lookup helpers.'
13
+ s.authors = ['Your Name']
14
+ s.email = ['you@example.com']
15
+ s.files = Dir.chdir(__dir__) { `git ls-files -z`.split("\x0") }
16
+ s.homepage = 'https://github.com/yourusername/thai_geodata'
17
+ s.license = 'MIT'
18
+
19
+ s.required_ruby_version = '>= 2.7'
20
+ end
metadata ADDED
@@ -0,0 +1,56 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: thai_geodata
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Your Name
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2025-06-15 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: A Ruby gem wrapping the MIT-licensed Thailand Geography JSON dataset,
14
+ with lookup helpers.
15
+ email:
16
+ - you@example.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - ".gitignore"
22
+ - Gemfile
23
+ - LICENSE
24
+ - README.md
25
+ - Rakefile
26
+ - lib/thai_geodata.rb
27
+ - lib/thai_geodata/data/districts.json
28
+ - lib/thai_geodata/data/provinces.json
29
+ - lib/thai_geodata/data/subdistricts.json
30
+ - lib/thai_geodata/version.rb
31
+ - test/test_thai_geodata.rb
32
+ - thai_geodata.gemspec
33
+ homepage: https://github.com/yourusername/thai_geodata
34
+ licenses:
35
+ - MIT
36
+ metadata: {}
37
+ post_install_message:
38
+ rdoc_options: []
39
+ require_paths:
40
+ - lib
41
+ required_ruby_version: !ruby/object:Gem::Requirement
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: '2.7'
46
+ required_rubygems_version: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: '0'
51
+ requirements: []
52
+ rubygems_version: 3.5.11
53
+ signing_key:
54
+ specification_version: 4
55
+ summary: 'Thailand geography data: provinces, districts, subdistricts, postal codes'
56
+ test_files: []