calcfyi 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/calcfyi.rb +89 -0
- metadata +46 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 569ad399162cb11bdc292e02e082edb7620066db78355a498f7d86685b7978e9
|
|
4
|
+
data.tar.gz: 06b051d3584a39dd31341a124f368d559197776e2f84531bd37986af2289d30b
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 5d32983f22e32aecb2db19f263ab3037a6b954c4115d637d572c11e9ff9fe57567a34bfaeb777096371fbf68d9e3eb32382df6e52793bab58d122a8c1254873c
|
|
7
|
+
data.tar.gz: 0ec2edffbd9dec8ec8867cefce4df28c2e5f51ad27f48eef3f5dc55d96c5f83601e4b3aefbbaa36ef36ed3a19a94140e92a352ecd4edbfe4af66e9061f7c9adb
|
data/lib/calcfyi.rb
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "net/http"
|
|
4
|
+
require "json"
|
|
5
|
+
require "uri"
|
|
6
|
+
|
|
7
|
+
# Ruby client for CalcFYI REST API (calcfyi.com).
|
|
8
|
+
#
|
|
9
|
+
# client = CalcFYI::Client.new
|
|
10
|
+
# result = client.search("query")
|
|
11
|
+
#
|
|
12
|
+
module CalcFYI
|
|
13
|
+
class Client
|
|
14
|
+
BASE_URL = "https://calcfyi.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 comparisons.
|
|
25
|
+
def list_comparisons
|
|
26
|
+
get("/api/v1/comparisons/")
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# Get comparison by slug.
|
|
30
|
+
def get_comparison(slug)
|
|
31
|
+
get("/api/v1/comparisons/#{slug}/")
|
|
32
|
+
end
|
|
33
|
+
# List all faqs.
|
|
34
|
+
def list_faqs
|
|
35
|
+
get("/api/v1/faqs/")
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# Get faq by slug.
|
|
39
|
+
def get_faq(slug)
|
|
40
|
+
get("/api/v1/faqs/#{slug}/")
|
|
41
|
+
end
|
|
42
|
+
# List all formulas.
|
|
43
|
+
def list_formulas
|
|
44
|
+
get("/api/v1/formulas/")
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# Get formula by slug.
|
|
48
|
+
def get_formula(slug)
|
|
49
|
+
get("/api/v1/formulas/#{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 scenarios.
|
|
70
|
+
def list_scenarios
|
|
71
|
+
get("/api/v1/scenarios/")
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
# Get scenario by slug.
|
|
75
|
+
def get_scenario(slug)
|
|
76
|
+
get("/api/v1/scenarios/#{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
|
metadata
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: calcfyi
|
|
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 CalcFYI REST API at calcfyi.com. Zero external dependencies.
|
|
14
|
+
email: dev@fyipedia.com
|
|
15
|
+
executables: []
|
|
16
|
+
extensions: []
|
|
17
|
+
extra_rdoc_files: []
|
|
18
|
+
files:
|
|
19
|
+
- lib/calcfyi.rb
|
|
20
|
+
homepage: https://calcfyi.com
|
|
21
|
+
licenses:
|
|
22
|
+
- MIT
|
|
23
|
+
metadata:
|
|
24
|
+
source_code_uri: https://github.com/fyipedia/calcfyi-rb
|
|
25
|
+
documentation_uri: https://calcfyi.com/api/v1/schema/
|
|
26
|
+
homepage_uri: https://calcfyi.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 CalcFYI API
|
|
46
|
+
test_files: []
|