unicodefyi 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: 78845b34afb9d5b49d1d40ea4581ef8124f0938e6bb68bece0af629a286f29d8
4
- data.tar.gz: 8a5e8dae870882c944b6310033f75a0c2658cae98d1a4843ad627e25c560fecc
3
+ metadata.gz: 8f4984bebb01e79d9e7f72adf3e5adaf5b4d9b367640679dab3dd00826430f52
4
+ data.tar.gz: 40c21c8a943a8eb83486bb4c446de44ebd1266a7a8725944b24505b93a340883
5
5
  SHA512:
6
- metadata.gz: cc8d9563b005f7bcf0e47882353e7b6e3e4bde45b63f41bad6c61ceb0794334ed319c52841f1f90cf43e0b3ae97f82f6eb543afd50f95b12e26906e48e227f0f
7
- data.tar.gz: 8c7e587d905c313dcc19c1352064ea73446be1329b7db34e173c0584f8a1a1bf7e310be458dc84020fc40d4c76e48f40b8fdc3706cf3f7128df64969601048d3
6
+ metadata.gz: e2c89757e59ce27f3f9a15eb43cbf9025e8a57fa60e141084172a1c33f33057bbbfd4ad3e37d3e7bfe8f1e4e89e1b35142f50cbe50b761ad0f3b77c678c69adf
7
+ data.tar.gz: ff709da3fd63387d051711620ebd7762f2b9b859971e33660a3c03a828d3b55ef00c2e730f7537e1ee7a0c49ee2e196ec9ba80f38b8f93da1fa14ec06f6a53f7
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "net/http"
4
+ require "json"
5
+ require "uri"
6
+
7
+ module UnicodeFYI
8
+ class Client
9
+ DEFAULT_BASE_URL = "https://unicodefyi.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("/character/#{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 UnicodeFYI
4
+ VERSION = "0.1.1"
5
+ end
data/lib/unicodefyi.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 UnicodeFYI REST API (unicodefyi.com).
8
- #
9
- # client = UnicodeFYI::Client.new
10
- # result = client.search("query")
11
- #
12
- module UnicodeFYI
13
- class Client
14
- BASE_URL = "https://unicodefyi.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 characters.
25
- def list_characters
26
- get("/api/v1/characters/")
27
- end
28
-
29
- # Get character by slug.
30
- def get_character(slug)
31
- get("/api/v1/characters/#{slug}/")
32
- end
33
- # List all collections.
34
- def list_collections
35
- get("/api/v1/collections/")
36
- end
37
-
38
- # Get collection by slug.
39
- def get_collection(slug)
40
- get("/api/v1/collections/#{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 "unicodefyi/version"
4
+ require_relative "unicodefyi/client"
metadata CHANGED
@@ -1,30 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unicodefyi
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 UnicodeFYI REST API at unicodefyi.com. Zero external
14
- dependencies.
15
- email: dev@fyipedia.com
13
+ description: API client for unicodefyi.com. Unicode character lookup with 17 encodings.
14
+ 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/unicodefyi.rb
22
+ - lib/unicodefyi/client.rb
23
+ - lib/unicodefyi/version.rb
21
24
  homepage: https://unicodefyi.com
22
25
  licenses:
23
26
  - MIT
24
27
  metadata:
25
- source_code_uri: https://github.com/fyipedia/unicodefyi-rb
26
- documentation_uri: https://unicodefyi.com/api/v1/schema/
27
28
  homepage_uri: https://unicodefyi.com
29
+ source_code_uri: https://github.com/fyipedia/unicodefyi-rb
30
+ changelog_uri: https://github.com/fyipedia/unicodefyi-rb/blob/main/CHANGELOG.md
31
+ documentation_uri: https://unicodefyi.com/developers/
32
+ bug_tracker_uri: https://github.com/fyipedia/unicodefyi-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 UnicodeFYI API
51
+ summary: Unicode character lookup with 17 encodings
47
52
  test_files: []