mini_http 0.1.0 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9c08f77f0d125e88a3232a1a297b02c63b58e603035eb270d6f831afc5125b60
4
- data.tar.gz: 8d1c560f5a1c7c96b16958f76ef11249058948293fad0d27edcc289b07aada43
3
+ metadata.gz: 990e61a5e8156abfcba0c67c1e4389e22af16db7c0f691e2b80c280e949aef14
4
+ data.tar.gz: d5d4068593c054c35e0a8c6ef0fcc6fcfd04703aafe6bf8c2dfb02711f04cd81
5
5
  SHA512:
6
- metadata.gz: e6030620de4d5dfebda56fdb0e1a3ecad646cacfbd32c37835f66ecff9c0e5ac4ef3657e8b1da5f86635c7c996b6aed6d70cf5fabc9bf3ff42100c022f8fac4d
7
- data.tar.gz: 33d519e99803cedc6227a02db5214203f46139df17b040e8a5a5a13eb2e11a16e86f40a339989856a949d1420b1c532c09b0e802a097a7123a52419ed1f84dda
6
+ metadata.gz: 8009ad9d56b6a21585ec6a78dabe16cb06c687e7253387e43c6cdbfef4162d503fe313165528d080414f467111efc04450dd6cc5b8b74b061535c2721276e3fc
7
+ data.tar.gz: 21943e04397015929abd169882b444e56bf861284f29b5cd29cba1b4451b62705cb2650e43e1ccb49e6fdd3cbefcb5ed597a0bcb4e82e2e57b12b0f0377dc29b
data/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.2.0] - 2025-12-02
4
+
5
+ ### Added
6
+ - Added `ssl` option to disable SSL certificate verification for development environments
7
+ - SSL verification can now be disabled by passing `ssl: false` to any HTTP method
8
+
9
+ ### Changed
10
+ - Refactored parameter handling to use keyword arguments splat (`**options`) to comply with RuboCop metrics
11
+ - Improved code maintainability by reducing parameter count in method signatures
12
+
13
+ ### Fixed
14
+ - Fixed RuboCop Metrics/ParameterLists violation
15
+
3
16
  ## [0.1.0] - 2025-06-23
4
17
 
5
18
  - Initial release of MiniHttp
data/README.md CHANGED
@@ -1,3 +1,6 @@
1
+ ![ChatGPT Image Jun 25, 2025, 09_45_50 AM-min](https://github.com/user-attachments/assets/8933e973-2a4f-4259-b7c3-a0aab5415d41)
2
+
3
+
1
4
  # MiniHttp
2
5
 
3
6
  A minimal, lightweight HTTP client library for Ruby that provides a clean interface for making HTTP requests with automatic JSON handling, SSL support, and customizable timeouts.
@@ -103,6 +106,7 @@ All methods support these optional parameters:
103
106
  - `headers`: Hash of HTTP headers
104
107
  - `timeout`: Request timeout in seconds (default: 30)
105
108
  - `body`: Request body for POST/PUT (string or object that responds to `to_json`)
109
+ - `ssl`: Enable/disable SSL certificate verification (default: true)
106
110
 
107
111
  ```ruby
108
112
  response = MiniHttp.get(
@@ -115,6 +119,25 @@ response = MiniHttp.get(
115
119
  )
116
120
  ```
117
121
 
122
+ ### Disabling SSL verification (for development)
123
+
124
+ ⚠️ **Warning**: Only use this in development environments. Never disable SSL verification in production.
125
+
126
+ ```ruby
127
+ # Useful for testing with self-signed certificates in development
128
+ response = MiniHttp.get(
129
+ "https://localhost:3000/api/data",
130
+ ssl: false
131
+ )
132
+
133
+ # Works with all HTTP methods
134
+ response = MiniHttp.post(
135
+ "https://dev-api.local/users",
136
+ body: { name: "Test User" },
137
+ ssl: false
138
+ )
139
+ ```
140
+
118
141
  ## Development
119
142
 
120
143
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class MiniHttp
4
- VERSION = "0.1.0"
4
+ VERSION = "0.2.0"
5
5
  end
data/lib/mini_http.rb CHANGED
@@ -51,46 +51,55 @@ class MiniHttp
51
51
  end
52
52
  end
53
53
 
54
- def self.get(url, headers: {}, timeout: 30)
55
- make_request(:get, url, headers: headers, timeout: timeout)
54
+ def self.get(url, **options)
55
+ make_request(:get, url, **options)
56
56
  end
57
57
 
58
- def self.post(url, body: nil, headers: {}, timeout: 30)
59
- make_request(:post, url, body: body, headers: headers, timeout: timeout)
58
+ def self.post(url, **options)
59
+ make_request(:post, url, **options)
60
60
  end
61
61
 
62
- def self.put(url, body: nil, headers: {}, timeout: 30)
63
- make_request(:put, url, body: body, headers: headers, timeout: timeout)
62
+ def self.put(url, **options)
63
+ make_request(:put, url, **options)
64
64
  end
65
65
 
66
- def self.delete(url, headers: {}, timeout: 30)
67
- make_request(:delete, url, headers: headers, timeout: timeout)
66
+ def self.delete(url, **options)
67
+ make_request(:delete, url, **options)
68
68
  end
69
69
 
70
70
  class << self
71
71
  private
72
72
 
73
- def make_request(method, url, body: nil, headers: {}, timeout: 30)
73
+ def make_request(method, url, **options)
74
+ body = options[:body]
75
+ headers = options.fetch(:headers, {})
76
+ timeout = options.fetch(:timeout, 30)
77
+ ssl = options.fetch(:ssl, true)
78
+
74
79
  uri = URI(url)
75
- http = build_http_client(uri, timeout)
80
+ http = build_http_client(uri, timeout, ssl)
76
81
  request = build_request(method, uri, body, headers)
77
82
 
78
83
  net_response = http.request(request)
79
84
  Response.new(net_response)
80
85
  end
81
86
 
82
- def build_http_client(uri, timeout)
87
+ def build_http_client(uri, timeout, ssl)
83
88
  http = Net::HTTP.new(uri.host, uri.port)
84
- configure_ssl(http, uri)
89
+ configure_ssl(http, uri, ssl)
85
90
  configure_timeouts(http, timeout)
86
91
  http
87
92
  end
88
93
 
89
- def configure_ssl(http, uri)
94
+ def configure_ssl(http, uri, ssl)
90
95
  return unless uri.scheme == "https"
91
96
 
92
97
  http.use_ssl = true
93
- http.verify_mode = OpenSSL::SSL::VERIFY_PEER
98
+ http.verify_mode = if ssl
99
+ OpenSSL::SSL::VERIFY_PEER
100
+ else
101
+ OpenSSL::SSL::VERIFY_NONE
102
+ end
94
103
  end
95
104
 
96
105
  def configure_timeouts(http, timeout)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mini_http
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Felipe Cicolin Rocha