cURLからRubyコード変換 (Net::HTTP・Faraday・HTTParty)
cURLコマンドをNet::HTTP、URI、Faraday、JSON解析を活用したクリーンで慣用的なRubyコードへ瞬時に変換します。
#!/usr/bin/env ruby
# Net::HTTP Client - Ruby Standard Library (Zero External Gems)
require 'net/http'
require 'uri'
require 'json'
begin
uri = URI.parse("https://api.github.com/repos/octocat/Hello-World/issues")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = (uri.scheme == 'https')
request = Net::HTTP::Post.new(uri.request_uri)
request["Accept"] = "application/vnd.github+json"
request["Authorization"] = "Bearer gho_16C7e42F292c6912E7710c838347Ae178B4a"
request["X-GitHub-Api-Version"] = "2022-11-28"
request["Content-Type"] = "application/json"
payload = {
title: "Bug in auth session",
body: "Need to verify token expiration handling",
labels: ["bug", "priority"]
}
request.body = JSON.dump(payload)
# Dispatch request
response = http.request(request)
puts "HTTP Status: #{response.code} #{response.message}"
begin
data = JSON.parse(response.body)
puts "Parsed JSON Response:"
puts JSON.pretty_generate(data)
rescue JSON::ParserError
puts "Raw Body: #{response.body}"
end
rescue SocketError => e
warn "Network connection error: #{e.message}"
rescue Net::OpenTimeout, Net::ReadTimeout => e
warn "Request timed out: #{e.message}"
rescue StandardError => e
warn "Execution failure: #{e.class} - #{e.message}"
end100% クライアント側のプライバシー
cURLコマンドの解析、APIトークン抽出、Rubyコード生成はすべてブラウザのメモリ内でのみ実行されます。サーバーへのデータ送信は一切ありません。
Net::HTTPとFaradayのデュアルエンジン
外部gem依存のない標準ライブラリNet::HTTPスクリプト、モダンなFaraday、HTTParty、HTTP.rbクライアントコードを瞬時に出力します。
本番仕様の完全なオプション互換性
JSON本文、URLエンコードフォーム、マルチパートファイル送信、Basic/Bearer認証、リダイレクト追従、SSL検証、タイムアウトを完全網羅します。