yobi-http 0.4.0 → 0.4.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.
Files changed (6) hide show
  1. checksums.yaml +4 -4
  2. data/Agents.md +389 -0
  3. data/CHANGELOG.md +10 -0
  4. data/exe/yobi +3 -9
  5. data/lib/yobi.rb +1 -1
  6. metadata +3 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 88846b024d2d475d692092a342ac7d178b24821994aef0cd3e70b4c914980f09
4
- data.tar.gz: 6cc5fbd3fb14e49c347cf8d866d2626e9a2174a8a6054fbc7d02d7a957c8416c
3
+ metadata.gz: 445677da2c43e5f1e160b463c4e188b9a48a6536dc89b6c54ae8456327e2a302
4
+ data.tar.gz: 6f2d45e33717d7aec6cc54fc0372bd206018ced1cc73d4d81535acb1d6f5b027
5
5
  SHA512:
6
- metadata.gz: 4085882260b11117520ab7f9390054a9df61696ef5abdac57c8e7264e5971dff658f6e23aa531e5142e25acc0bd0ed24c4ca555270023091d7b5f8ca74ceb34c
7
- data.tar.gz: e86d070c44208636e3377ad0f83b0657a12bce7f0e129b904781d3eceda159764f755eb4ee0d63d4df77eafc73d05e362f830e4d38f9fbd523c07553f9da489b
6
+ metadata.gz: efe2e6ed336f584d35c776b89db1cf30ee585f4af398bafd3dbb873a92bc96865c2c3be68af9557d0c748110962ad96f222fda4a122952d3180cc9ab46697cbb
7
+ data.tar.gz: a05e99fa52716827a7e44f42630dd5c5460aa80829bd08f3e6fed5e795ce966b2afdbbbbaa82b84670ed99e8502189a44337a03489321189e6039bc00f085588
data/Agents.md ADDED
@@ -0,0 +1,389 @@
1
+ # Yobi HTTP Client - Technical Documentation
2
+
3
+ ## Overview
4
+
5
+ Yobi (呼び) is a lightweight Ruby HTTP client designed for testing APIs from the command line. It provides a simple and efficient way to make HTTP requests with human-friendly output formatting, inspired by HTTPie.
6
+
7
+ **Key Features:**
8
+ - Simple command-line interface
9
+ - Support for all standard HTTP methods (GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS)
10
+ - JSON formatting and syntax highlighting
11
+ - Multiple authentication methods
12
+ - Customizable output formats
13
+ - Offline mode for request debugging
14
+ - Raw output mode for piping to other tools
15
+
16
+ ## System Requirements
17
+
18
+ - Ruby >= 3.0.0
19
+ - RubyGems package manager
20
+
21
+ ## Installation
22
+
23
+ ### Install from RubyGems
24
+
25
+ The simplest way to install Yobi is through RubyGems:
26
+
27
+ ```bash
28
+ gem install yobi-http
29
+ ```
30
+
31
+ ### Install from Source
32
+
33
+ Clone the repository and install locally:
34
+
35
+ ```bash
36
+ git clone https://github.com/dvinciguerra/yobi-http.git
37
+ cd yobi-http
38
+ bundle install
39
+ bundle exec rake install
40
+ ```
41
+
42
+ ### Verify Installation
43
+
44
+ Check that Yobi is installed correctly:
45
+
46
+ ```bash
47
+ yobi --version
48
+ ```
49
+
50
+ ## Usage
51
+
52
+ ### Basic Syntax
53
+
54
+ ```bash
55
+ yobi [METHOD] <url> [HEADER:VALUE] [key=value]
56
+ ```
57
+
58
+ ### HTTP Methods
59
+
60
+ Yobi supports all standard HTTP methods:
61
+
62
+ - **GET** - Retrieve resources (default method)
63
+ - **POST** - Create new resources
64
+ - **PUT** - Update existing resources
65
+ - **DELETE** - Remove resources
66
+ - **PATCH** - Partially update resources
67
+ - **HEAD** - Get resource headers only
68
+ - **OPTIONS** - Get available methods
69
+
70
+ ### Basic Examples
71
+
72
+ #### Simple GET Request
73
+
74
+ ```bash
75
+ yobi GET https://jsonplaceholder.typicode.com/posts/1
76
+ ```
77
+
78
+ Or simply (GET is the default):
79
+
80
+ ```bash
81
+ yobi https://jsonplaceholder.typicode.com/posts/1
82
+ ```
83
+
84
+ #### POST Request with Data
85
+
86
+ ```bash
87
+ yobi POST https://jsonplaceholder.typicode.com/posts title="foo" body="bar" userId=1
88
+ ```
89
+
90
+ #### Request with Custom Headers
91
+
92
+ ```bash
93
+ yobi GET https://jsonplaceholder.typicode.com/posts/1 Authorization:"Bearer <token>"
94
+ ```
95
+
96
+ #### Using Localhost Shorthand
97
+
98
+ ```bash
99
+ yobi :8080/api/items
100
+ # Expands to: http://localhost:8080/api/items
101
+ ```
102
+
103
+ ### Authentication
104
+
105
+ #### Basic Authentication
106
+
107
+ ```bash
108
+ yobi -A basic -a username:password https://api.example.com/secure-data
109
+ ```
110
+
111
+ #### Bearer Token Authentication
112
+
113
+ ```bash
114
+ yobi -A bearer -a YOUR_TOKEN https://api.example.com/secure-data
115
+ ```
116
+
117
+ Or use a header directly:
118
+
119
+ ```bash
120
+ yobi GET https://api.example.com/secure-data Authorization:"Bearer YOUR_TOKEN"
121
+ ```
122
+
123
+ ### Command-Line Options
124
+
125
+ #### Output Control
126
+
127
+ **Print Format (`-p`, `--print`)**
128
+
129
+ Control what parts of the response to display:
130
+
131
+ - `H` - Print headers only
132
+ - `B` - Print body only
133
+ - `HB` - Print headers and body (default)
134
+
135
+ ```bash
136
+ yobi --print B https://api.example.com/data
137
+ ```
138
+
139
+ **Raw Output (`--raw`)**
140
+
141
+ Print raw response without formatting (useful for piping to other tools):
142
+
143
+ ```bash
144
+ yobi --raw --print B POST https://httpbin.org/anything | jq '.headers["User-Agent"]'
145
+ ```
146
+
147
+ #### Authentication Options
148
+
149
+ - `-a, --auth USER:PASS` - Specify authentication credentials
150
+ - `-A, --auth-type TYPE` - Specify authentication type (basic, bearer)
151
+
152
+ ```bash
153
+ yobi -A basic -a user:pass https://api.example.com/secure
154
+ ```
155
+
156
+ #### Debugging Options
157
+
158
+ **Verbose Mode (`-v`, `--verbose`)**
159
+
160
+ Print detailed request and response information:
161
+
162
+ ```bash
163
+ yobi -v GET https://api.example.com/users
164
+ ```
165
+
166
+ **Offline Mode (`--offline`)**
167
+
168
+ Prepare the request without sending it (useful for debugging):
169
+
170
+ ```bash
171
+ yobi --offline POST https://api.example.com/users name=John age=30
172
+ ```
173
+
174
+ **Debug Environment Variable**
175
+
176
+ Enable debug output with environment variable:
177
+
178
+ ```bash
179
+ YOBI_DEBUG=1 yobi GET https://api.example.com/users
180
+ ```
181
+
182
+ #### Other Options
183
+
184
+ - `-h, --help` - Display help message
185
+ - `--version` - Display version information
186
+
187
+ ## Advanced Usage
188
+
189
+ ### Combining Multiple Parameters
190
+
191
+ You can combine headers and data in a single request:
192
+
193
+ ```bash
194
+ yobi POST https://api.example.com/users \
195
+ name=John \
196
+ email=john@example.com \
197
+ Authorization:"Bearer token123" \
198
+ Content-Type:"application/json"
199
+ ```
200
+
201
+ ### Working with Different Content Types
202
+
203
+ By default, Yobi uses `application/json`. Override with custom headers:
204
+
205
+ ```bash
206
+ yobi POST https://api.example.com/form \
207
+ username=john \
208
+ password=secret \
209
+ Content-Type:"application/x-www-form-urlencoded"
210
+ ```
211
+
212
+ ### Piping Output
213
+
214
+ Use raw mode to pipe output to other command-line tools:
215
+
216
+ ```bash
217
+ # Extract specific fields with jq
218
+ yobi --raw --print B GET https://api.example.com/users | jq '.[0].name'
219
+
220
+ # Save response to file
221
+ yobi --raw --print B GET https://api.example.com/data > response.json
222
+
223
+ # Count lines in response
224
+ yobi --raw --print B GET https://api.example.com/logs | wc -l
225
+ ```
226
+
227
+ ## Development
228
+
229
+ ### Setting Up Development Environment
230
+
231
+ 1. Clone the repository:
232
+ ```bash
233
+ git clone https://github.com/dvinciguerra/yobi-http.git
234
+ cd yobi-http
235
+ ```
236
+
237
+ 2. Install dependencies:
238
+ ```bash
239
+ bin/setup
240
+ ```
241
+
242
+ 3. Run the interactive console:
243
+ ```bash
244
+ bin/console
245
+ ```
246
+
247
+ ### Building the Gem
248
+
249
+ To build the gem locally:
250
+
251
+ ```bash
252
+ bundle exec rake build
253
+ ```
254
+
255
+ The gem file will be created in the `pkg/` directory.
256
+
257
+ ### Installing Local Development Version
258
+
259
+ ```bash
260
+ bundle exec rake install
261
+ ```
262
+
263
+ ### Running Tests
264
+
265
+ ```bash
266
+ bundle exec rake test
267
+ ```
268
+
269
+ ### Code Quality
270
+
271
+ Check code style with RuboCop:
272
+
273
+ ```bash
274
+ rubocop
275
+ ```
276
+
277
+ ### Release Process
278
+
279
+ 1. Update version in `lib/yobi.rb`
280
+ 2. Update `CHANGELOG.md`
281
+ 3. Run tests and ensure they pass
282
+ 4. Create release:
283
+ ```bash
284
+ bundle exec rake release
285
+ ```
286
+
287
+ This will:
288
+ - Create a git tag for the version
289
+ - Build and push the gem to RubyGems
290
+ - Push commits and tags to GitHub
291
+
292
+ ## Project Structure
293
+
294
+ ```
295
+ yobi-http/
296
+ ├── exe/
297
+ │ └── yobi # Main executable
298
+ ├── lib/
299
+ │ ├── yobi.rb # Core module and version
300
+ │ ├── yobi/
301
+ │ │ └── http.rb # HTTP constants
302
+ │ └── views/ # Output templates
303
+ ├── bin/
304
+ │ ├── setup # Development setup script
305
+ │ └── console # Interactive console
306
+ ├── yobi.gemspec # Gem specification
307
+ └── README.md # User documentation
308
+ ```
309
+
310
+ ## Dependencies
311
+
312
+ - **tty-markdown (~> 0.7)** - Markdown rendering with syntax highlighting for formatted output
313
+
314
+ ## Technical Details
315
+
316
+ ### URL Resolution
317
+
318
+ Yobi intelligently resolves URLs:
319
+
320
+ - Full URLs: `https://api.example.com/path`
321
+ - Without protocol: `api.example.com/path` → `http://api.example.com/path`
322
+ - Localhost shorthand: `:8080/path` → `http://localhost:8080/path`
323
+
324
+ ### Request Processing
325
+
326
+ 1. Parse command-line arguments and options
327
+ 2. Resolve HTTP method (defaults to GET)
328
+ 3. Resolve and normalize URL
329
+ 4. Parse data parameters (key=value format)
330
+ 5. Parse headers (Header:Value format)
331
+ 6. Apply authentication if specified
332
+ 7. Send request or prepare offline mode
333
+ 8. Format and display response
334
+
335
+ ### Response Formatting
336
+
337
+ - JSON responses are automatically pretty-printed
338
+ - Markdown-based output with syntax highlighting
339
+ - Configurable output sections (headers, body, or both)
340
+ - Raw mode for integration with other tools
341
+
342
+ ## Troubleshooting
343
+
344
+ ### Common Issues
345
+
346
+ **"command not found: yobi"**
347
+ - Ensure gem bin directory is in your PATH
348
+ - Try `bundle exec yobi` if running from source
349
+
350
+ **SSL Certificate Errors**
351
+ - Update system certificates
352
+ - Check Ruby OpenSSL installation
353
+
354
+ **JSON Parsing Errors**
355
+ - Use `--raw` mode to see actual response
356
+ - Verify API is returning valid JSON
357
+
358
+ **Permission Denied**
359
+ - Use `gem install --user-install yobi-http` for user-level installation
360
+ - Or use `sudo gem install yobi-http` for system-wide installation
361
+
362
+ ## Contributing
363
+
364
+ Contributions are welcome! Please follow these guidelines:
365
+
366
+ 1. Fork the repository
367
+ 2. Create a feature branch
368
+ 3. Make your changes
369
+ 4. Add tests if applicable
370
+ 5. Ensure code passes RuboCop checks
371
+ 6. Submit a pull request
372
+
373
+ See [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md) for community guidelines.
374
+
375
+ ## License
376
+
377
+ This project is open source. See the repository for license details.
378
+
379
+ ## Resources
380
+
381
+ - **GitHub Repository**: https://github.com/dvinciguerra/yobi-http
382
+ - **RubyGems Package**: https://rubygems.org/gems/yobi-http
383
+ - **Changelog**: https://github.com/dvinciguerra/yobi-http/blob/main/CHANGELOG.md
384
+ - **Code of Conduct**: https://github.com/dvinciguerra/yobi-http/blob/main/CODE_OF_CONDUCT.md
385
+
386
+ ## Support
387
+
388
+ For bugs and feature requests, please open an issue on GitHub:
389
+ https://github.com/dvinciguerra/yobi-http/issues
data/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.4.1]
4
+
5
+ - Fix Time requirement
6
+ - Change Time format to match HTTP standard
7
+
8
+ ## [0.4.0] - 2026-10-01
9
+
10
+ - Add offline mode feature
11
+ - Solve part of header showing always
12
+
3
13
  ## [0.1.0] - 2026-02-10
4
14
 
5
15
  - Initial release
data/exe/yobi CHANGED
@@ -8,6 +8,7 @@ require "erb"
8
8
  require "json"
9
9
  require "net/http"
10
10
  require "optparse"
11
+ require "time"
11
12
  require "tty-markdown"
12
13
  require "uri"
13
14
 
@@ -125,17 +126,10 @@ Net::HTTP.start(URI(url).host, URI(url).port, use_ssl: URI(url).scheme == "https
125
126
  response["Access-Control-Allow-Credentials"] = true
126
127
  response["Access-Control-Allow-Origin"] = "*"
127
128
  response["Connection"] = "close"
128
- response["Date"] = Time.now.iso8601
129
+ response["Date"] = Time.now.httpdate
129
130
  response["Server"] = "yobi-offline/#{Yobi::VERSION}"
130
131
  response["X-Powered-By"] = "Yobi/#{Yobi::VERSION}"
131
-
132
- body = JSON.pretty_generate({
133
- method: method,
134
- url: url,
135
- headers: headers,
136
- body: request.body,
137
- options: options
138
- })
132
+ response.body = body = JSON.pretty_generate({ message: "Offline mode enabled" })
139
133
 
140
134
  view = Yobi.view(:output)
141
135
  puts TTY::Markdown.parse(ERB.new(view).result(binding), color: :always)
data/lib/yobi.rb CHANGED
@@ -10,7 +10,7 @@ module Yobi
10
10
  class Error < StandardError; end
11
11
 
12
12
  # Yobi gem version
13
- VERSION = "0.4.0"
13
+ VERSION = "0.4.1"
14
14
 
15
15
 
16
16
  def self.name
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yobi-http
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Vinciguerra
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2026-02-12 00:00:00.000000000 Z
10
+ date: 2026-02-13 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: tty-markdown
@@ -32,6 +32,7 @@ executables:
32
32
  extensions: []
33
33
  extra_rdoc_files: []
34
34
  files:
35
+ - Agents.md
35
36
  - CHANGELOG.md
36
37
  - CODE_OF_CONDUCT.md
37
38
  - README.md