namefyi 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: 34a00411afe636ca98df9f95764a383d952ee2f72fd8d3b41ede9084213f2332
4
- data.tar.gz: f0942160d2e476816bc7f1f3953ddc8d67490e45241e579f4afd7ca9b69e4ae3
3
+ metadata.gz: 35db2dd47f3f5b02ceead8d448ffa05e3a933ef49a4ccb4b1e9f8f02176e8bf5
4
+ data.tar.gz: 4636cb958b9efa30c8262438f920272f4c8388f16b266af3753628d09f02764f
5
5
  SHA512:
6
- metadata.gz: d8de88c0ef31efae8cae81c0b20bc6f919fa83a4866494008604bb4b5f3619e2c4e2d8650c53552a7a1194a10d9db343238d2bd8cf6c4f440eda26ed40758d75
7
- data.tar.gz: a4b6791328ea0e5a3e3c70224d8a5ad1f5488aba98f35b422a4bd9165c6be2e71c1454a5fe1fba91591ebe7f61c8304025ac39a629d3ea07feaba1c2c25a620f
6
+ metadata.gz: dc3f1bf51ee51f5be2ce93c1b616401864b4a1e16225dab733bcb5035847a659a9f3c9bd07079a7396a487096ebaa0b5bdf75aea9ac6d242c8721b6f49221218
7
+ data.tar.gz: f935e8e7cc5d75ad202965bacc29b02fb21d106f0bc22d1b89f5a65109419004015fbc3c652fe9dad31b3f6755ed919c8f06bd01bf28b0dde4d363504890ee3a
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "net/http"
4
+ require "json"
5
+ require "uri"
6
+
7
+ module NameFYI
8
+ class Client
9
+ DEFAULT_BASE_URL = "https://namefyi.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("/name/#{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 NameFYI
4
+ VERSION = "0.1.1"
5
+ end
data/lib/namefyi.rb CHANGED
@@ -1,107 +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 NameFYI REST API (namefyi.com).
8
- #
9
- # client = NameFYI::Client.new
10
- # result = client.search("query")
11
- #
12
- module NameFYI
13
- class Client
14
- BASE_URL = "https://namefyi.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 cultures.
34
- def list_cultures
35
- get("/api/v1/cultures/")
36
- end
37
-
38
- # Get culture by slug.
39
- def get_culture(slug)
40
- get("/api/v1/cultures/#{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
- # List all given names.
52
- def list_given_names
53
- get("/api/v1/given-names/")
54
- end
55
-
56
- # Get given name by slug.
57
- def get_given_name(slug)
58
- get("/api/v1/given-names/#{slug}/")
59
- end
60
- # List all glossary.
61
- def list_glossary
62
- get("/api/v1/glossary/")
63
- end
64
-
65
- # Get term by slug.
66
- def get_term(slug)
67
- get("/api/v1/glossary/#{slug}/")
68
- end
69
- # List all guides.
70
- def list_guides
71
- get("/api/v1/guides/")
72
- end
73
-
74
- # Get guide by slug.
75
- def get_guide(slug)
76
- get("/api/v1/guides/#{slug}/")
77
- end
78
- # List all meaning tags.
79
- def list_meaning_tags
80
- get("/api/v1/meaning-tags/")
81
- end
82
-
83
- # Get meaning tag by slug.
84
- def get_meaning_tag(slug)
85
- get("/api/v1/meaning-tags/#{slug}/")
86
- end
87
- # List all surnames.
88
- def list_surnames
89
- get("/api/v1/surnames/")
90
- end
91
-
92
- # Get surname by slug.
93
- def get_surname(slug)
94
- get("/api/v1/surnames/#{slug}/")
95
- end
96
-
97
- private
98
-
99
- def get(path, **params)
100
- uri = URI.join(@base_url, path)
101
- uri.query = URI.encode_www_form(params) unless params.empty?
102
- response = Net::HTTP.get_response(uri)
103
- raise "HTTP #{response.code}" unless response.is_a?(Net::HTTPSuccess)
104
- JSON.parse(response.body)
105
- end
106
- end
107
- end
3
+ require_relative "namefyi/version"
4
+ require_relative "namefyi/client"
metadata CHANGED
@@ -1,29 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: namefyi
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 NameFYI REST API at namefyi.com. Zero external dependencies.
14
- email: dev@fyipedia.com
13
+ description: API client for namefyi.com. Korean romanization, Five Elements, and CJK
14
+ stroke lookup. Zero dependencies.
15
+ email:
16
+ - hello@fyipedia.com
15
17
  executables: []
16
18
  extensions: []
17
19
  extra_rdoc_files: []
18
20
  files:
19
21
  - lib/namefyi.rb
22
+ - lib/namefyi/client.rb
23
+ - lib/namefyi/version.rb
20
24
  homepage: https://namefyi.com
21
25
  licenses:
22
26
  - MIT
23
27
  metadata:
24
- source_code_uri: https://github.com/fyipedia/namefyi-rb
25
- documentation_uri: https://namefyi.com/api/v1/schema/
26
28
  homepage_uri: https://namefyi.com
29
+ source_code_uri: https://github.com/fyipedia/namefyi-rb
30
+ changelog_uri: https://github.com/fyipedia/namefyi-rb/blob/main/CHANGELOG.md
31
+ documentation_uri: https://namefyi.com/developers/
32
+ bug_tracker_uri: https://github.com/fyipedia/namefyi-rb/issues
27
33
  post_install_message:
28
34
  rdoc_options: []
29
35
  require_paths:
@@ -42,5 +48,5 @@ requirements: []
42
48
  rubygems_version: 3.0.3.1
43
49
  signing_key:
44
50
  specification_version: 4
45
- summary: Ruby client for NameFYI API
51
+ summary: Korean romanization, Five Elements, and CJK stroke lookup
46
52
  test_files: []