distancefyi 0.1.0 → 0.1.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f9becf2728a964de68fb053a8a2addd6c703e8d703c74a34f6b0264ce5d5e5ff
4
- data.tar.gz: 06dc021b195ccb569f819c9cef3c210bfa33e41d4a7f34a5c166d6c5010bd6d3
3
+ metadata.gz: 0e64eb3f63a2c8c415f0c2357ec579b0bdf2ae35e7145a486c068b5aa21ace58
4
+ data.tar.gz: 3f7ef68fad6f19d0e59cc71ce62841fb3de73e65e45f04eaf5af50955c67b034
5
5
  SHA512:
6
- metadata.gz: 4f8527579117dc00ad91d5dcb859f26d98d53e147a7eb56ea3f75e00f23bd167af7f29d487a11882558e39c5c122dea15c0f2aef5f44dddd0c7e6d58566b746f
7
- data.tar.gz: 74a65b3b1bd3f6fc293f05edc423c53ce6567bda14b11fbcbe9a0530e9cf31b74d36cbc4a095246788fe3946cf514f3cbb5ce327ca77154cf8dec4fa018ff35c
6
+ metadata.gz: 8982e2649c314bc843cb2ccd96f582126550fd2b7dadd92110268c9fd08ff4ac925bbe5cc391125e3140c74f97a0b412c6bbcf476c0143aff39f62c914892e1c
7
+ data.tar.gz: 05cc327c9f040988f57982eecfc1361fe42fbcfbf4cdbda9af9867beed28c64838def9a770b03d007d41f3c3070a55013895af9a7718256b4c933dd88cd93995
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "net/http"
4
+ require "json"
5
+ require "uri"
6
+
7
+ module DistanceFYI
8
+ class Client
9
+ DEFAULT_BASE_URL = "https://distancefyi.com/api"
10
+
11
+ def initialize(base_url: DEFAULT_BASE_URL)
12
+ @base_url = base_url
13
+ end
14
+
15
+ def search(query)
16
+ get("/search/", q: query)
17
+ end
18
+
19
+ def entity(slug)
20
+ get("/city/#{slug}/")
21
+ end
22
+
23
+ def glossary_term(slug)
24
+ get("/glossary/#{slug}/")
25
+ end
26
+
27
+ def random
28
+ get("/random/")
29
+ end
30
+
31
+ private
32
+
33
+ def get(path, params = {})
34
+ uri = URI("#{@base_url}#{path}")
35
+ uri.query = URI.encode_www_form(params) unless params.empty?
36
+
37
+ response = Net::HTTP.get_response(uri)
38
+
39
+ unless response.is_a?(Net::HTTPSuccess)
40
+ raise Error, "HTTP #{response.code}: #{response.body}"
41
+ end
42
+
43
+ JSON.parse(response.body, symbolize_names: true)
44
+ end
45
+ end
46
+
47
+ class Error < StandardError; end
48
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DistanceFYI
4
+ VERSION = "0.1.1"
5
+ end
data/lib/distancefyi.rb CHANGED
@@ -1,62 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "net/http"
4
- require "json"
5
- require "uri"
6
-
7
- # Ruby client for DistanceFYI REST API (distancefyi.com).
8
- #
9
- # client = DistanceFYI::Client.new
10
- # result = client.search("query")
11
- #
12
- module DistanceFYI
13
- class Client
14
- BASE_URL = "https://distancefyi.com"
15
-
16
- def initialize(base_url: BASE_URL)
17
- @base_url = base_url
18
- end
19
-
20
- def search(query)
21
- get("/api/v1/search/", q: query)
22
- end
23
-
24
- # List all cities.
25
- def list_cities
26
- get("/api/v1/cities/")
27
- end
28
-
29
- # Get city by slug.
30
- def get_city(slug)
31
- get("/api/v1/cities/#{slug}/")
32
- end
33
- # List all countries.
34
- def list_countries
35
- get("/api/v1/countries/")
36
- end
37
-
38
- # Get country by slug.
39
- def get_country(slug)
40
- get("/api/v1/countries/#{slug}/")
41
- end
42
- # List all faqs.
43
- def list_faqs
44
- get("/api/v1/faqs/")
45
- end
46
-
47
- # Get faq by slug.
48
- def get_faq(slug)
49
- get("/api/v1/faqs/#{slug}/")
50
- end
51
-
52
- private
53
-
54
- def get(path, **params)
55
- uri = URI.join(@base_url, path)
56
- uri.query = URI.encode_www_form(params) unless params.empty?
57
- response = Net::HTTP.get_response(uri)
58
- raise "HTTP #{response.code}" unless response.is_a?(Net::HTTPSuccess)
59
- JSON.parse(response.body)
60
- end
61
- end
62
- end
3
+ require_relative "distancefyi/version"
4
+ require_relative "distancefyi/client"
metadata CHANGED
@@ -1,30 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: distancefyi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - FYIPedia
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-03-21 00:00:00.000000000 Z
11
+ date: 2026-03-30 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: Ruby client for the DistanceFYI REST API at distancefyi.com. Zero external
14
- dependencies.
15
- email: dev@fyipedia.com
13
+ description: API client for distancefyi.com. Haversine distance calculation and travel
14
+ time estimation. Zero dependencies.
15
+ email:
16
+ - hello@fyipedia.com
16
17
  executables: []
17
18
  extensions: []
18
19
  extra_rdoc_files: []
19
20
  files:
20
21
  - lib/distancefyi.rb
22
+ - lib/distancefyi/client.rb
23
+ - lib/distancefyi/version.rb
21
24
  homepage: https://distancefyi.com
22
25
  licenses:
23
26
  - MIT
24
27
  metadata:
25
- source_code_uri: https://github.com/fyipedia/distancefyi-rb
26
- documentation_uri: https://distancefyi.com/api/v1/schema/
27
28
  homepage_uri: https://distancefyi.com
29
+ source_code_uri: https://github.com/fyipedia/distancefyi-rb
30
+ changelog_uri: https://github.com/fyipedia/distancefyi-rb/blob/main/CHANGELOG.md
31
+ documentation_uri: https://distancefyi.com/developers/
32
+ bug_tracker_uri: https://github.com/fyipedia/distancefyi-rb/issues
28
33
  post_install_message:
29
34
  rdoc_options: []
30
35
  require_paths:
@@ -43,5 +48,5 @@ requirements: []
43
48
  rubygems_version: 3.0.3.1
44
49
  signing_key:
45
50
  specification_version: 4
46
- summary: Ruby client for DistanceFYI API
51
+ summary: Haversine distance calculation and travel time estimation
47
52
  test_files: []