beerfyi 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: 071fdb9f15fd61143b6d63a3ec49549ee9eca23ea3aef98586e2b4ea8b8b2680
4
- data.tar.gz: '08550c61d8cda38c4485c1356554c4aad29626d29de62f6765b019133a0f8eb8'
3
+ metadata.gz: 6c4c78be59ae06777184f0c5646b5c910b28880e51e8009b98f90196ae3d1cd1
4
+ data.tar.gz: 7568ae5fe9d938783ef01c3ccd0b392df270b0d6dda16be6b7a7f2cd1be6743f
5
5
  SHA512:
6
- metadata.gz: 4bf0fd60a1c2d1ca2eb5629e70f0764e64f4bb58e6919cb52b32704503b922e7aefa68eeebc71242cf6eb93f691982c3b5483d8e4bfdedbdbf9df1e204e07992
7
- data.tar.gz: 3aabfb3bf9dcc2e2b85ce5c6b3eecd530b83f2dd82746be9dea4d03b5bb51641b656e5483c60e69959287ffa967d2b498e7382385c882990c15a3b06068cd62b
6
+ metadata.gz: f280dcd8f0c728c1245aa55249391d2d796c5a278eed2eb3d0e0b362934c2565790dbd238ceb65840cccc61a79dab2b88c7388dfb38bde60d2d783bedcec58de
7
+ data.tar.gz: 9b32230730fcce83a9f4b2754d145348ae4b665492abcb665a998b952a9aaac53ece75cf1eafbf0703527daddf198bc528ba6289e7d44d4c0ea02b595af10fd2
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "net/http"
4
+ require "json"
5
+ require "uri"
6
+
7
+ module BeerFYI
8
+ class Client
9
+ DEFAULT_BASE_URL = "https://beerfyi.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("/style/#{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 BeerFYI
4
+ VERSION = "0.1.1"
5
+ end
data/lib/beerfyi.rb CHANGED
@@ -1,143 +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 BeerFYI REST API (beerfyi.com).
8
- #
9
- # client = BeerFYI::Client.new
10
- # result = client.search("query")
11
- #
12
- module BeerFYI
13
- class Client
14
- BASE_URL = "https://beerfyi.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 breweries.
25
- def list_breweries
26
- get("/api/v1/breweries/")
27
- end
28
-
29
- # Get brewery by slug.
30
- def get_brewery(slug)
31
- get("/api/v1/breweries/#{slug}/")
32
- end
33
- # List all categories.
34
- def list_categories
35
- get("/api/v1/categories/")
36
- end
37
-
38
- # Get category by slug.
39
- def get_category(slug)
40
- get("/api/v1/categories/#{slug}/")
41
- end
42
- # List all countries.
43
- def list_countries
44
- get("/api/v1/countries/")
45
- end
46
-
47
- # Get country by slug.
48
- def get_country(slug)
49
- get("/api/v1/countries/#{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 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 hops.
79
- def list_hops
80
- get("/api/v1/hops/")
81
- end
82
-
83
- # Get hop by slug.
84
- def get_hop(slug)
85
- get("/api/v1/hops/#{slug}/")
86
- end
87
- # List all malts.
88
- def list_malts
89
- get("/api/v1/malts/")
90
- end
91
-
92
- # Get malt by slug.
93
- def get_malt(slug)
94
- get("/api/v1/malts/#{slug}/")
95
- end
96
- # List all regions.
97
- def list_regions
98
- get("/api/v1/regions/")
99
- end
100
-
101
- # Get region by slug.
102
- def get_region(slug)
103
- get("/api/v1/regions/#{slug}/")
104
- end
105
- # List all styles.
106
- def list_styles
107
- get("/api/v1/styles/")
108
- end
109
-
110
- # Get style by slug.
111
- def get_style(slug)
112
- get("/api/v1/styles/#{slug}/")
113
- end
114
- # List all tools.
115
- def list_tools
116
- get("/api/v1/tools/")
117
- end
118
-
119
- # Get tool by slug.
120
- def get_tool(slug)
121
- get("/api/v1/tools/#{slug}/")
122
- end
123
- # List all yeasts.
124
- def list_yeasts
125
- get("/api/v1/yeasts/")
126
- end
127
-
128
- # Get yeast by slug.
129
- def get_yeast(slug)
130
- get("/api/v1/yeasts/#{slug}/")
131
- end
132
-
133
- private
134
-
135
- def get(path, **params)
136
- uri = URI.join(@base_url, path)
137
- uri.query = URI.encode_www_form(params) unless params.empty?
138
- response = Net::HTTP.get_response(uri)
139
- raise "HTTP #{response.code}" unless response.is_a?(Net::HTTPSuccess)
140
- JSON.parse(response.body)
141
- end
142
- end
143
- end
3
+ require_relative "beerfyi/version"
4
+ require_relative "beerfyi/client"
metadata CHANGED
@@ -1,29 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: beerfyi
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 BeerFYI REST API at beerfyi.com. Zero external dependencies.
14
- email: dev@fyipedia.com
13
+ description: API client for beerfyi.com. Beer style guide with BJCP styles, hops,
14
+ malts, and yeast. 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/beerfyi.rb
22
+ - lib/beerfyi/client.rb
23
+ - lib/beerfyi/version.rb
20
24
  homepage: https://beerfyi.com
21
25
  licenses:
22
26
  - MIT
23
27
  metadata:
24
- source_code_uri: https://github.com/fyipedia/beerfyi-rb
25
- documentation_uri: https://beerfyi.com/api/v1/schema/
26
28
  homepage_uri: https://beerfyi.com
29
+ source_code_uri: https://github.com/fyipedia/beerfyi-rb
30
+ changelog_uri: https://github.com/fyipedia/beerfyi-rb/blob/main/CHANGELOG.md
31
+ documentation_uri: https://beerfyi.com/developers/
32
+ bug_tracker_uri: https://github.com/fyipedia/beerfyi-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 BeerFYI API
51
+ summary: Beer style guide with BJCP styles, hops, malts, and yeast
46
52
  test_files: []