cocktailfyi 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.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/cocktailfyi.rb +98 -0
  3. metadata +47 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: fe672ab77e168cebedbb5e55b92c21bc39ffe6eba67f8cd757e0bde9395f71f5
4
+ data.tar.gz: af37876731feeca6afa2dbcfb535e5f5660b1921ae60cd7fe7f18cef906feb7f
5
+ SHA512:
6
+ metadata.gz: 4575a65b9aae9526b7b8848b9edef02ce64bb5c208875f4815dfa8ba14fb3d1df8d958c146b2f5a83182fec63070688e72e26e8f9cf73f05bdddc0586ee600b5
7
+ data.tar.gz: ee2b363dd28cbba5815e4affd69d7b25928a2ab42eee1c41b645e3fa3ffe55e1e4ea9546f5656ad164497e6bf1daf5655090f3ecc849f56bb458c172e88ed6e2
@@ -0,0 +1,98 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "net/http"
4
+ require "json"
5
+ require "uri"
6
+
7
+ # Ruby client for CocktailFYI REST API (cocktailfyi.com).
8
+ #
9
+ # client = CocktailFYI::Client.new
10
+ # result = client.search("query")
11
+ #
12
+ module CocktailFYI
13
+ class Client
14
+ BASE_URL = "https://cocktailfyi.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 categories.
25
+ def list_categories
26
+ get("/api/v1/categories/")
27
+ end
28
+
29
+ # Get category by slug.
30
+ def get_category(slug)
31
+ get("/api/v1/categories/#{slug}/")
32
+ end
33
+ # List all cocktails.
34
+ def list_cocktails
35
+ get("/api/v1/cocktails/")
36
+ end
37
+
38
+ # Get cocktail by slug.
39
+ def get_cocktail(slug)
40
+ get("/api/v1/cocktails/#{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 glossary.
52
+ def list_glossary
53
+ get("/api/v1/glossary/")
54
+ end
55
+
56
+ # Get term by slug.
57
+ def get_term(slug)
58
+ get("/api/v1/glossary/#{slug}/")
59
+ end
60
+ # List all guides.
61
+ def list_guides
62
+ get("/api/v1/guides/")
63
+ end
64
+
65
+ # Get guide by slug.
66
+ def get_guide(slug)
67
+ get("/api/v1/guides/#{slug}/")
68
+ end
69
+ # List all ingredients.
70
+ def list_ingredients
71
+ get("/api/v1/ingredients/")
72
+ end
73
+
74
+ # Get ingredient by slug.
75
+ def get_ingredient(slug)
76
+ get("/api/v1/ingredients/#{slug}/")
77
+ end
78
+ # List all techniques.
79
+ def list_techniques
80
+ get("/api/v1/techniques/")
81
+ end
82
+
83
+ # Get technique by slug.
84
+ def get_technique(slug)
85
+ get("/api/v1/techniques/#{slug}/")
86
+ end
87
+
88
+ private
89
+
90
+ def get(path, **params)
91
+ uri = URI.join(@base_url, path)
92
+ uri.query = URI.encode_www_form(params) unless params.empty?
93
+ response = Net::HTTP.get_response(uri)
94
+ raise "HTTP #{response.code}" unless response.is_a?(Net::HTTPSuccess)
95
+ JSON.parse(response.body)
96
+ end
97
+ end
98
+ end
metadata ADDED
@@ -0,0 +1,47 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cocktailfyi
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - FYIPedia
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2026-03-21 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Ruby client for the CocktailFYI REST API at cocktailfyi.com. Zero external
14
+ dependencies.
15
+ email: dev@fyipedia.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - lib/cocktailfyi.rb
21
+ homepage: https://cocktailfyi.com
22
+ licenses:
23
+ - MIT
24
+ metadata:
25
+ source_code_uri: https://github.com/fyipedia/cocktailfyi-rb
26
+ documentation_uri: https://cocktailfyi.com/api/v1/schema/
27
+ homepage_uri: https://cocktailfyi.com
28
+ post_install_message:
29
+ rdoc_options: []
30
+ require_paths:
31
+ - lib
32
+ required_ruby_version: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: '3.0'
37
+ required_rubygems_version: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ requirements: []
43
+ rubygems_version: 3.0.3.1
44
+ signing_key:
45
+ specification_version: 4
46
+ summary: Ruby client for CocktailFYI API
47
+ test_files: []