peasytext 0.1.1 → 0.2.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: d5f8327e1e70b66f18778afd2914da514af0011ac3615cf7744add68544546e8
4
- data.tar.gz: 4a74e440dff05a09cf3566775ac0e82c84b472453c398c71f22fd5617f091a56
3
+ metadata.gz: 3976ce2f29631788b642d40e5040e2676ba82fb8d22e28f917c0c36620ac8b8f
4
+ data.tar.gz: a2104db10632f3fe414af7a3f396257b10c10cc4fbec056310a30e40c3d5c127
5
5
  SHA512:
6
- metadata.gz: d82f793c433c1974726d249375b3adb5f96fe2fbeb691ee624f6603f4ec656bab8717a547bda6b0cac5fff8442b131e61b941c39606441ec616bc9d389e3d1e3
7
- data.tar.gz: '0149a27af898071c3093ef29b5aef5f6e13727b5673e5061976bad33c6bae4b39d932667cfeaced2d861af735468c48c1e65bcc911e06b6b4d9eaeec7b4aeb00'
6
+ metadata.gz: d8af59c356785ac233bbb781e1e7f4e6ef6eafc2a806bb9357c390a4a84125a137ea05b817c71a8e6caba1e9f8656cf0fbf6cf41259ba90f7d7d4127e041409d
7
+ data.tar.gz: f7dea0254dd5c83af078c8f5fa05bbaa3fec1e8655c4bc938511bd1f7a42b96256d038375cdd0c19f3d07d0ad42c78d37a8f375d768c9916e0bbb86e5b7fc9ac
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PeasyText
4
- VERSION = "0.1.1"
4
+ VERSION = "0.2.1"
5
5
  end
data/lib/peasytext.rb CHANGED
@@ -2,3 +2,4 @@
2
2
 
3
3
  require_relative "peasytext/version"
4
4
  require_relative "peasytext/engine"
5
+ require_relative "peasytext/client"
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.1.1
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - PeasyTools
8
+ autorequire:
8
9
  bindir: bin
9
10
  cert_chain: []
10
- date: 1980-01-02 00:00:00.000000000 Z
11
+ date: 2026-03-18 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: 4.0.3
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: []