chemfyi 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/chemfyi.rb +134 -0
  3. metadata +46 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 0a354ece35bce5bd30e44f019e05874e790d3b40c44a33ffd8b4b0017447ccec
4
+ data.tar.gz: 8e3008f089fcea7df2daec6c8d7886e77b46acf422d4bebaffde22b6de5d79d9
5
+ SHA512:
6
+ metadata.gz: 1bf0fc7fde677228c22d6c297ce01a5f135e229a86b0dd9937003faea9f6b200d1922452c285ea545fce46865ca95b4b8c88cb6de9b3819013a7cc286b1131c1
7
+ data.tar.gz: 7af2617912af1957f432d3462b8c14218ce524ff22198f23704c8542d2794e910ffad5d7e8e144fc413d6e7abd9da67f3d940b9c08b5a9b8bca14624ee2b1693
data/lib/chemfyi.rb ADDED
@@ -0,0 +1,134 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "net/http"
4
+ require "json"
5
+ require "uri"
6
+
7
+ # Ruby client for ChemFYI REST API (chemfyi.com).
8
+ #
9
+ # client = ChemFYI::Client.new
10
+ # result = client.search("query")
11
+ #
12
+ module ChemFYI
13
+ class Client
14
+ BASE_URL = "https://chemfyi.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 applications.
25
+ def list_applications
26
+ get("/api/v1/applications/")
27
+ end
28
+
29
+ # Get application by slug.
30
+ def get_application(slug)
31
+ get("/api/v1/applications/#{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 compounds.
43
+ def list_compounds
44
+ get("/api/v1/compounds/")
45
+ end
46
+
47
+ # Get compound by slug.
48
+ def get_compound(slug)
49
+ get("/api/v1/compounds/#{slug}/")
50
+ end
51
+ # List all elements.
52
+ def list_elements
53
+ get("/api/v1/elements/")
54
+ end
55
+
56
+ # Get element by slug.
57
+ def get_element(slug)
58
+ get("/api/v1/elements/#{slug}/")
59
+ end
60
+ # List all experiments.
61
+ def list_experiments
62
+ get("/api/v1/experiments/")
63
+ end
64
+
65
+ # Get experiment by slug.
66
+ def get_experiment(slug)
67
+ get("/api/v1/experiments/#{slug}/")
68
+ end
69
+ # List all faqs.
70
+ def list_faqs
71
+ get("/api/v1/faqs/")
72
+ end
73
+
74
+ # Get faq by slug.
75
+ def get_faq(slug)
76
+ get("/api/v1/faqs/#{slug}/")
77
+ end
78
+ # List all glossary.
79
+ def list_glossary
80
+ get("/api/v1/glossary/")
81
+ end
82
+
83
+ # Get term by slug.
84
+ def get_term(slug)
85
+ get("/api/v1/glossary/#{slug}/")
86
+ end
87
+ # List all glossary categories.
88
+ def list_glossary_categories
89
+ get("/api/v1/glossary-categories/")
90
+ end
91
+
92
+ # Get glossary category by slug.
93
+ def get_glossary_category(slug)
94
+ get("/api/v1/glossary-categories/#{slug}/")
95
+ end
96
+ # List all guide series.
97
+ def list_guide_series
98
+ get("/api/v1/guide-series/")
99
+ end
100
+
101
+ # Get guide sery by slug.
102
+ def get_guide_sery(slug)
103
+ get("/api/v1/guide-series/#{slug}/")
104
+ end
105
+ # List all guides.
106
+ def list_guides
107
+ get("/api/v1/guides/")
108
+ end
109
+
110
+ # Get guide by slug.
111
+ def get_guide(slug)
112
+ get("/api/v1/guides/#{slug}/")
113
+ end
114
+ # List all reactions.
115
+ def list_reactions
116
+ get("/api/v1/reactions/")
117
+ end
118
+
119
+ # Get reaction by slug.
120
+ def get_reaction(slug)
121
+ get("/api/v1/reactions/#{slug}/")
122
+ end
123
+
124
+ private
125
+
126
+ def get(path, **params)
127
+ uri = URI.join(@base_url, path)
128
+ uri.query = URI.encode_www_form(params) unless params.empty?
129
+ response = Net::HTTP.get_response(uri)
130
+ raise "HTTP #{response.code}" unless response.is_a?(Net::HTTPSuccess)
131
+ JSON.parse(response.body)
132
+ end
133
+ end
134
+ end
metadata ADDED
@@ -0,0 +1,46 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: chemfyi
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 ChemFYI REST API at chemfyi.com. Zero external dependencies.
14
+ email: dev@fyipedia.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/chemfyi.rb
20
+ homepage: https://chemfyi.com
21
+ licenses:
22
+ - MIT
23
+ metadata:
24
+ source_code_uri: https://github.com/fyipedia/chemfyi-rb
25
+ documentation_uri: https://chemfyi.com/api/v1/schema/
26
+ homepage_uri: https://chemfyi.com
27
+ post_install_message:
28
+ rdoc_options: []
29
+ require_paths:
30
+ - lib
31
+ required_ruby_version: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - ">="
34
+ - !ruby/object:Gem::Version
35
+ version: '3.0'
36
+ required_rubygems_version: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ requirements: []
42
+ rubygems_version: 3.0.3.1
43
+ signing_key:
44
+ specification_version: 4
45
+ summary: Ruby client for ChemFYI API
46
+ test_files: []