peasytext 0.1.1 → 0.2.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 +4 -4
- data/lib/peasytext/client.rb +109 -0
- data/lib/peasytext/version.rb +1 -1
- data/lib/peasytext.rb +1 -0
- metadata +7 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4c3a3a03a8b42cf57d126ca25630d703a7ab12ad3e9231ab6f0e07f7a209a2d3
|
|
4
|
+
data.tar.gz: afaa8afb9ceb9e6634386c14e4423ef8f5b28d799e8d1c0bb100390372881edb
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1476b54280a5cf929a0a567a3d9146070c0aca19a189aebb5b227429361e61f17762c8ab295fd7c066f1b4a03b895d2a5ad6aecba47d55f591227364101dad98
|
|
7
|
+
data.tar.gz: eb17547f931c5b47537c4f5159b725cce0d17476fd84918434c29503a6b17be466e285ffab60b204aba89d03e1b232afe821dc6184d6dadba331609d27029604
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "net/http"
|
|
4
|
+
require "json"
|
|
5
|
+
require "uri"
|
|
6
|
+
|
|
7
|
+
module PeasyText
|
|
8
|
+
# REST API client for peasytext.com.
|
|
9
|
+
# Zero dependencies — uses Ruby stdlib only.
|
|
10
|
+
class Client
|
|
11
|
+
DEFAULT_BASE_URL = "https://peasytext.com"
|
|
12
|
+
|
|
13
|
+
def initialize(base_url: DEFAULT_BASE_URL)
|
|
14
|
+
@base_url = base_url.chomp("/")
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
# --- Tools ---
|
|
18
|
+
|
|
19
|
+
def list_tools(page: 1, limit: 50, category: nil, search: nil)
|
|
20
|
+
get("/api/v1/tools/", page: page, limit: limit, category: category, search: search)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def get_tool(slug)
|
|
24
|
+
get("/api/v1/tools/#{slug}/")
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# --- Categories ---
|
|
28
|
+
|
|
29
|
+
def list_categories(page: 1, limit: 50)
|
|
30
|
+
get("/api/v1/categories/", page: page, limit: limit)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# --- Formats ---
|
|
34
|
+
|
|
35
|
+
def list_formats(page: 1, limit: 50, category: nil, search: nil)
|
|
36
|
+
get("/api/v1/formats/", page: page, limit: limit, category: category, search: search)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def get_format(slug)
|
|
40
|
+
get("/api/v1/formats/#{slug}/")
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# --- Conversions ---
|
|
44
|
+
|
|
45
|
+
def list_conversions(page: 1, limit: 50, source: nil, target: nil)
|
|
46
|
+
get("/api/v1/conversions/", page: page, limit: limit, source: source, target: target)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# --- Glossary ---
|
|
50
|
+
|
|
51
|
+
def list_glossary(page: 1, limit: 50, category: nil, search: nil)
|
|
52
|
+
get("/api/v1/glossary/", page: page, limit: limit, category: category, search: search)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def get_glossary_term(slug)
|
|
56
|
+
get("/api/v1/glossary/#{slug}/")
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# --- Guides ---
|
|
60
|
+
|
|
61
|
+
def list_guides(page: 1, limit: 50, category: nil, audience_level: nil, search: nil)
|
|
62
|
+
get("/api/v1/guides/", page: page, limit: limit, category: category,
|
|
63
|
+
audience_level: audience_level, search: search)
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def get_guide(slug)
|
|
67
|
+
get("/api/v1/guides/#{slug}/")
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
# --- Use Cases ---
|
|
71
|
+
|
|
72
|
+
def list_use_cases(page: 1, limit: 50, industry: nil, search: nil)
|
|
73
|
+
get("/api/v1/use-cases/", page: page, limit: limit, industry: industry, search: search)
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
# --- Search ---
|
|
77
|
+
|
|
78
|
+
def search(query, limit: 20)
|
|
79
|
+
get("/api/v1/search/", q: query, limit: limit)
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
# --- Sites ---
|
|
83
|
+
|
|
84
|
+
def list_sites
|
|
85
|
+
get("/api/v1/sites/")
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
# --- OpenAPI ---
|
|
89
|
+
|
|
90
|
+
def openapi_spec
|
|
91
|
+
get("/api/openapi.json")
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
private
|
|
95
|
+
|
|
96
|
+
def get(path, **params)
|
|
97
|
+
uri = URI("#{@base_url}#{path}")
|
|
98
|
+
params.reject! { |_, v| v.nil? }
|
|
99
|
+
uri.query = URI.encode_www_form(params) unless params.empty?
|
|
100
|
+
response = Net::HTTP.get_response(uri)
|
|
101
|
+
body = JSON.parse(response.body)
|
|
102
|
+
unless response.is_a?(Net::HTTPSuccess)
|
|
103
|
+
detail = body.is_a?(Hash) ? body.fetch("detail", "Unknown error") : response.body
|
|
104
|
+
raise PeasyText::Error, "HTTP #{response.code}: #{detail}"
|
|
105
|
+
end
|
|
106
|
+
body
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
end
|
data/lib/peasytext/version.rb
CHANGED
data/lib/peasytext.rb
CHANGED
metadata
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: peasytext
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- PeasyTools
|
|
8
|
+
autorequire:
|
|
8
9
|
bindir: bin
|
|
9
10
|
cert_chain: []
|
|
10
|
-
date:
|
|
11
|
+
date: 2026-03-17 00:00:00.000000000 Z
|
|
11
12
|
dependencies: []
|
|
12
13
|
description: Text processing library for Ruby — case conversion (camelCase, snake_case,
|
|
13
14
|
kebab-case, PascalCase), word/character counting, slug generation, Base64/URL encoding.
|
|
@@ -19,6 +20,7 @@ extensions: []
|
|
|
19
20
|
extra_rdoc_files: []
|
|
20
21
|
files:
|
|
21
22
|
- lib/peasytext.rb
|
|
23
|
+
- lib/peasytext/client.rb
|
|
22
24
|
- lib/peasytext/engine.rb
|
|
23
25
|
- lib/peasytext/version.rb
|
|
24
26
|
homepage: https://peasytext.com
|
|
@@ -30,6 +32,7 @@ metadata:
|
|
|
30
32
|
changelog_uri: https://github.com/peasytools/peasytext-rb/blob/main/CHANGELOG.md
|
|
31
33
|
documentation_uri: https://peasytext.com
|
|
32
34
|
bug_tracker_uri: https://github.com/peasytools/peasytext-rb/issues
|
|
35
|
+
post_install_message:
|
|
33
36
|
rdoc_options: []
|
|
34
37
|
require_paths:
|
|
35
38
|
- lib
|
|
@@ -44,7 +47,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
44
47
|
- !ruby/object:Gem::Version
|
|
45
48
|
version: '0'
|
|
46
49
|
requirements: []
|
|
47
|
-
rubygems_version:
|
|
50
|
+
rubygems_version: 3.0.3.1
|
|
51
|
+
signing_key:
|
|
48
52
|
specification_version: 4
|
|
49
53
|
summary: Text analysis — case conversion, word count, slugs, encoding
|
|
50
54
|
test_files: []
|