qodex-rails 0.1.10 → 0.1.12

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: 412c62536ab0707422faa020f102a9c58a63f5ff475b2092ee28e86f6922bf1f
4
- data.tar.gz: 2263a192cdf11f9e97a94a5f2664c354ce8d0cb1c728a20101141c3a37b15813
3
+ metadata.gz: a262b4d3d39e45f79225e099292a23a4ce9252e868417e5c8d8afa5cd241612d
4
+ data.tar.gz: 236f581a2dac8c015f7e8fe89345ed666c251d6a84bceaff03f4d762e8e4fb57
5
5
  SHA512:
6
- metadata.gz: 25762008c98696dd7ef073f0db87717447d72b020d35ae19880c641acfc272ba9876dcf5d17c38f391e923a0a6b3d3281687c01aa82b75219e1aca46d3fb15c7
7
- data.tar.gz: 8a4e7943394dba195e650157f41e347b922c8a0c3915927e79fdabe275175ad5736f266ed55a933104a023a05eb77e643e086f9e82d0853eb48b15c07d624c40
6
+ metadata.gz: c7601c3ee35b8553318cf90c13c04d893ef86aacda9cf1b87d5a3cd1b4933f67eca99484a455cd70c1cb9ccb343c0408e964a2e228c7f6f02d743d658915eca8
7
+ data.tar.gz: 878eb28294a829db2065d43e7d3c07f352d75ff5825607cf1e24b100fb4f9e22f59292f279114adfe287197a124ff659268fb5dcf61f7e116a8222599d645599
data/README.md CHANGED
@@ -22,7 +22,7 @@ If bundler is not being used to manage dependencies, install the gem by executin
22
22
  # Your configuration settings for qodex-rails in the staging environment
23
23
  project_name = Rails.application.class.module_parent_name rescue 'qodex'
24
24
  config.collection_name = "#{project_name}-#{Rails.env}" # Name of the collection where logs will be stored
25
- config.enabled_in_production = false # Set to true to enable in production
25
+ config.allowed_environments = ['staging', 'production'] # Default value is staging if not set. Add production to enable in production
26
26
  config.api_key = 'Your API Key'
27
27
  end
28
28
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Qodex
4
4
  module Rails
5
- VERSION = "0.1.10"
5
+ VERSION = "0.1.12"
6
6
  end
7
7
  end
@@ -1,11 +1,12 @@
1
1
  module QodexRails
2
2
  class Configuration
3
- attr_accessor :collection_name, :api_key
3
+ attr_accessor :collection_name, :api_key, :allowed_environments, :frequency
4
4
 
5
5
  def initialize
6
6
  @collection_name = nil
7
7
  @api_key = nil
8
- @enabled_in_production = false
8
+ @allowed_environments = ['staging']
9
+ @frequency = 'medium'
9
10
  end
10
11
  end
11
12
  end
@@ -7,14 +7,14 @@ module QodexRails
7
7
  def initialize(app)
8
8
  @app = app
9
9
  @mutex = Mutex.new # Mutex for thread-safe logging
10
+ @allowed_environments = QodexRails.configuration.allowed_environments || ['staging']
11
+ @frequency = QodexRails.configuration.frequency || 'low'
10
12
  end
11
13
 
12
14
  def call(env)
13
-
14
- is_staging = Rails.env.staging?
15
- enabled_in_production = Rails.env.production? && QodexRails.configuration.enabled_in_production
16
15
 
17
- return @app.call(env) unless is_staging || enabled_in_production
16
+ # Check if the current environment is allowed
17
+ return @app.call(env) unless @allowed_environments.include?(Rails.env)
18
18
 
19
19
  # Exit early if collection_name or api_key are not configured
20
20
  unless QodexRails.configuration.collection_name && QodexRails.configuration.api_key
@@ -22,6 +22,15 @@ module QodexRails
22
22
  return @app.call(env)
23
23
  end
24
24
 
25
+ # Decide whether to log based on frequency setting
26
+ random_number = rand(20) + 1
27
+ case @frequency
28
+ when 'low'
29
+ return @app.call(env) unless random_number == 1
30
+ when 'medium'
31
+ return @app.call(env) unless random_number <= 4
32
+ end
33
+
25
34
  # Print the initializer keys to the output
26
35
  # Rails.logger.info "QodexRails Initializer Keys: Collection Name: #{QodexRails.configuration.collection_name}, API Key: #{QodexRails.configuration.api_key}"
27
36
 
@@ -1,3 +1,3 @@
1
1
  module QodexRails
2
- VERSION = "0.1.10"
2
+ VERSION = "0.1.12"
3
3
  end
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.10
4
+ version: 0.1.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - sid
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-10-11 00:00:00.000000000 Z
11
+ date: 2023-11-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:
@@ -32,6 +32,7 @@ files:
32
32
  - lib/qodex/rails/version.rb
33
33
  - qodex-rails-0.1.0.gem
34
34
  - qodex-rails-0.1.1.gem
35
+ - qodex-rails-0.1.10.gem
35
36
  - qodex-rails-0.1.2.gem
36
37
  - qodex-rails-0.1.3.gem
37
38
  - qodex-rails-0.1.4.gem