committer 0.4.0 → 0.4.2

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: f495af607b9c66c6b3526af94a5d9792441dc84f6bf09c872586d70940ac6cb8
4
- data.tar.gz: 3b203eedb9030d65417c74c41c2535ca76230836a612033852703476bcfc2e86
3
+ metadata.gz: 1d0ac5269f5c3820aa6b82f73d2484f3ed6e9032f20072636687f7ec3f06ed64
4
+ data.tar.gz: eb250810565eef8cc558d517d61c441bc1f3607861ab2da55bfe6d88e59a9bfe
5
5
  SHA512:
6
- metadata.gz: 28b144c3f80ba381a8c3b00208d8ed92e9d8a47e7e2e21c86eb4c904699ecbd1711907a5bccd01227f6c7bb3c4a336adc199813c5590321e7d8b420891c35fb0
7
- data.tar.gz: 597f5f6db243a56f05c285377b6b8cbaa44f1ffebc300ce2febabf7945179346a3db9d4f1afaadcb92e1ca9141cd61012dfdda2a32dfed18c72d0c52747ce71c
6
+ metadata.gz: f0b32302cdb99081396e279cf71dcb511b1015d0af62c3da62720f5d44e6213284dc49116614336167f27e290f1dbaa823493f63ff8db3d0d7dc49b57656cdb6
7
+ data.tar.gz: f84c2835fcb6bb606b1d478654aa59111ea4e509cb0eb19b0e438fd84ef47958887f892b6db1a125810202c1938df073c5dd310769f2216710d38ac0ec72986f
@@ -1,7 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'json'
4
- require 'httparty'
4
+ require 'net/http'
5
+ require 'uri'
5
6
  require_relative '../committer/config/accessor'
6
7
 
7
8
  module Clients
@@ -11,6 +12,8 @@ module Clients
11
12
  class UnknownError < StandardError; end
12
13
  class ConfigError < StandardError; end
13
14
 
15
+ API_ENDPOINT = 'https://api.anthropic.com/v1/messages'
16
+
14
17
  def initialize
15
18
  @config = Committer::Config::Accessor.instance
16
19
 
@@ -38,19 +41,20 @@ module Clients
38
41
  private
39
42
 
40
43
  def send_request(body)
41
- options = build_request_options(body)
42
- HTTParty.post('https://api.anthropic.com/v1/messages', options)
43
- end
44
+ uri = URI.parse(API_ENDPOINT)
45
+ http = Net::HTTP.new(uri.host, uri.port)
46
+ http.use_ssl = true
44
47
 
45
- def build_request_options(body)
46
- {
47
- headers: {
48
- 'anthropic-version': '2023-06-01',
49
- 'content-type': 'application/json',
50
- 'x-api-key': @config['api_key']
51
- },
52
- body: body.to_json
53
- }
48
+ request = Net::HTTP::Post.new(uri.request_uri)
49
+ request['anthropic-version'] = '2023-06-01'
50
+ request['content-type'] = 'application/json'
51
+ request['x-api-key'] = @config['api_key']
52
+ request.body = body.to_json
53
+
54
+ response = http.request(request)
55
+ JSON.parse(response.body)
56
+ rescue JSON::ParserError
57
+ { 'type' => 'error', 'error' => { 'type' => 'unknown_error' } }
54
58
  end
55
59
 
56
60
  def handle_error_response(response)
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'httparty'
4
3
  require 'yaml'
5
4
  require_relative 'config/accessor'
6
5
  require_relative 'prompt_templates'
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Committer
4
- VERSION = '0.4.0'
4
+ VERSION = '0.4.2'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: committer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sebastien Stettler
@@ -9,21 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
  date: 2025-03-08 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: httparty
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '0.20'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '0.20'
12
+ dependencies: []
27
13
  description: A tool that uses Claude API to generate conventional commit messages
28
14
  based on staged changes
29
15
  email: