colorfyi 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: a8783e6b573411e921f5d59544f9691bf47a3779f5f21ff5ce94b16175c04f08
4
- data.tar.gz: 2727db9d90759793763f0a3830f153954fad897b495658e93418eeaecc195841
3
+ metadata.gz: 984edbbb49b9975637d7468adb0912f74c8087ee49955ee8b61c2ef55e456f80
4
+ data.tar.gz: 05cee14dee539b87c44bbe61df303c5becac8b3eae376cb6c99c02c1f2c56692
5
5
  SHA512:
6
- metadata.gz: da2a1fe96e9596e4e6fbe7b98bb70e75f987d16eee1da94082586b496d807292874aa699166b08fbb6828b21bd9c6b44e7c5ddc1d670783400096c2f4644354f
7
- data.tar.gz: 1c389d1f0c1b9e8b190b0bdbb1438c7367029056aeb5f5d0f1b38f4e9d81cb7e427c68546b57a2194ae3f63a7af2b395d5f7f2801fc0e2f6cbb8392f4f630d45
6
+ metadata.gz: 1903933a3634f2d9cadadd3cf17b05044ab0893df4ef6b39229d7ebea078471cbaad5b74bea68a8fb611179b5743af093eacf6f0f928adaf3d0bde30102238ca
7
+ data.tar.gz: 58a61763583692e20974f266ad0b2c8d39b79810546f61eb57b5f6bb6169a9883b9f45b3d94d9b4bbfe7ccbec60676fb95d65103a8bc7ebbdcdd1abec031e248
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "net/http"
4
+ require "json"
5
+ require "uri"
6
+
7
+ module ColorFYI
8
+ class Client
9
+ DEFAULT_BASE_URL = "https://colorfyi.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("/color/#{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 ColorFYI
4
+ VERSION = "0.1.1"
5
+ end
data/lib/colorfyi.rb CHANGED
@@ -1,89 +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 ColorFYI REST API (colorfyi.com).
8
- #
9
- # client = ColorFYI::Client.new
10
- # result = client.search("query")
11
- #
12
- module ColorFYI
13
- class Client
14
- BASE_URL = "https://colorfyi.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 brands.
25
- def list_brands
26
- get("/api/v1/brands/")
27
- end
28
-
29
- # Get brand by slug.
30
- def get_brand(slug)
31
- get("/api/v1/brands/#{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 colors.
43
- def list_colors
44
- get("/api/v1/colors/")
45
- end
46
-
47
- # Get color by slug.
48
- def get_color(slug)
49
- get("/api/v1/colors/#{slug}/")
50
- end
51
- # List all faqs.
52
- def list_faqs
53
- get("/api/v1/faqs/")
54
- end
55
-
56
- # Get faq by slug.
57
- def get_faq(slug)
58
- get("/api/v1/faqs/#{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 posts.
70
- def list_posts
71
- get("/api/v1/posts/")
72
- end
73
-
74
- # Get post by slug.
75
- def get_post(slug)
76
- get("/api/v1/posts/#{slug}/")
77
- end
78
-
79
- private
80
-
81
- def get(path, **params)
82
- uri = URI.join(@base_url, path)
83
- uri.query = URI.encode_www_form(params) unless params.empty?
84
- response = Net::HTTP.get_response(uri)
85
- raise "HTTP #{response.code}" unless response.is_a?(Net::HTTPSuccess)
86
- JSON.parse(response.body)
87
- end
88
- end
89
- end
3
+ require_relative "colorfyi/version"
4
+ require_relative "colorfyi/client"
metadata CHANGED
@@ -1,30 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: colorfyi
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 ColorFYI REST API at colorfyi.com. Zero external
14
- dependencies.
15
- email: dev@fyipedia.com
13
+ description: API client for colorfyi.com. Color conversion, WCAG contrast, and color
14
+ space lookup. 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/colorfyi.rb
22
+ - lib/colorfyi/client.rb
23
+ - lib/colorfyi/version.rb
21
24
  homepage: https://colorfyi.com
22
25
  licenses:
23
26
  - MIT
24
27
  metadata:
25
- source_code_uri: https://github.com/fyipedia/colorfyi-rb
26
- documentation_uri: https://colorfyi.com/api/v1/schema/
27
28
  homepage_uri: https://colorfyi.com
29
+ source_code_uri: https://github.com/fyipedia/colorfyi-rb
30
+ changelog_uri: https://github.com/fyipedia/colorfyi-rb/blob/main/CHANGELOG.md
31
+ documentation_uri: https://colorfyi.com/developers/
32
+ bug_tracker_uri: https://github.com/fyipedia/colorfyi-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 ColorFYI API
51
+ summary: Color conversion, WCAG contrast, and color space lookup
47
52
  test_files: []