drinkfyi 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.
- checksums.yaml +7 -0
- data/lib/drinkfyi/client.rb +48 -0
- data/lib/drinkfyi/version.rb +5 -0
- data/lib/drinkfyi.rb +4 -0
- metadata +52 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 6bbe914c4dbcd0248b9d9ec08b07fee85cb6d24f3ac9b0b33c9f62c0d19eec85
|
|
4
|
+
data.tar.gz: f221b02758fdac15b7c49e198593007d595ff27b183f5a704f958d3d7280de55
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 4d529469185637afe0d3d4b4b8cb18663ed0b3903ab988c83c120e238e3b5908b1985711e891b970af7da7e2e3fe85d3030c005ea82f43f22fb755d8452abb33
|
|
7
|
+
data.tar.gz: 754a702822654aa31bd0942cc8cfae65705a336c96b7f32378a18e0664a1b1b1ba587011a485d5a0b354fcba48c6188b394f63d1ef79e26206c566e73aa12000
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "net/http"
|
|
4
|
+
require "json"
|
|
5
|
+
require "uri"
|
|
6
|
+
|
|
7
|
+
module DrinkFYI
|
|
8
|
+
class Client
|
|
9
|
+
DEFAULT_BASE_URL = "https://drinkfyi.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("/beverage/#{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
|
data/lib/drinkfyi.rb
ADDED
metadata
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: drinkfyi
|
|
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-30 00:00:00.000000000 Z
|
|
12
|
+
dependencies: []
|
|
13
|
+
description: API client for drinkfyi.com. Beverage encyclopedia hub for cocktails,
|
|
14
|
+
wine, beer, and more. Zero dependencies.
|
|
15
|
+
email:
|
|
16
|
+
- hello@fyipedia.com
|
|
17
|
+
executables: []
|
|
18
|
+
extensions: []
|
|
19
|
+
extra_rdoc_files: []
|
|
20
|
+
files:
|
|
21
|
+
- lib/drinkfyi.rb
|
|
22
|
+
- lib/drinkfyi/client.rb
|
|
23
|
+
- lib/drinkfyi/version.rb
|
|
24
|
+
homepage: https://drinkfyi.com
|
|
25
|
+
licenses:
|
|
26
|
+
- MIT
|
|
27
|
+
metadata:
|
|
28
|
+
homepage_uri: https://drinkfyi.com
|
|
29
|
+
source_code_uri: https://github.com/fyipedia/drinkfyi-rb
|
|
30
|
+
changelog_uri: https://github.com/fyipedia/drinkfyi-rb/blob/main/CHANGELOG.md
|
|
31
|
+
documentation_uri: https://drinkfyi.com/developers/
|
|
32
|
+
bug_tracker_uri: https://github.com/fyipedia/drinkfyi-rb/issues
|
|
33
|
+
post_install_message:
|
|
34
|
+
rdoc_options: []
|
|
35
|
+
require_paths:
|
|
36
|
+
- lib
|
|
37
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
38
|
+
requirements:
|
|
39
|
+
- - ">="
|
|
40
|
+
- !ruby/object:Gem::Version
|
|
41
|
+
version: '3.0'
|
|
42
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
43
|
+
requirements:
|
|
44
|
+
- - ">="
|
|
45
|
+
- !ruby/object:Gem::Version
|
|
46
|
+
version: '0'
|
|
47
|
+
requirements: []
|
|
48
|
+
rubygems_version: 3.0.3.1
|
|
49
|
+
signing_key:
|
|
50
|
+
specification_version: 4
|
|
51
|
+
summary: Beverage encyclopedia hub for cocktails, wine, beer, and more
|
|
52
|
+
test_files: []
|