gitdb-client 1.0.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.
Files changed (5) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +469 -0
  3. data/gitdb-client.gemspec +30 -0
  4. data/lib/gitdb_client.rb +263 -0
  5. metadata +107 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: d01ab528477d9adb2b3980cba474d466ae8205b7fc3a6993f944f01267535fe6
4
+ data.tar.gz: b514cb24a152505be3d7ce04fc05522c8298a7f856d99f91d6de2627993c6a55
5
+ SHA512:
6
+ metadata.gz: 861df0078fa647d506a685ebb8d253fbe400e2a623ade1cdb0311036309de3404fb93332cc418c30da5e748bbdefb7122c57ff85b0361243209bc4cda4e5a666
7
+ data.tar.gz: 607cc8f8076cf5600d7af486723317016551454ad2f35c54b00a67e886d5791ddd2dd3854b8796f014ba872e8c2f950bc99818e575bf2f155678da3ab9c9976c
data/README.md ADDED
@@ -0,0 +1,469 @@
1
+ # GitDB Ruby Client
2
+
3
+ Official Ruby client for GitDB - GitHub-backed NoSQL database.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'gitdb-client'
11
+ ```
12
+
13
+ And then execute:
14
+ ```bash
15
+ $ bundle install
16
+ ```
17
+
18
+ Or install it yourself as:
19
+ ```bash
20
+ $ gem install gitdb-client
21
+ ```
22
+
23
+ ## Quick Start
24
+
25
+ ```ruby
26
+ require 'gitdb_client'
27
+
28
+ # Create a client instance
29
+ client = GitDBClient.new('your-github-token', 'owner', 'repository')
30
+
31
+ # Check server health
32
+ client.health
33
+
34
+ # Create a collection
35
+ client.create_collection('users')
36
+
37
+ # Insert a document
38
+ document = {
39
+ name: 'John Doe',
40
+ email: 'john@example.com',
41
+ age: 30
42
+ }
43
+
44
+ id = client.insert('users', document)
45
+ puts "Inserted document with ID: #{id}"
46
+
47
+ # Find documents
48
+ query = {
49
+ age: { '$gte' => 25 }
50
+ }
51
+
52
+ documents = client.find('users', query)
53
+ puts "Found #{documents.length} documents"
54
+
55
+ # Update a document
56
+ update = { age: 31 }
57
+ client.update('users', id, update)
58
+
59
+ # Delete a document
60
+ client.delete('users', id)
61
+ ```
62
+
63
+ ## Features
64
+
65
+ - ✅ **Simple Ruby API** - Easy to use Ruby interface
66
+ - ✅ **Full CRUD operations** - Create, Read, Update, Delete documents
67
+ - ✅ **Query support** - MongoDB-style query operators
68
+ - ✅ **Collection management** - Create, list, delete collections
69
+ - ✅ **Error handling** - Comprehensive error handling
70
+ - ✅ **HTTP client** - Built-in HTTP client with retry logic
71
+ - ✅ **JSON handling** - Native JSON serialization/deserialization
72
+ - ✅ **Ruby 2.6+ support** - Modern Ruby compatibility
73
+
74
+ ## Configuration
75
+
76
+ ### GitHub Token
77
+
78
+ You'll need a GitHub Personal Access Token with the following permissions:
79
+ - `repo` - Full control of private repositories
80
+ - `workflow` - Update GitHub Action workflows
81
+
82
+ Create a token at: https://github.com/settings/tokens
83
+
84
+ ### Client Initialization
85
+
86
+ ```ruby
87
+ require 'gitdb_client'
88
+
89
+ # Basic initialization
90
+ client = GitDBClient.new('token', 'owner', 'repo')
91
+
92
+ # With custom base URL (for self-hosted instances)
93
+ client = GitDBClient.new('token', 'owner', 'repo', 'http://localhost:7896')
94
+ ```
95
+
96
+ ## API Reference
97
+
98
+ ### Client Creation
99
+
100
+ ```ruby
101
+ # Create a new client
102
+ client = GitDBClient.new(token, owner, repo)
103
+
104
+ # Create client with custom URL
105
+ client = GitDBClient.new(token, owner, repo, 'http://localhost:7896')
106
+ ```
107
+
108
+ ### Health Check
109
+
110
+ ```ruby
111
+ # Check if server is healthy
112
+ client.health
113
+ ```
114
+
115
+ ### Collection Management
116
+
117
+ ```ruby
118
+ # Create a collection
119
+ client.create_collection('users')
120
+
121
+ # List all collections
122
+ collections = client.list_collections
123
+ collections.each do |collection|
124
+ puts "Collection: #{collection['name']} (#{collection['count']} documents)"
125
+ end
126
+
127
+ # Delete a collection
128
+ client.delete_collection('users')
129
+ ```
130
+
131
+ ### Document Operations
132
+
133
+ #### Insert
134
+
135
+ ```ruby
136
+ document = {
137
+ name: 'Alice',
138
+ email: 'alice@example.com',
139
+ age: 25
140
+ }
141
+
142
+ id = client.insert('users', document)
143
+ puts "Inserted with ID: #{id}"
144
+ ```
145
+
146
+ #### Find
147
+
148
+ ```ruby
149
+ # Find all documents
150
+ all_users = client.find('users', nil)
151
+
152
+ # Find with query
153
+ query = {
154
+ age: { '$gte' => 30 }
155
+ }
156
+ older_users = client.find('users', query)
157
+
158
+ # Find one document
159
+ user = client.find_one('users', query)
160
+
161
+ # Find by ID
162
+ user = client.find_by_id('users', 'document-id')
163
+ ```
164
+
165
+ #### Update
166
+
167
+ ```ruby
168
+ update = {
169
+ age: 26,
170
+ last_updated: '2024-01-01'
171
+ }
172
+
173
+ client.update('users', 'document-id', update)
174
+ ```
175
+
176
+ #### Delete
177
+
178
+ ```ruby
179
+ # Delete by ID
180
+ client.delete('users', 'document-id')
181
+
182
+ # Delete multiple documents
183
+ query = {
184
+ age: { '$lt' => 18 }
185
+ }
186
+ deleted_count = client.delete_many('users', query)
187
+ ```
188
+
189
+ ### Batch Operations
190
+
191
+ ```ruby
192
+ # Insert multiple documents
193
+ documents = [
194
+ { name: 'Alice', age: 25 },
195
+ { name: 'Bob', age: 30 },
196
+ { name: 'Charlie', age: 35 }
197
+ ]
198
+
199
+ documents.each do |doc|
200
+ id = client.insert('users', doc)
201
+ end
202
+
203
+ # Update multiple documents
204
+ query = {
205
+ age: { '$gte' => 25 }
206
+ }
207
+
208
+ update = {
209
+ category: 'senior'
210
+ }
211
+
212
+ updated_count = client.update_many('users', query, update)
213
+ ```
214
+
215
+ ### Query Operators
216
+
217
+ The Ruby client supports MongoDB-style query operators:
218
+
219
+ ```ruby
220
+ query = {}
221
+
222
+ # Equal
223
+ query[:age] = 30
224
+
225
+ # Greater than
226
+ query[:age] = { '$gt' => 25 }
227
+
228
+ # Greater than or equal
229
+ query[:age] = { '$gte' => 25 }
230
+
231
+ # Less than
232
+ query[:age] = { '$lt' => 50 }
233
+
234
+ # Less than or equal
235
+ query[:age] = { '$lte' => 50 }
236
+
237
+ # In array
238
+ query[:status] = { '$in' => ['active', 'pending'] }
239
+
240
+ # Not in array
241
+ query[:status] = { '$nin' => ['inactive', 'deleted'] }
242
+
243
+ # Logical AND
244
+ query[:'$and'] = [
245
+ { age: { '$gte' => 18 } },
246
+ { status: 'active' }
247
+ ]
248
+
249
+ # Logical OR
250
+ query[:'$or'] = [
251
+ { status: 'active' },
252
+ { status: 'pending' }
253
+ ]
254
+ ```
255
+
256
+ ## Error Handling
257
+
258
+ The SDK provides comprehensive error handling:
259
+
260
+ ```ruby
261
+ begin
262
+ document = client.find_by_id('users', 'non-existent-id')
263
+ rescue GitDBError => e
264
+ puts "GitDB Error: #{e.message}"
265
+ puts "Status Code: #{e.status_code}"
266
+ rescue => e
267
+ puts "General Error: #{e.message}"
268
+ end
269
+ ```
270
+
271
+ ## Advanced Usage
272
+
273
+ ### Custom HTTP Client
274
+
275
+ ```ruby
276
+ require 'httparty'
277
+
278
+ # Create custom HTTP client
279
+ http_client = HTTParty
280
+ http_client.timeout = 30
281
+
282
+ # Create GitDB client with custom HTTP client
283
+ client = GitDBClient.new('token', 'owner', 'repo', http_client: http_client)
284
+ ```
285
+
286
+ ### Retry Logic
287
+
288
+ ```ruby
289
+ # The client includes built-in retry logic for transient errors
290
+ # You can configure retry behavior if needed
291
+ client.max_retries = 3
292
+ client.retry_delay = 1
293
+ ```
294
+
295
+ ## Examples
296
+
297
+ ### User Management System
298
+
299
+ ```ruby
300
+ require 'gitdb_client'
301
+
302
+ class User
303
+ attr_accessor :id, :name, :email, :age, :status, :created_at
304
+
305
+ def initialize(name, email, age)
306
+ @name = name
307
+ @email = email
308
+ @age = age
309
+ @status = 'active'
310
+ @created_at = Time.now
311
+ end
312
+
313
+ def to_hash
314
+ {
315
+ name: @name,
316
+ email: @email,
317
+ age: @age,
318
+ status: @status,
319
+ created_at: @created_at
320
+ }
321
+ end
322
+ end
323
+
324
+ class UserManager
325
+ def initialize(token, owner, repo)
326
+ @client = GitDBClient.new(token, owner, repo)
327
+ end
328
+
329
+ def create_user(name, email, age)
330
+ user = User.new(name, email, age)
331
+ @client.insert('users', user.to_hash)
332
+ end
333
+
334
+ def find_user_by_email(email)
335
+ query = { email: email }
336
+ @client.find_one('users', query)
337
+ end
338
+
339
+ def update_user_status(user_id, status)
340
+ update = { status: status }
341
+ @client.update('users', user_id, update)
342
+ end
343
+
344
+ def get_active_users
345
+ query = { status: 'active' }
346
+ @client.find('users', query)
347
+ end
348
+
349
+ def delete_inactive_users
350
+ query = { status: 'inactive' }
351
+ @client.delete_many('users', query)
352
+ end
353
+ end
354
+
355
+ # Usage
356
+ user_manager = UserManager.new('your-token', 'owner', 'repo')
357
+
358
+ # Create user
359
+ user_id = user_manager.create_user('John Doe', 'john@example.com', 30)
360
+
361
+ # Find user
362
+ user = user_manager.find_user_by_email('john@example.com')
363
+
364
+ # Update status
365
+ user_manager.update_user_status(user_id, 'inactive')
366
+
367
+ # Get active users
368
+ active_users = user_manager.get_active_users
369
+ puts "Active users: #{active_users.length}"
370
+ ```
371
+
372
+ ## Testing
373
+
374
+ ```ruby
375
+ require 'rspec'
376
+ require 'gitdb_client'
377
+
378
+ RSpec.describe GitDBClient do
379
+ describe '#new' do
380
+ it 'creates a client instance' do
381
+ client = GitDBClient.new('token', 'owner', 'repo')
382
+ expect(client).to be_a(GitDBClient)
383
+ end
384
+ end
385
+
386
+ describe '#insert and #find_by_id' do
387
+ it 'inserts and finds a document' do
388
+ client = GitDBClient.new('token', 'owner', 'repo')
389
+
390
+ # Test document
391
+ document = {
392
+ name: 'Test User',
393
+ age: 25
394
+ }
395
+
396
+ # Insert
397
+ id = client.insert('test', document)
398
+
399
+ # Find by ID
400
+ found = client.find_by_id('test', id)
401
+
402
+ expect(found['name']).to eq('Test User')
403
+
404
+ # Cleanup
405
+ client.delete('test', id)
406
+ end
407
+ end
408
+ end
409
+ ```
410
+
411
+ ## Troubleshooting
412
+
413
+ ### Common Issues
414
+
415
+ 1. **Authentication Error**
416
+ - Verify your GitHub token is valid
417
+ - Ensure token has required permissions
418
+ - Check token hasn't expired
419
+
420
+ 2. **Repository Access**
421
+ - Verify repository exists
422
+ - Check you have access to the repository
423
+ - Ensure repository is not private (unless using private GitDB)
424
+
425
+ 3. **Network Issues**
426
+ - Check internet connection
427
+ - Verify GitHub API is accessible
428
+ - Check firewall settings
429
+
430
+ 4. **Rate Limiting**
431
+ - GitHub API has rate limits
432
+ - Implement exponential backoff for retries
433
+ - Consider using authenticated requests
434
+
435
+ ### Debug Mode
436
+
437
+ Enable debug mode to see detailed request/response information:
438
+
439
+ ```ruby
440
+ # Set debug mode (if supported by the client)
441
+ client.debug_mode = true
442
+ ```
443
+
444
+ ## Contributing
445
+
446
+ 1. Fork the repository
447
+ 2. Create a feature branch
448
+ 3. Make your changes
449
+ 4. Add tests
450
+ 5. Submit a pull request
451
+
452
+ ## License
453
+
454
+ This project is licensed under the MIT License - see the [LICENSE](../../LICENSE) file for details.
455
+
456
+ ## Support
457
+
458
+ - GitHub Issues: https://github.com/karthikeyanV2K/GitDB/issues
459
+ - Documentation: https://github.com/karthikeyanV2K/GitDB
460
+ - Email: Support@afot.in
461
+
462
+ ## Changelog
463
+
464
+ ### v1.0.0
465
+ - Initial release
466
+ - Full CRUD operations
467
+ - Query support with MongoDB-style operators
468
+ - Error handling
469
+ - Comprehensive documentation
@@ -0,0 +1,30 @@
1
+ Gem::Specification.new do |spec|
2
+ spec.name = "gitdb-client"
3
+ spec.version = "1.0.0"
4
+ spec.authors = ["AFOT Team", "karthikeyanV2K"]
5
+ spec.email = ["Support@afot.in", "karthikeyan@afot.in"]
6
+
7
+ spec.summary = "Official Ruby client for GitDB - GitHub-backed NoSQL database"
8
+ spec.description = "A Ruby client for GitDB, a GitHub-backed NoSQL database"
9
+ spec.homepage = "https://github.com/karthikeyanV2K/GitDB"
10
+ spec.license = "MIT"
11
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.6.0")
12
+
13
+ spec.metadata["homepage_uri"] = spec.homepage
14
+ spec.metadata["source_code_uri"] = spec.homepage
15
+ spec.metadata["changelog_uri"] = spec.homepage
16
+
17
+ spec.files = [
18
+ "lib/gitdb_client.rb",
19
+ "gitdb-client.gemspec",
20
+ "README.md"
21
+ ]
22
+ # Removed bindir and executables
23
+ spec.require_paths = ["lib"]
24
+
25
+ spec.add_dependency "httparty", "~> 0.21"
26
+ spec.add_dependency "json", "~> 2.6"
27
+
28
+ spec.add_development_dependency "rspec", "~> 3.0"
29
+ spec.add_development_dependency "rake", "~> 13.0"
30
+ end
@@ -0,0 +1,263 @@
1
+ require 'net/http'
2
+ require 'json'
3
+ require 'uri'
4
+
5
+ module GitDB
6
+ # GitDB Client for Ruby
7
+ # A client library for interacting with GitDB - GitHub-backed NoSQL database
8
+ class Client
9
+ attr_reader :base_url, :token, :owner, :repo
10
+
11
+ # Create a new GitDB client
12
+ # @param token [String] GitHub personal access token
13
+ # @param owner [String] GitHub username or organization
14
+ # @param repo [String] GitHub repository name
15
+ # @param base_url [String] GitDB server base URL
16
+ def initialize(token, owner, repo, base_url = 'http://localhost:7896')
17
+ @token = token
18
+ @owner = owner
19
+ @repo = repo
20
+ @base_url = base_url
21
+ end
22
+
23
+ # Set the base URL for the client
24
+ # @param url [String] new base URL
25
+ def set_base_url(url)
26
+ @base_url = url
27
+ end
28
+
29
+ # Check if the GitDB server is healthy
30
+ # @return [Boolean] true if healthy
31
+ # @raise [GitDBException] if health check fails
32
+ def health
33
+ response = make_request(:get, '/health')
34
+ response.code == '200'
35
+ end
36
+
37
+ # Create a new collection
38
+ # @param name [String] collection name
39
+ # @return [Boolean] true if created successfully
40
+ # @raise [GitDBException] if creation fails
41
+ def create_collection(name)
42
+ data = { name: name }
43
+ response = make_request(:post, '/api/v1/collections', data)
44
+ response.code == '201'
45
+ end
46
+
47
+ # List all collections
48
+ # @return [Array<Hash>] list of collections
49
+ # @raise [GitDBException] if listing fails
50
+ def list_collections
51
+ response = make_request(:get, '/api/v1/collections')
52
+ JSON.parse(response.body)
53
+ end
54
+
55
+ # Delete a collection
56
+ # @param name [String] collection name
57
+ # @return [Boolean] true if deleted successfully
58
+ # @raise [GitDBException] if deletion fails
59
+ def delete_collection(name)
60
+ response = make_request(:delete, "/api/v1/collections/#{name}")
61
+ response.code == '200'
62
+ end
63
+
64
+ # Insert a document into a collection
65
+ # @param collection [String] collection name
66
+ # @param document [Hash] document to insert
67
+ # @return [String] document ID
68
+ # @raise [GitDBException] if insertion fails
69
+ def insert(collection, document)
70
+ response = make_request(:post, "/api/v1/collections/#{collection}/documents", document)
71
+
72
+ unless response.code == '201'
73
+ raise GitDBException, "Failed to insert document: #{response.code}"
74
+ end
75
+
76
+ result = JSON.parse(response.body)
77
+ result['_id'] or raise GitDBException, 'No document ID returned'
78
+ end
79
+
80
+ # Find documents in a collection
81
+ # @param collection [String] collection name
82
+ # @param query [Hash] query to execute
83
+ # @return [Array<Hash>] list of documents
84
+ # @raise [GitDBException] if query fails
85
+ def find(collection, query = {})
86
+ response = make_request(:post, "/api/v1/collections/#{collection}/documents/find", query)
87
+
88
+ unless response.code == '200'
89
+ raise GitDBException, "Failed to find documents: #{response.code}"
90
+ end
91
+
92
+ JSON.parse(response.body)
93
+ end
94
+
95
+ # Find a single document in a collection
96
+ # @param collection [String] collection name
97
+ # @param query [Hash] query to execute
98
+ # @return [Hash, nil] document or nil if not found
99
+ # @raise [GitDBException] if query fails
100
+ def find_one(collection, query = {})
101
+ documents = find(collection, query)
102
+ documents.first
103
+ end
104
+
105
+ # Find a document by ID
106
+ # @param collection [String] collection name
107
+ # @param id [String] document ID
108
+ # @return [Hash] document
109
+ # @raise [GitDBException] if query fails
110
+ def find_by_id(collection, id)
111
+ response = make_request(:get, "/api/v1/collections/#{collection}/documents/#{id}")
112
+
113
+ unless response.code == '200'
114
+ raise GitDBException, "Failed to find document: #{response.code}"
115
+ end
116
+
117
+ JSON.parse(response.body)
118
+ end
119
+
120
+ # Update a document by ID
121
+ # @param collection [String] collection name
122
+ # @param id [String] document ID
123
+ # @param update [Hash] update operations
124
+ # @return [Boolean] true if updated successfully
125
+ # @raise [GitDBException] if update fails
126
+ def update(collection, id, update)
127
+ response = make_request(:put, "/api/v1/collections/#{collection}/documents/#{id}", update)
128
+ response.code == '200'
129
+ end
130
+
131
+ # Update multiple documents
132
+ # @param collection [String] collection name
133
+ # @param query [Hash] query to match documents
134
+ # @param update [Hash] update operations
135
+ # @return [Integer] number of modified documents
136
+ # @raise [GitDBException] if update fails
137
+ def update_many(collection, query, update)
138
+ data = { query: query, update: update }
139
+ response = make_request(:post, "/api/v1/collections/#{collection}/documents/update-many", data)
140
+
141
+ unless response.code == '200'
142
+ raise GitDBException, "Failed to update documents: #{response.code}"
143
+ end
144
+
145
+ result = JSON.parse(response.body)
146
+ result['modifiedCount'] || 0
147
+ end
148
+
149
+ # Delete a document by ID
150
+ # @param collection [String] collection name
151
+ # @param id [String] document ID
152
+ # @return [Boolean] true if deleted successfully
153
+ # @raise [GitDBException] if deletion fails
154
+ def delete(collection, id)
155
+ response = make_request(:delete, "/api/v1/collections/#{collection}/documents/#{id}")
156
+ response.code == '200'
157
+ end
158
+
159
+ # Delete multiple documents
160
+ # @param collection [String] collection name
161
+ # @param query [Hash] query to match documents
162
+ # @return [Integer] number of deleted documents
163
+ # @raise [GitDBException] if deletion fails
164
+ def delete_many(collection, query)
165
+ response = make_request(:post, "/api/v1/collections/#{collection}/documents/delete-many", query)
166
+
167
+ unless response.code == '200'
168
+ raise GitDBException, "Failed to delete documents: #{response.code}"
169
+ end
170
+
171
+ result = JSON.parse(response.body)
172
+ result['deletedCount'] || 0
173
+ end
174
+
175
+ # Count documents in a collection
176
+ # @param collection [String] collection name
177
+ # @param query [Hash] query to match documents
178
+ # @return [Integer] document count
179
+ # @raise [GitDBException] if count fails
180
+ def count(collection, query = {})
181
+ response = make_request(:post, "/api/v1/collections/#{collection}/documents/count", query)
182
+
183
+ unless response.code == '200'
184
+ raise GitDBException, "Failed to count documents: #{response.code}"
185
+ end
186
+
187
+ result = JSON.parse(response.body)
188
+ result['count'] || 0
189
+ end
190
+
191
+ # Execute a GraphQL query
192
+ # @param query [String] GraphQL query string
193
+ # @param variables [Hash, nil] GraphQL variables
194
+ # @return [Hash] GraphQL response
195
+ # @raise [GitDBException] if query fails
196
+ def graphql(query, variables = nil)
197
+ request_data = { query: query }
198
+ request_data[:variables] = variables if variables
199
+
200
+ response = make_request(:post, '/graphql', request_data)
201
+
202
+ unless response.code == '200'
203
+ raise GitDBException, "Failed to execute GraphQL query: #{response.code}"
204
+ end
205
+
206
+ result = JSON.parse(response.body)
207
+
208
+ if result['errors']
209
+ raise GitDBException, "GraphQL errors: #{result['errors']}"
210
+ end
211
+
212
+ result
213
+ end
214
+
215
+ private
216
+
217
+ # Make an HTTP request to the GitDB server
218
+ # @param method [Symbol] HTTP method
219
+ # @param path [String] API path
220
+ # @param data [Hash, nil] request data
221
+ # @return [Net::HTTPResponse] HTTP response
222
+ # @raise [GitDBException] if request fails
223
+ def make_request(method, path, data = nil)
224
+ uri = URI.parse("#{@base_url}#{path}")
225
+
226
+ case method
227
+ when :get
228
+ request = Net::HTTP::Get.new(uri)
229
+ when :post
230
+ request = Net::HTTP::Post.new(uri)
231
+ request.body = data.to_json if data
232
+ when :put
233
+ request = Net::HTTP::Put.new(uri)
234
+ request.body = data.to_json if data
235
+ when :delete
236
+ request = Net::HTTP::Delete.new(uri)
237
+ else
238
+ raise GitDBException, "Unsupported HTTP method: #{method}"
239
+ end
240
+
241
+ request['Authorization'] = "Bearer #{@token}"
242
+ request['Content-Type'] = 'application/json'
243
+
244
+ http = Net::HTTP.new(uri.host, uri.port)
245
+ http.use_ssl = uri.scheme == 'https'
246
+ http.read_timeout = 30
247
+ http.open_timeout = 30
248
+
249
+ response = http.request(request)
250
+
251
+ unless response.is_a?(Net::HTTPSuccess) || response.is_a?(Net::HTTPCreated)
252
+ raise GitDBException, "HTTP request failed: #{response.code} #{response.message}"
253
+ end
254
+
255
+ response
256
+ rescue => e
257
+ raise GitDBException, "Request failed: #{e.message}"
258
+ end
259
+ end
260
+
261
+ # Custom exception class for GitDB errors
262
+ class GitDBException < StandardError; end
263
+ end
metadata ADDED
@@ -0,0 +1,107 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gitdb-client
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - AFOT Team
8
+ - karthikeyanV2K
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2025-07-13 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: httparty
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: '0.21'
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: '0.21'
28
+ - !ruby/object:Gem::Dependency
29
+ name: json
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: '2.6'
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '2.6'
42
+ - !ruby/object:Gem::Dependency
43
+ name: rspec
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - "~>"
47
+ - !ruby/object:Gem::Version
48
+ version: '3.0'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: '3.0'
56
+ - !ruby/object:Gem::Dependency
57
+ name: rake
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - "~>"
61
+ - !ruby/object:Gem::Version
62
+ version: '13.0'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: '13.0'
70
+ description: A Ruby client for GitDB, a GitHub-backed NoSQL database
71
+ email:
72
+ - Support@afot.in
73
+ - karthikeyan@afot.in
74
+ executables: []
75
+ extensions: []
76
+ extra_rdoc_files: []
77
+ files:
78
+ - README.md
79
+ - gitdb-client.gemspec
80
+ - lib/gitdb_client.rb
81
+ homepage: https://github.com/karthikeyanV2K/GitDB
82
+ licenses:
83
+ - MIT
84
+ metadata:
85
+ homepage_uri: https://github.com/karthikeyanV2K/GitDB
86
+ source_code_uri: https://github.com/karthikeyanV2K/GitDB
87
+ changelog_uri: https://github.com/karthikeyanV2K/GitDB
88
+ post_install_message:
89
+ rdoc_options: []
90
+ require_paths:
91
+ - lib
92
+ required_ruby_version: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: 2.6.0
97
+ required_rubygems_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ requirements: []
103
+ rubygems_version: 3.4.10
104
+ signing_key:
105
+ specification_version: 4
106
+ summary: Official Ruby client for GitDB - GitHub-backed NoSQL database
107
+ test_files: []