qodex-rails 0.1.1 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0cc9a5ccd335641d6c77c77ec917e86f4546b9ad6b17111b5a3ea52bc79faa3c
4
- data.tar.gz: b5bc6ee69f2d251c98cc72c22957d01f0f58437909b47f031e91d1b31dd44de6
3
+ metadata.gz: b11d2adaab0ce0578b59e97eb0126db77c6e3ea9e574a26993fc98e5390a6625
4
+ data.tar.gz: 87c38a3060afe958a318c551447b930d8f59b6f8a4d26a3ee70aec9fc77e20b1
5
5
  SHA512:
6
- metadata.gz: 17ebca6fdc4e5349277352f388181e6e5a75164c3acaa43a52db8c3f39ae257e1b3a1f48459eaf0e89aa507b050c49b7a1f563e157a63f8375355dee65f4afee
7
- data.tar.gz: 9e2e6bd01d2d2eb2be4073aac3403154edf8a8ca68db91ab06bf5c84405aa589c927885572f4dfbe18d846e1081e6ba3c688766c48bc8dbf1bdd1dbec592fc72
6
+ metadata.gz: ceb75b0590a4b51efc355c35851ed649d3222671196987c8807192484291305b8ce899360ee428b06f4af86261be3464c8df0ae0ccb1cb44953de38a5b264542
7
+ data.tar.gz: 4e66c0e6157973b8c3e278d5ca7ed91473ddcf77367ea9c0c1b5f151f3f04749d642e19059e9763f4b763aafc8ff15aa19c4e4e737341753d2a5e82b87cba62d
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Qodex
4
4
  module Rails
5
- VERSION = "0.1.1"
5
+ VERSION = "0.1.3"
6
6
  end
7
7
  end
@@ -10,6 +10,15 @@ module QodexRails
10
10
  end
11
11
 
12
12
  def call(env)
13
+ # Exit early if collection_name or api_key are not configured
14
+ unless QodexRails.configuration.collection_name && QodexRails.configuration.api_key
15
+ Rails.logger.warn "QodexRails: collection_name or api_key not configured. Skipping middleware."
16
+ return @app.call(env)
17
+ end
18
+
19
+ # Print the initializer keys to the output
20
+ Rails.logger.info "QodexRails Initializer Keys: Collection Name: #{QodexRails.configuration.collection_name}, API Key: #{QodexRails.configuration.api_key}"
21
+
13
22
  start_time = Time.now
14
23
 
15
24
  # Capture the request details
@@ -30,7 +39,7 @@ module QodexRails
30
39
  api_key: QodexRails.configuration.api_key,
31
40
  apis: [{
32
41
  body: response_body,
33
- body_type: response.content_type,
42
+ body_type: 'none-type',
34
43
  request_type: request.request_method,
35
44
  timestamp: Time.now.to_i,
36
45
  url: request.url,
@@ -50,16 +59,16 @@ module QodexRails
50
59
 
51
60
  def extract_body(response)
52
61
  body = ""
53
- response.each { |part| body << part }
62
+ response.each { |part| body << part } if response.respond_to?(:each)
54
63
  body
55
64
  end
56
65
 
57
66
  def extract_headers(headers)
58
- headers.map { |name, value| { name: name, value: value } }
67
+ headers.map { |name, value| { name: name, value: value } } if headers.respond_to?(:map)
59
68
  end
60
69
 
61
70
  def send_to_api(logs)
62
- uri = URI("#{ENV['API_URL']}/api/v1/collections/create_with_folder/#{ENV['API_KEY']}")
71
+ uri = URI("https://api.app.qodex.ai/api/v1/collections/create_with_folder/#{QodexRails.configuration.api_key}")
63
72
  request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')
64
73
  request.body = JSON.generate(logs)
65
74
  response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == 'https') do |http|
@@ -67,7 +76,7 @@ module QodexRails
67
76
  end
68
77
 
69
78
  # Optionally log the response from the external API
70
- Rails.logger.info "API Response: #{response.body}" if response
79
+ Rails.logger.info "URI: #{uri}, API Response: #{response.body}" if response
71
80
  end
72
81
  end
73
82
  end
@@ -1,3 +1,3 @@
1
1
  module QodexRails
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.3"
3
3
  end
Binary file
Binary file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qodex-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - sid
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-09-30 00:00:00.000000000 Z
11
+ date: 2023-10-02 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Intercept your rails application to power Qodex.ai AI copilot.
14
14
  email:
@@ -31,6 +31,8 @@ files:
31
31
  - lib/qodex/rails.rb
32
32
  - lib/qodex/rails/version.rb
33
33
  - qodex-rails-0.1.0.gem
34
+ - qodex-rails-0.1.1.gem
35
+ - qodex-rails-0.1.2.gem
34
36
  - sig/qodex/rails.rbs
35
37
  homepage: https://qodex.ai
36
38
  licenses: