yobi-http 0.1.0 → 0.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9e47c9cf6b60d6ccc40c4e679132f68da6a792500723c18d6b9779c7d350fb0b
4
- data.tar.gz: b22cc75a93e412033c498548e82f1cf373d9ab9720dafea4c44efcc88228a20b
3
+ metadata.gz: 88846b024d2d475d692092a342ac7d178b24821994aef0cd3e70b4c914980f09
4
+ data.tar.gz: 6cc5fbd3fb14e49c347cf8d866d2626e9a2174a8a6054fbc7d02d7a957c8416c
5
5
  SHA512:
6
- metadata.gz: 407e2e909630c3243efa467fb63ce4742895140331158decc77544da3151c11d1d2b4720debe9f2c03ad8205b86f944c8bde1f58df547ac893034143bf7ea279
7
- data.tar.gz: d233b846b87e54ec3a4467fd3df0460ba14e6c0ad27cad2c3789cd5d5995abe99eb8efc739821022306d803fa6e6fc51bd1c4ef38172d9675ad221a10ff5b2b4
6
+ metadata.gz: 4085882260b11117520ab7f9390054a9df61696ef5abdac57c8e7264e5971dff658f6e23aa531e5142e25acc0bd0ed24c4ca555270023091d7b5f8ca74ceb34c
7
+ data.tar.gz: e86d070c44208636e3377ad0f83b0657a12bce7f0e129b904781d3eceda159764f755eb4ee0d63d4df77eafc73d05e362f830e4d38f9fbd523c07553f9da489b
data/exe/yobi CHANGED
@@ -14,7 +14,7 @@ require "uri"
14
14
  require "yobi"
15
15
 
16
16
  # parsing arguments
17
- @options = { print: "HB", auth: nil, auth_type: "basic", verbose: false, raw: false }
17
+ @options = { print: "HB", auth: nil, auth_type: "basic", verbose: false, raw: false, offline: false }
18
18
 
19
19
  parser = OptionParser.new do |opts|
20
20
  opts.banner = %(
@@ -55,6 +55,10 @@ parser = OptionParser.new do |opts|
55
55
  exit
56
56
  end
57
57
 
58
+ opts.on("--offline", "Run in offline mode (prepare request but do not send)") do
59
+ @options[:offline] = true
60
+ end
61
+
58
62
  opts.on("-v", "--verbose", "Print detailed request and response information") do
59
63
  @options[:verbose] = true
60
64
  end
@@ -112,6 +116,32 @@ Net::HTTP.start(URI(url).host, URI(url).port, use_ssl: URI(url).scheme == "https
112
116
 
113
117
  request.body = data.to_json unless data.empty?
114
118
 
119
+ if options[:offline]
120
+ options[:verbose] = true
121
+ # In offline mode, we prepare the request but do not send it. Instead, we print the request details for debugging
122
+ # purposes.
123
+ response = Net::HTTPResponse.new("1.1", "200", "OK")
124
+ response["Content-Type"] = "application/json"
125
+ response["Access-Control-Allow-Credentials"] = true
126
+ response["Access-Control-Allow-Origin"] = "*"
127
+ response["Connection"] = "close"
128
+ response["Date"] = Time.now.iso8601
129
+ response["Server"] = "yobi-offline/#{Yobi::VERSION}"
130
+ 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
+ })
139
+
140
+ view = Yobi.view(:output)
141
+ puts TTY::Markdown.parse(ERB.new(view).result(binding), color: :always)
142
+ break
143
+ end
144
+
115
145
  response = http.request(request)
116
146
 
117
147
  body = nil
@@ -11,9 +11,9 @@
11
11
 
12
12
  <% end %>
13
13
 
14
+ <% if options[:print].include?('H') %>
14
15
  # HTTP/<%= response.http_version %> <%= response.code %> <%= response.message %>
15
16
 
16
- <% if options[:print].include?('H') %>
17
17
  ```yaml
18
18
  <%= response.each_capitalized.to_h.sort.map { |key, value| "#{key}: #{value}" }.join("\n") %>
19
19
  ```
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.1.0"
13
+ VERSION = "0.4.0"
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.1.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Vinciguerra
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2026-02-11 00:00:00.000000000 Z
10
+ date: 2026-02-12 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: tty-markdown