widesutra 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/LICENSE +21 -0
- data/README.md +233 -0
- data/lib/widesutra/client.rb +204 -0
- data/lib/widesutra/version.rb +5 -0
- data/lib/widesutra.rb +4 -0
- metadata +55 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 656a4dec6e96f30b312cb9624982ac177e08a129e2bf91057cda30cba337da97
|
|
4
|
+
data.tar.gz: 1d94ff31e22863e5fafeaa79d4aba2ea4fde430d0f59a5f11ff05719ffb1066e
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 6ec0836c0f913e1b3bf3a599225c62f835be09a6ba23dc3ddb3b997112835a199926e6c94b743a1222dea86f6551e1dabed13fed06d0b76fcc703a99155a7b49
|
|
7
|
+
data.tar.gz: 7e970e76c4c7a176003d66180e438ba813c0c0838e6b00015243104e5c8e312df1857cae31eee0e3fd2418ed2e6e405fd4aff4c1ccf5cbc5713d3d13e508ef59
|
data/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 WideHoly
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
# widesutra
|
|
2
|
+
|
|
3
|
+
[](https://rubygems.org/gems/widesutra)
|
|
4
|
+
[](https://www.ruby-lang.org/)
|
|
5
|
+
[](https://opensource.org/licenses/MIT)
|
|
6
|
+
[](https://rubygems.org/gems/widesutra)
|
|
7
|
+
|
|
8
|
+
Ruby client for the [WideSutra](https://widesutra.com) API. Access Buddhist scripture collections (Tipitaka, Mahayana Sutras), individual books (Dhammapada, Heart Sutra, Diamond Sutra), texts with Pali and Sanskrit originals, multiple translations (Sujato, Thanissaro), Buddhist figures, core concepts (Four Noble Truths, Noble Eightfold Path), and a Pali/Sanskrit glossary. Zero runtime dependencies -- uses only Ruby stdlib (`net/http`, `json`, `uri`).
|
|
9
|
+
|
|
10
|
+
WideSutra is a comprehensive Buddhist scripture encyclopedia providing structured access to the Theravada Pali Canon, Mahayana sutras, and the broader Buddhist intellectual tradition -- all accessible through a free REST API.
|
|
11
|
+
|
|
12
|
+
> **Explore Buddhist scriptures at [widesutra.com](https://widesutra.com)** -- [Collections](https://widesutra.com/collections/), [Books](https://widesutra.com/books/), [Figures](https://widesutra.com/figures/), [Concepts](https://widesutra.com/concepts/), [Glossary](https://widesutra.com/glossary/)
|
|
13
|
+
|
|
14
|
+
## Table of Contents
|
|
15
|
+
|
|
16
|
+
- [Install](#install)
|
|
17
|
+
- [Quick Start](#quick-start)
|
|
18
|
+
- [What You Can Do](#what-you-can-do)
|
|
19
|
+
- [Browse Scripture Collections](#browse-scripture-collections)
|
|
20
|
+
- [Read Books](#read-books)
|
|
21
|
+
- [Look Up Texts](#look-up-texts)
|
|
22
|
+
- [Search Scripture](#search-scripture)
|
|
23
|
+
- [Discover Buddhist Figures](#discover-buddhist-figures)
|
|
24
|
+
- [Explore Core Concepts](#explore-core-concepts)
|
|
25
|
+
- [Browse Topics and Glossary](#browse-topics-and-glossary)
|
|
26
|
+
- [API Reference](#api-reference)
|
|
27
|
+
- [Learn More About Buddhist Scripture](#learn-more-about-buddhist-scripture)
|
|
28
|
+
- [WideHoly Scripture Family](#wideholy-scripture-family)
|
|
29
|
+
- [Also Available](#also-available)
|
|
30
|
+
- [License](#license)
|
|
31
|
+
|
|
32
|
+
## Install
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
gem install widesutra
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Or add to your Gemfile:
|
|
39
|
+
|
|
40
|
+
```ruby
|
|
41
|
+
gem "widesutra"
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Quick Start
|
|
45
|
+
|
|
46
|
+
```ruby
|
|
47
|
+
require "widesutra"
|
|
48
|
+
|
|
49
|
+
# Create a client (zero configuration needed)
|
|
50
|
+
client = WideSutra::Client.new
|
|
51
|
+
|
|
52
|
+
# List scripture collections
|
|
53
|
+
collections = client.list_collections
|
|
54
|
+
puts collections["results"].first["name"]
|
|
55
|
+
|
|
56
|
+
# Get a Dhammapada verse
|
|
57
|
+
text = client.get_text("dhammapada", 1, 1)
|
|
58
|
+
puts text["results"].first["text"]
|
|
59
|
+
|
|
60
|
+
# Search across all Buddhist scriptures
|
|
61
|
+
results = client.search("four noble truths")
|
|
62
|
+
results["results"].each { |t| puts t["text"] }
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## What You Can Do
|
|
66
|
+
|
|
67
|
+
### Browse Scripture Collections
|
|
68
|
+
|
|
69
|
+
Buddhist scriptures are organized into major collections by tradition. The Theravada tradition preserves the Tipitaka (Three Baskets): Vinaya Pitaka (monastic rules), Sutta Pitaka (discourses), and Abhidhamma Pitaka (philosophical analysis). Mahayana traditions add sutras like the Heart Sutra and Lotus Sutra.
|
|
70
|
+
|
|
71
|
+
```ruby
|
|
72
|
+
# List all collections
|
|
73
|
+
collections = client.list_collections
|
|
74
|
+
|
|
75
|
+
# Filter by tradition
|
|
76
|
+
theravada = client.list_collections(tradition: "theravada")
|
|
77
|
+
mahayana = client.list_collections(tradition: "mahayana")
|
|
78
|
+
|
|
79
|
+
# Get details for the Tipitaka
|
|
80
|
+
tipitaka = client.get_collection("tipitaka")
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Read Books
|
|
84
|
+
|
|
85
|
+
Individual scriptures within the collections -- from the Dhammapada (verses of the Buddha) to the Heart Sutra (Prajnaparamita) and the Lotus Sutra (Saddharma Pundarika).
|
|
86
|
+
|
|
87
|
+
```ruby
|
|
88
|
+
# List all books
|
|
89
|
+
books = client.list_books
|
|
90
|
+
|
|
91
|
+
# Filter by collection
|
|
92
|
+
sutta_pitaka = client.list_books(collection: "sutta-pitaka")
|
|
93
|
+
|
|
94
|
+
# Get details for the Dhammapada
|
|
95
|
+
dhammapada = client.get_book("dhammapada")
|
|
96
|
+
puts dhammapada["name"]
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Look Up Texts
|
|
100
|
+
|
|
101
|
+
Access individual verses and passages with Pali or Sanskrit originals alongside scholarly translations. Bhikkhu Sujato's translation is the default for Pali Canon texts.
|
|
102
|
+
|
|
103
|
+
```ruby
|
|
104
|
+
# Get a specific text passage
|
|
105
|
+
text = client.get_text("dhammapada", 1, 1, translation: "sujato")
|
|
106
|
+
|
|
107
|
+
# Use a different translation
|
|
108
|
+
text = client.get_text("dhammapada", 1, 1, translation: "thanissaro")
|
|
109
|
+
|
|
110
|
+
# Browse available translations
|
|
111
|
+
translations = client.list_translations
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Search Scripture
|
|
115
|
+
|
|
116
|
+
Full-text search across all Buddhist texts with relevance ranking.
|
|
117
|
+
|
|
118
|
+
```ruby
|
|
119
|
+
# Search across all scriptures
|
|
120
|
+
results = client.search("suffering", limit: 10)
|
|
121
|
+
results["results"].each do |text|
|
|
122
|
+
puts text["text"]
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
# Search for specific Buddhist concepts
|
|
126
|
+
results = client.search("dependent origination")
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### Discover Buddhist Figures
|
|
130
|
+
|
|
131
|
+
Profiles of key figures in Buddhist history -- Siddhartha Gautama (the historical Buddha), bodhisattvas like Avalokiteshvara and Manjushri, and influential monks and scholars across Theravada and Mahayana traditions.
|
|
132
|
+
|
|
133
|
+
```ruby
|
|
134
|
+
# List all figures
|
|
135
|
+
figures = client.list_figures
|
|
136
|
+
|
|
137
|
+
# Filter by tradition
|
|
138
|
+
theravada_figures = client.list_figures(tradition: "theravada")
|
|
139
|
+
|
|
140
|
+
# Get the Buddha's profile
|
|
141
|
+
buddha = client.get_figure("siddhartha-gautama")
|
|
142
|
+
puts buddha["name"]
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### Explore Core Concepts
|
|
146
|
+
|
|
147
|
+
Central Buddhist doctrines and philosophical concepts -- the Four Noble Truths, Noble Eightfold Path, Three Marks of Existence, Dependent Origination, and more.
|
|
148
|
+
|
|
149
|
+
| Concept | Pali/Sanskrit | Description |
|
|
150
|
+
|---------|---------------|-------------|
|
|
151
|
+
| Four Noble Truths | Cattari Ariyasaccani | Suffering, origin, cessation, path |
|
|
152
|
+
| Noble Eightfold Path | Ariya Atthangika Magga | Right view through right concentration |
|
|
153
|
+
| Three Marks | Tilakkhana | Impermanence, suffering, non-self |
|
|
154
|
+
| Dependent Origination | Paticca Samuppada | 12-link chain of causation |
|
|
155
|
+
| Five Aggregates | Panca Khandha | Form, feeling, perception, formations, consciousness |
|
|
156
|
+
|
|
157
|
+
```ruby
|
|
158
|
+
# List concepts
|
|
159
|
+
concepts = client.list_concepts
|
|
160
|
+
|
|
161
|
+
# Filter by category
|
|
162
|
+
meditation = client.list_concepts(category: "meditation")
|
|
163
|
+
|
|
164
|
+
# Get the Four Noble Truths
|
|
165
|
+
fnt = client.get_concept("four-noble-truths")
|
|
166
|
+
puts fnt["description"]
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
### Browse Topics and Glossary
|
|
170
|
+
|
|
171
|
+
Thematic verse collections and a Pali/Sanskrit glossary with definitions, etymology, and usage contexts.
|
|
172
|
+
|
|
173
|
+
```ruby
|
|
174
|
+
# Browse topics
|
|
175
|
+
topics = client.list_topics
|
|
176
|
+
topic = client.get_topic("compassion")
|
|
177
|
+
|
|
178
|
+
# Browse glossary
|
|
179
|
+
terms = client.list_glossary
|
|
180
|
+
term = client.get_glossary_term("nibbana")
|
|
181
|
+
puts term["definition"]
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
## API Reference
|
|
185
|
+
|
|
186
|
+
| Method | Description |
|
|
187
|
+
|--------|-------------|
|
|
188
|
+
| `list_collections(tradition:)` | List scripture collections |
|
|
189
|
+
| `get_collection(slug)` | Get collection details |
|
|
190
|
+
| `list_books(collection:)` | List books in collections |
|
|
191
|
+
| `get_book(slug)` | Get book details |
|
|
192
|
+
| `get_text(book, chapter, verse, translation:)` | Get a specific text |
|
|
193
|
+
| `search(query, limit:)` | Search scripture texts |
|
|
194
|
+
| `list_translations` | List available translations |
|
|
195
|
+
| `get_translation(code)` | Get translation details |
|
|
196
|
+
| `list_figures(tradition:)` | List Buddhist figures |
|
|
197
|
+
| `get_figure(slug)` | Get figure details |
|
|
198
|
+
| `list_concepts(category:)` | List Buddhist concepts |
|
|
199
|
+
| `get_concept(slug)` | Get concept details |
|
|
200
|
+
| `list_topics` | List topics and themes |
|
|
201
|
+
| `get_topic(slug)` | Get topic details |
|
|
202
|
+
| `list_glossary` | List Pali/Sanskrit glossary |
|
|
203
|
+
| `get_glossary_term(slug)` | Get term definition |
|
|
204
|
+
|
|
205
|
+
## Learn More About Buddhist Scripture
|
|
206
|
+
|
|
207
|
+
- **Browse**: [Collections](https://widesutra.com/collections/) -- [Books](https://widesutra.com/books/) -- [Figures](https://widesutra.com/figures/)
|
|
208
|
+
- **Study**: [Concepts](https://widesutra.com/concepts/) -- [Topics](https://widesutra.com/topics/) -- [Glossary](https://widesutra.com/glossary/)
|
|
209
|
+
- **API**: [REST API Docs](https://widesutra.com/developers/) -- [OpenAPI Spec](https://widesutra.com/api/openapi.json)
|
|
210
|
+
|
|
211
|
+
## WideHoly Scripture Family
|
|
212
|
+
|
|
213
|
+
Part of the [WideHoly](https://wideholy.com) multi-religion scripture platform.
|
|
214
|
+
|
|
215
|
+
| Site | Domain | Focus |
|
|
216
|
+
|------|--------|-------|
|
|
217
|
+
| WideBible | [widebible.com](https://widebible.com) | 66 books, 31,102 verses, KJV/ASV/BBE/YLT, cross-references |
|
|
218
|
+
| WideQuran | [widequran.com](https://widequran.com) | 114 surahs, 6,236 ayahs, hadith collections, tafsir |
|
|
219
|
+
| WideTorah | [widetorah.com](https://widetorah.com) | Tanakh, Talmud tractates, parashot, Rashi commentary |
|
|
220
|
+
| WideGita | [widegita.com](https://widegita.com) | 18 chapters, 700 verses, Upanishads, Yoga Sutras |
|
|
221
|
+
| **WideSutra** | [widesutra.com](https://widesutra.com) | **Tipitaka, Pali Canon, Mahayana sutras, Buddhist figures** |
|
|
222
|
+
| WideHoly | [wideholy.com](https://wideholy.com) | Cross-religion search, verse comparison, shared topics |
|
|
223
|
+
|
|
224
|
+
## Also Available
|
|
225
|
+
|
|
226
|
+
| Platform | Install | Link |
|
|
227
|
+
|----------|---------|------|
|
|
228
|
+
| **PyPI** | `pip install widesutra` | [PyPI](https://pypi.org/project/widesutra/) |
|
|
229
|
+
| **npm** | `npm install widesutra` | [npm](https://www.npmjs.com/package/widesutra) |
|
|
230
|
+
|
|
231
|
+
## License
|
|
232
|
+
|
|
233
|
+
MIT
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "net/http"
|
|
4
|
+
require "json"
|
|
5
|
+
require "uri"
|
|
6
|
+
|
|
7
|
+
module WideSutra
|
|
8
|
+
# HTTP client for the WideSutra REST API.
|
|
9
|
+
#
|
|
10
|
+
# Zero runtime dependencies -- uses only Ruby stdlib (net/http, json, uri).
|
|
11
|
+
#
|
|
12
|
+
# client = WideSutra::Client.new
|
|
13
|
+
# collections = client.list_collections
|
|
14
|
+
# text = client.get_text("dhammapada", 1, 1)
|
|
15
|
+
# results = client.search("four noble truths")
|
|
16
|
+
#
|
|
17
|
+
class Client
|
|
18
|
+
DEFAULT_BASE_URL = "https://widesutra.com/api/v1/sutra"
|
|
19
|
+
DEFAULT_TIMEOUT = 10
|
|
20
|
+
|
|
21
|
+
def initialize(base_url: DEFAULT_BASE_URL, timeout: DEFAULT_TIMEOUT)
|
|
22
|
+
@base_url = base_url.chomp("/")
|
|
23
|
+
@timeout = timeout
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# --- Collections ----------------------------------------------------------
|
|
27
|
+
|
|
28
|
+
# List scripture collections (Tipitaka, Mahayana Sutras, etc.).
|
|
29
|
+
#
|
|
30
|
+
# @param tradition [String, nil] filter by tradition ("theravada", "mahayana")
|
|
31
|
+
# @return [Hash] paginated list of collections
|
|
32
|
+
def list_collections(tradition: nil, **params)
|
|
33
|
+
get("/collections/", { tradition: tradition }.merge(params))
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# Get collection details by slug (e.g. "tipitaka").
|
|
37
|
+
#
|
|
38
|
+
# @param slug [String] collection URL slug
|
|
39
|
+
# @return [Hash] collection details
|
|
40
|
+
def get_collection(slug)
|
|
41
|
+
get("/collections/#{slug}/")
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# --- Books ----------------------------------------------------------------
|
|
45
|
+
|
|
46
|
+
# List books within scripture collections.
|
|
47
|
+
#
|
|
48
|
+
# @param collection [String, nil] filter by collection slug
|
|
49
|
+
# @return [Hash] paginated list of books
|
|
50
|
+
def list_books(collection: nil, **params)
|
|
51
|
+
get("/books/", { collection__slug: collection }.merge(params))
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# Get book details by slug (e.g. "dhammapada", "heart-sutra").
|
|
55
|
+
#
|
|
56
|
+
# @param slug [String] book URL slug
|
|
57
|
+
# @return [Hash] book details
|
|
58
|
+
def get_book(slug)
|
|
59
|
+
get("/books/#{slug}/")
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
# --- Texts ----------------------------------------------------------------
|
|
63
|
+
|
|
64
|
+
# Get a specific scripture text by book, chapter, and verse number.
|
|
65
|
+
#
|
|
66
|
+
# @param book [String] book slug (e.g. "dhammapada")
|
|
67
|
+
# @param chapter [Integer] chapter number
|
|
68
|
+
# @param verse [Integer] verse number within the chapter
|
|
69
|
+
# @param translation [String] translation code (default: "sujato")
|
|
70
|
+
# @return [Hash] text data with Pali/Sanskrit and translation
|
|
71
|
+
def get_text(book, chapter, verse, translation: "sujato")
|
|
72
|
+
get("/texts/", {
|
|
73
|
+
chapter__book__slug: book,
|
|
74
|
+
chapter__number: chapter,
|
|
75
|
+
number: verse,
|
|
76
|
+
translation__code: translation
|
|
77
|
+
})
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
# Search scripture texts by keyword.
|
|
81
|
+
#
|
|
82
|
+
# @param query [String] search query string
|
|
83
|
+
# @param limit [Integer] maximum number of results (default: 25)
|
|
84
|
+
# @return [Hash] paginated search results
|
|
85
|
+
def search(query, limit: 25)
|
|
86
|
+
get("/texts/", { search: query, page_size: limit })
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
# --- Translations ---------------------------------------------------------
|
|
90
|
+
|
|
91
|
+
# List available text translations (Sujato, Thanissaro, etc.).
|
|
92
|
+
#
|
|
93
|
+
# @return [Hash] paginated list of translations
|
|
94
|
+
def list_translations(**params)
|
|
95
|
+
get("/translations/", params)
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
# Get translation details by code (e.g. "sujato").
|
|
99
|
+
#
|
|
100
|
+
# @param code [String] translation code
|
|
101
|
+
# @return [Hash] translation details
|
|
102
|
+
def get_translation(code)
|
|
103
|
+
get("/translations/#{code}/")
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
# --- Figures --------------------------------------------------------------
|
|
107
|
+
|
|
108
|
+
# List Buddhist figures (Buddhas, bodhisattvas, monks).
|
|
109
|
+
#
|
|
110
|
+
# @param tradition [String, nil] filter by tradition ("theravada", "mahayana")
|
|
111
|
+
# @return [Hash] paginated list of figures
|
|
112
|
+
def list_figures(tradition: nil, **params)
|
|
113
|
+
get("/figures/", { tradition: tradition }.merge(params))
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
# Get figure details by slug (e.g. "siddhartha-gautama").
|
|
117
|
+
#
|
|
118
|
+
# @param slug [String] figure URL slug
|
|
119
|
+
# @return [Hash] figure details
|
|
120
|
+
def get_figure(slug)
|
|
121
|
+
get("/figures/#{slug}/")
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
# --- Concepts -------------------------------------------------------------
|
|
125
|
+
|
|
126
|
+
# List Buddhist concepts (Four Noble Truths, Noble Eightfold Path, etc.).
|
|
127
|
+
#
|
|
128
|
+
# @param category [String, nil] filter by category
|
|
129
|
+
# @return [Hash] paginated list of concepts
|
|
130
|
+
def list_concepts(category: nil, **params)
|
|
131
|
+
get("/concepts/", { category: category }.merge(params))
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
# Get concept details by slug (e.g. "four-noble-truths").
|
|
135
|
+
#
|
|
136
|
+
# @param slug [String] concept URL slug
|
|
137
|
+
# @return [Hash] concept details
|
|
138
|
+
def get_concept(slug)
|
|
139
|
+
get("/concepts/#{slug}/")
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
# --- Topics ---------------------------------------------------------------
|
|
143
|
+
|
|
144
|
+
# List Buddhist topics and themes.
|
|
145
|
+
#
|
|
146
|
+
# @return [Hash] paginated list of topics
|
|
147
|
+
def list_topics(**params)
|
|
148
|
+
get("/topics/", params)
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
# Get topic details by slug.
|
|
152
|
+
#
|
|
153
|
+
# @param slug [String] topic URL slug
|
|
154
|
+
# @return [Hash] topic details
|
|
155
|
+
def get_topic(slug)
|
|
156
|
+
get("/topics/#{slug}/")
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
# --- Glossary -------------------------------------------------------------
|
|
160
|
+
|
|
161
|
+
# List Pali and Sanskrit glossary terms.
|
|
162
|
+
#
|
|
163
|
+
# @return [Hash] paginated list of glossary terms
|
|
164
|
+
def list_glossary(**params)
|
|
165
|
+
get("/glossary/", params)
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
# Get glossary term details by slug.
|
|
169
|
+
#
|
|
170
|
+
# @param slug [String] term URL slug
|
|
171
|
+
# @return [Hash] glossary term details
|
|
172
|
+
def get_glossary_term(slug)
|
|
173
|
+
get("/glossary/#{slug}/")
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
private
|
|
177
|
+
|
|
178
|
+
def get(path, params = {})
|
|
179
|
+
uri = URI("#{@base_url}#{path}")
|
|
180
|
+
cleaned = params.each_with_object({}) { |(k, v), h| h[k] = v unless v.nil? }
|
|
181
|
+
uri.query = URI.encode_www_form(cleaned) unless cleaned.empty?
|
|
182
|
+
|
|
183
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
|
184
|
+
http.use_ssl = uri.scheme == "https"
|
|
185
|
+
http.open_timeout = @timeout
|
|
186
|
+
http.read_timeout = @timeout
|
|
187
|
+
|
|
188
|
+
request = Net::HTTP::Get.new(uri)
|
|
189
|
+
request["Accept"] = "application/json"
|
|
190
|
+
request["User-Agent"] = "widesutra-rb/#{VERSION}"
|
|
191
|
+
|
|
192
|
+
response = http.request(request)
|
|
193
|
+
|
|
194
|
+
case response
|
|
195
|
+
when Net::HTTPSuccess
|
|
196
|
+
JSON.parse(response.body)
|
|
197
|
+
when Net::HTTPNotFound
|
|
198
|
+
raise "Not found: #{path}"
|
|
199
|
+
else
|
|
200
|
+
raise "HTTP #{response.code}: #{response.body}"
|
|
201
|
+
end
|
|
202
|
+
end
|
|
203
|
+
end
|
|
204
|
+
end
|
data/lib/widesutra.rb
ADDED
metadata
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: widesutra
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- dobestan
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2026-03-24 00:00:00.000000000 Z
|
|
12
|
+
dependencies: []
|
|
13
|
+
description: API client for widesutra.com. Access Buddhist scripture collections (Tipitaka,
|
|
14
|
+
Mahayana Sutras), books, texts with Pali/Sanskrit originals and translations, Buddhist
|
|
15
|
+
figures, concepts (Four Noble Truths, Noble Eightfold Path), topics, and Pali/Sanskrit
|
|
16
|
+
glossary. Zero dependencies.
|
|
17
|
+
email:
|
|
18
|
+
executables: []
|
|
19
|
+
extensions: []
|
|
20
|
+
extra_rdoc_files: []
|
|
21
|
+
files:
|
|
22
|
+
- LICENSE
|
|
23
|
+
- README.md
|
|
24
|
+
- lib/widesutra.rb
|
|
25
|
+
- lib/widesutra/client.rb
|
|
26
|
+
- lib/widesutra/version.rb
|
|
27
|
+
homepage: https://widesutra.com
|
|
28
|
+
licenses:
|
|
29
|
+
- MIT
|
|
30
|
+
metadata:
|
|
31
|
+
homepage_uri: https://widesutra.com
|
|
32
|
+
source_code_uri: https://github.com/dobestan/widesutra-rb
|
|
33
|
+
changelog_uri: https://github.com/dobestan/widesutra-rb/blob/main/CHANGELOG.md
|
|
34
|
+
documentation_uri: https://widesutra.com/developers/
|
|
35
|
+
bug_tracker_uri: https://github.com/dobestan/widesutra-rb/issues
|
|
36
|
+
post_install_message:
|
|
37
|
+
rdoc_options: []
|
|
38
|
+
require_paths:
|
|
39
|
+
- lib
|
|
40
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
41
|
+
requirements:
|
|
42
|
+
- - ">="
|
|
43
|
+
- !ruby/object:Gem::Version
|
|
44
|
+
version: '3.0'
|
|
45
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
46
|
+
requirements:
|
|
47
|
+
- - ">="
|
|
48
|
+
- !ruby/object:Gem::Version
|
|
49
|
+
version: '0'
|
|
50
|
+
requirements: []
|
|
51
|
+
rubygems_version: 3.0.3.1
|
|
52
|
+
signing_key:
|
|
53
|
+
specification_version: 4
|
|
54
|
+
summary: Ruby SDK for WideSutra — Buddhist scriptures, Tipitaka, Pali Canon
|
|
55
|
+
test_files: []
|