copyleaks 5.0.0 → 5.1.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 +4 -4
- data/CHANGELOG.md +12 -0
- data/README.md +23 -20
- data/lib/copyleaks/ai_image_detection_client.rb +2 -1
- data/lib/copyleaks/models/constants/CopyleaksErrorTypes.rb +14 -0
- data/lib/copyleaks/models/constants/index.rb +1 -0
- data/lib/copyleaks/models/exceptions/copyleaks_api_error_detail.rb +15 -0
- data/lib/copyleaks/models/exceptions/copyleaks_api_exception.rb +78 -0
- data/lib/copyleaks/models/exceptions/index.rb +1 -0
- data/lib/copyleaks/models/submissions/properties/submission_properties.rb +45 -5
- data/lib/copyleaks/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 77b8b903b7adbbd0cb991a4faa0be8beab645e5fac2bfdddd9a606847cdfcd81
|
|
4
|
+
data.tar.gz: e23f9d2938bd7d4261f694c373410ccf75cb52dd4a1cbe338c881b7ee2363898
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 232d01d23e55f15e51ac3570fbd24884658a71cbef44c49853ad8779cedd5f06bfe16dd72cd02632f24b8393c5d0df520cc54ec7baa375852657fed36cec5b07
|
|
7
|
+
data.tar.gz: aeb9fadeb10156b6ceb7cc688418ce719ac914ad6cfa1c6414940f9e1525daac6addf641624465ff0c39bd152016cfbac12bb0ca4f9727429e6888015e800bf2
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to the Copyleaks Ruby SDK are listed here.
|
|
4
4
|
|
|
5
|
+
## 5.1.0
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- **API error details.** `Copyleaks::CopyleaksApiException` (and so `CommandException`, `RateLimitException` and `UnderMaintenanceException`) reads the error envelope of the response body, described at https://docs.copyleaks.com/using-the-apis/api-errors/.
|
|
10
|
+
- `error_type`, `error_id`, `error_code` (an Integer; a numeric String is converted), `error_message` and `error_url`. Each is `nil` when the field is missing or has the wrong type, or when the body is not an error envelope.
|
|
11
|
+
- `error_details`: an Array of `Copyleaks::CopyleaksApiErrorDetail`, each with `param` and `message`. Empty when the body has no details or they are malformed; entries that are not objects are dropped.
|
|
12
|
+
- Constants `Copyleaks::CopyleaksErrorTypes::INVALID_REQUEST_ERROR`, `AUTHENTICATION_ERROR`, `PAYMENT_ERROR` and `API_ERROR`. `error_type` stays a String, so a new type is returned as is.
|
|
13
|
+
- The readers never raise. Exception messages, classes and retry behaviour do not change.
|
|
14
|
+
- **Keyword arguments for every `Copyleaks::SubmissionProperties` argument.** `Copyleaks::SubmissionProperties.new(webhooks: webhooks, aiGeneratedText: Copyleaks::SubmissionAiGeneratedText.new(true))` sets only what you need, without `nil` placeholders. Only `webhooks` is required. The positional form keeps working, and both forms can be mixed. A `nil` on either side counts as not given, so a `nil` placeholder never overrides a keyword; an argument given a value both by position and as a keyword raises `ArgumentError`.
|
|
15
|
+
- **`submit` on the AI Image Detection client.** `api.ai_image_detection_client.submit` is an alias of `submit_`, the synchronous check that returns the result. `submit_` and `check` keep working.
|
|
16
|
+
|
|
5
17
|
## 5.0.0
|
|
6
18
|
|
|
7
19
|
The gem is now published as `copyleaks`. Versions up to 4.1.1 were published as `plagiarism-checker`. The Ruby code you write does not change: `require 'copyleaks'` and the `Copyleaks` module are the same as before. Read the upgrade notes below.
|
data/README.md
CHANGED
|
@@ -60,6 +60,7 @@ copyleaks = Copyleaks::API.new(
|
|
|
60
60
|
- `Copyleaks::RateLimitException` (HTTP 429) and `Copyleaks::UnderMaintenanceException` (HTTP 503): retry later with exponential backoff. `e.retry_after` returns the `Retry-After` header when the server sends one.
|
|
61
61
|
- `Copyleaks::AuthExpiredException`: the login token has expired, or expires within 5 minutes. Log in again.
|
|
62
62
|
- `Copyleaks::CommandException`, `RateLimitException` and `UnderMaintenanceException` all extend `Copyleaks::CopyleaksApiException`, so one `rescue Copyleaks::CopyleaksApiException => e` catches any API error response.
|
|
63
|
+
- `Copyleaks::CopyleaksApiException` reads the [error envelope](https://docs.copyleaks.com/using-the-apis/api-errors/) of the response body: `e.error_type` (compare with `Copyleaks::CopyleaksErrorTypes::INVALID_REQUEST_ERROR`, `AUTHENTICATION_ERROR`, `PAYMENT_ERROR` or `API_ERROR`), `e.error_id`, `e.error_code` (Integer), `e.error_message`, `e.error_url` and `e.error_details` (`Copyleaks::CopyleaksApiErrorDetail` objects with `param` and `message`). A missing field is `nil`; `error_details` is then `[]`.
|
|
63
64
|
- `Net::OpenTimeout`, `Net::ReadTimeout`, `Net::WriteTimeout` and socket errors: the request did not complete.
|
|
64
65
|
|
|
65
66
|
## 💡 Usage Examples
|
|
@@ -107,21 +108,21 @@ begin
|
|
|
107
108
|
'aGVsbG8gd29ybGQ=',
|
|
108
109
|
'ruby.txt',
|
|
109
110
|
Copyleaks::SubmissionProperties.new(
|
|
110
|
-
Copyleaks::SubmissionWebhooks.new("#{WEBHOOK_URL}/webhook/{STATUS}","#{WEBHOOK_URL}/url-webhook/new-result"),
|
|
111
|
-
true,
|
|
112
|
-
'developer_payloads_test',
|
|
113
|
-
true,
|
|
114
|
-
60,
|
|
115
|
-
1,
|
|
116
|
-
true,
|
|
117
|
-
Copyleaks::SubmissionActions::SCAN,
|
|
118
|
-
Copyleaks::SubmissionAuthor.new('Author_name'),
|
|
119
|
-
Copyleaks::SubmissionFilter.new(true, true, true),
|
|
120
|
-
Copyleaks::SubmissionScanning.new(true, nil, nil, Copyleaks::SubmissionScanningCopyleaksDB.new(true, true)),
|
|
121
|
-
Copyleaks::SubmissionIndexing.new([Copyleaks::SubmissionRepository.new('repo-1')]),
|
|
122
|
-
Copyleaks::SubmissionExclude.new(true, true, true, true, true),
|
|
123
|
-
Copyleaks::SubmissionPDF.new(true, 'pdf-title', BASE64_LOGO, false),
|
|
124
|
-
Copyleaks::SubmissionSensitiveData.new(false)
|
|
111
|
+
webhooks: Copyleaks::SubmissionWebhooks.new("#{WEBHOOK_URL}/webhook/{STATUS}","#{WEBHOOK_URL}/url-webhook/new-result"),
|
|
112
|
+
includeHtml: true,
|
|
113
|
+
developerPayload: 'developer_payloads_test',
|
|
114
|
+
sandbox: true,
|
|
115
|
+
expiration: 60,
|
|
116
|
+
sensitivityLevel: 1,
|
|
117
|
+
cheatDetection: true,
|
|
118
|
+
action: Copyleaks::SubmissionActions::SCAN,
|
|
119
|
+
author: Copyleaks::SubmissionAuthor.new('Author_name'),
|
|
120
|
+
filters: Copyleaks::SubmissionFilter.new(true, true, true),
|
|
121
|
+
scanning: Copyleaks::SubmissionScanning.new(true, nil, nil, Copyleaks::SubmissionScanningCopyleaksDB.new(true, true)),
|
|
122
|
+
indexing: Copyleaks::SubmissionIndexing.new([Copyleaks::SubmissionRepository.new('repo-1')]),
|
|
123
|
+
exclude: Copyleaks::SubmissionExclude.new(true, true, true, true, true),
|
|
124
|
+
pdf: Copyleaks::SubmissionPDF.new(true, 'pdf-title', BASE64_LOGO, false),
|
|
125
|
+
sensitiveDataProtection: Copyleaks::SubmissionSensitiveData.new(false)
|
|
125
126
|
)
|
|
126
127
|
)
|
|
127
128
|
|
|
@@ -133,12 +134,12 @@ For a full guide please refer to our step by step [Guide](https://docs.copyleaks
|
|
|
133
134
|
|
|
134
135
|
For a detailed understanding of the plagiarism detection process, refer to the Copyleaks Submit Endpoint [Documentation](https://docs.copyleaks.com/reference/actions/authenticity/submit-file)
|
|
135
136
|
|
|
136
|
-
Only `webhooks` is required in `Copyleaks::SubmissionProperties`. Every other argument is optional: a value left `nil` is not sent, and the server default applies.
|
|
137
|
+
Only `webhooks` is required in `Copyleaks::SubmissionProperties`. Every other argument is optional: a value left out or `nil` is not sent, and the server default applies. Every argument can be passed as a keyword, so you set only what you need:
|
|
137
138
|
|
|
138
139
|
```ruby
|
|
139
140
|
properties = Copyleaks::SubmissionProperties.new(
|
|
140
|
-
Copyleaks::SubmissionWebhooks.new("#{WEBHOOK_URL}/webhook/{STATUS}"),
|
|
141
|
-
|
|
141
|
+
webhooks: Copyleaks::SubmissionWebhooks.new("#{WEBHOOK_URL}/webhook/{STATUS}"),
|
|
142
|
+
sandbox: true,
|
|
142
143
|
overview: Copyleaks::SubmissionOverview.new(true, ignoreAuthorData: true), # Gen-AI Overview
|
|
143
144
|
internalAiSourceMatch: Copyleaks::SubmissionInternalAiSourceMatch.new(true), # Internal AI Source Match
|
|
144
145
|
references: Copyleaks::SubmissionReferences.new(true), # Citation Checker
|
|
@@ -148,6 +149,8 @@ properties = Copyleaks::SubmissionProperties.new(
|
|
|
148
149
|
institution: Copyleaks::SubmissionInstitution.new('institution-1')
|
|
149
150
|
)
|
|
150
151
|
```
|
|
152
|
+
The positional form, `Copyleaks::SubmissionProperties.new(webhooks, includeHtml, developerPayload, sandbox, ...)`, still works, and you can mix both forms as long as no argument is given twice.
|
|
153
|
+
|
|
151
154
|
Other new options:
|
|
152
155
|
- `Copyleaks::SubmissionAiGeneratedText.new(true, sensitivity: 2, explain: true)`: AI detection sensitivity (1 to 3) and AI Logic explanations
|
|
153
156
|
- `Copyleaks::SubmissionScanning.new(true, exclude, repositories, copyleaks_db, cross_languages, include: Copyleaks::SubmissionScanningInclude.new('my-prefix-*'))`
|
|
@@ -361,7 +364,7 @@ Determine if a given image was generated or partially generated by an AI.
|
|
|
361
364
|
true # sandbox mode
|
|
362
365
|
)
|
|
363
366
|
|
|
364
|
-
res = copyleaks.ai_image_detection_client.
|
|
367
|
+
res = copyleaks.ai_image_detection_client.submit(authToken, scanId, model)
|
|
365
368
|
rescue StandardError => e
|
|
366
369
|
puts "Error in test_image_detection: #{e.message}"
|
|
367
370
|
end
|
|
@@ -380,7 +383,7 @@ model = Copyleaks::CopyleaksAiImageDetectionRequestModel.new(
|
|
|
380
383
|
mask_type: Copyleaks::CopyleaksAiImageMaskTypes::HEATMAP, # BINARY (default), HEATMAP or NONE
|
|
381
384
|
object_detection: ['face', 'hand'] # up to 3 objects
|
|
382
385
|
)
|
|
383
|
-
res = copyleaks.ai_image_detection_client.check(authToken, scanId, model) # same as
|
|
386
|
+
res = copyleaks.ai_image_detection_client.check(authToken, scanId, model) # same as submit
|
|
384
387
|
result = Copyleaks::CopyleaksAiImageDetectionResponseModel.from_json(res)
|
|
385
388
|
puts "AI detected: #{result.is_ai_detected}, objects: #{Array(result.detected_objects).map(&:object)}"
|
|
386
389
|
```
|
|
@@ -17,8 +17,9 @@ module Copyleaks
|
|
|
17
17
|
'submission is Invalid, must be instance of type Copyleaks::CopyleaksAiImageDetectionRequestModel'])
|
|
18
18
|
end
|
|
19
19
|
|
|
20
|
-
# Same as submit_.
|
|
20
|
+
# Same as submit_ (synchronous check).
|
|
21
21
|
alias check submit_
|
|
22
|
+
alias submit submit_
|
|
22
23
|
|
|
23
24
|
# Submits an image URL for AI detection (asynchronous). The server answers 201 Created and later
|
|
24
25
|
# posts the result, shaped like CopyleaksAiImageDetectionResponseModel, to the request's webhook.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
module Copyleaks
|
|
2
|
+
# Documented values of error.type in an API error response (CopyleaksApiException#error_type).
|
|
3
|
+
# See https://docs.copyleaks.com/using-the-apis/api-errors/
|
|
4
|
+
class CopyleaksErrorTypes
|
|
5
|
+
# Invalid request format, missing parameters or malformed data.
|
|
6
|
+
INVALID_REQUEST_ERROR = "invalid_request_error"
|
|
7
|
+
# Invalid credentials, a disabled account or too many failed login attempts.
|
|
8
|
+
AUTHENTICATION_ERROR = "authentication_error"
|
|
9
|
+
# Insufficient credits, an expired subscription or a team billing error.
|
|
10
|
+
PAYMENT_ERROR = "payment_error"
|
|
11
|
+
# Internal server error, overload, timeout or temporary unavailability.
|
|
12
|
+
API_ERROR = "api_error"
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -4,6 +4,7 @@ require_relative 'CopyleaksAiImageDetectionModels.rb'
|
|
|
4
4
|
require_relative 'CopyleaksAiImageMaskTypes.rb'
|
|
5
5
|
require_relative 'CopyleaksAiVideoDetectionModels.rb'
|
|
6
6
|
require_relative 'CopyleaksAlertCodes.rb'
|
|
7
|
+
require_relative 'CopyleaksErrorTypes.rb'
|
|
7
8
|
|
|
8
9
|
|
|
9
10
|
module Copyleaks
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
module Copyleaks
|
|
2
|
+
# One entry of error.details in an API error response: a parameter that caused the error.
|
|
3
|
+
# See CopyleaksApiException#error_details.
|
|
4
|
+
class CopyleaksApiErrorDetail
|
|
5
|
+
# @return [String, nil] The request parameter, for example 'labels'.
|
|
6
|
+
attr_reader :param
|
|
7
|
+
# @return [String, nil] What is wrong with it.
|
|
8
|
+
attr_reader :message
|
|
9
|
+
|
|
10
|
+
def initialize(param: nil, message: nil)
|
|
11
|
+
@param = param
|
|
12
|
+
@message = message
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -1,6 +1,13 @@
|
|
|
1
|
+
require 'json'
|
|
2
|
+
|
|
1
3
|
module Copyleaks
|
|
2
4
|
# An error response from the Copyleaks API. Rescue it to handle CommandException, RateLimitException and
|
|
3
5
|
# UnderMaintenanceException together.
|
|
6
|
+
#
|
|
7
|
+
# The error_* readers return the fields of the error envelope in the response body
|
|
8
|
+
# ({"error": {"type", "id", "code", "message", "url", "details"}}, see
|
|
9
|
+
# https://docs.copyleaks.com/using-the-apis/api-errors/). Each one is nil (error_details: an empty Array)
|
|
10
|
+
# when the field is missing or has the wrong type, or when the body is not such an envelope. They never raise.
|
|
4
11
|
class CopyleaksApiException < RuntimeError
|
|
5
12
|
# The HTTP response, or nil when the exception was raised without one.
|
|
6
13
|
attr_reader :response
|
|
@@ -14,5 +21,76 @@ module Copyleaks
|
|
|
14
21
|
def retry_after
|
|
15
22
|
@response.nil? ? nil : @response['Retry-After']
|
|
16
23
|
end
|
|
24
|
+
|
|
25
|
+
# @return [String, nil] For example CopyleaksErrorTypes::INVALID_REQUEST_ERROR. Unknown values are returned as is.
|
|
26
|
+
def error_type
|
|
27
|
+
error_string('type')
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# @return [String, nil] Machine-readable, for example 'missing_parameter'.
|
|
31
|
+
def error_id
|
|
32
|
+
error_string('id')
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# @return [Integer, nil] The error code. A numeric String in the body is converted to an Integer.
|
|
36
|
+
def error_code
|
|
37
|
+
code = error_envelope['code']
|
|
38
|
+
return code if code.is_a?(Integer)
|
|
39
|
+
return code.strip.to_i if code.is_a?(String) && code.valid_encoding? && code.match?(/\A\s*[+-]?\d+\s*\z/)
|
|
40
|
+
|
|
41
|
+
nil
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# @return [String, nil] The error message of the body. Exception#message is not changed.
|
|
45
|
+
def error_message
|
|
46
|
+
error_string('message')
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# @return [String, nil] The documentation page for this error.
|
|
50
|
+
def error_url
|
|
51
|
+
error_string('url')
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# @return [Array<CopyleaksApiErrorDetail>] The parameters that caused the error. Entries that are not
|
|
55
|
+
# objects are skipped. Empty when the body has no details.
|
|
56
|
+
def error_details
|
|
57
|
+
details = error_envelope['details']
|
|
58
|
+
return [] unless details.is_a?(Array)
|
|
59
|
+
|
|
60
|
+
details.select { |detail| detail.is_a?(Hash) }.map do |detail|
|
|
61
|
+
CopyleaksApiErrorDetail.new(
|
|
62
|
+
param: detail['param'].is_a?(String) ? detail['param'] : nil,
|
|
63
|
+
message: detail['message'].is_a?(String) ? detail['message'] : nil
|
|
64
|
+
)
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
private
|
|
69
|
+
|
|
70
|
+
def error_string(name)
|
|
71
|
+
value = error_envelope[name]
|
|
72
|
+
value.is_a?(String) ? value : nil
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
# The 'error' object of the response body, parsed once. An empty Hash when there is none.
|
|
76
|
+
def error_envelope
|
|
77
|
+
return @error_envelope if defined?(@error_envelope)
|
|
78
|
+
|
|
79
|
+
envelope = parse_error_envelope
|
|
80
|
+
@error_envelope = envelope unless frozen?
|
|
81
|
+
envelope
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def parse_error_envelope
|
|
85
|
+
body = @response.respond_to?(:body) ? @response.body : nil
|
|
86
|
+
return {} unless body.is_a?(String) && !body.empty?
|
|
87
|
+
|
|
88
|
+
# Parse a copy: JSON.parse can re-tag a binary String as UTF-8 in place, which would change response.body.
|
|
89
|
+
parsed = JSON.parse(body.dup)
|
|
90
|
+
error = parsed.is_a?(Hash) ? parsed['error'] : nil
|
|
91
|
+
error.is_a?(Hash) ? error : {}
|
|
92
|
+
rescue StandardError
|
|
93
|
+
{}
|
|
94
|
+
end
|
|
17
95
|
end
|
|
18
96
|
end
|
|
@@ -1,11 +1,26 @@
|
|
|
1
1
|
module Copyleaks
|
|
2
2
|
# Scan settings. Only webhooks is required; arguments left nil are not sent, so the server default applies.
|
|
3
|
+
#
|
|
4
|
+
# Every argument can be passed as a keyword:
|
|
5
|
+
# SubmissionProperties.new(webhooks: SubmissionWebhooks.new(url), sandbox: true)
|
|
6
|
+
# The positional form, SubmissionProperties.new(webhooks, includeHtml, developerPayload, ...), still works, in the
|
|
7
|
+
# order of POSITIONAL_ARGUMENTS below. Both forms can be mixed. A nil on either side counts as not given, so a nil
|
|
8
|
+
# placeholder never overrides a keyword; giving the same argument a value both ways raises ArgumentError.
|
|
3
9
|
class SubmissionProperties
|
|
4
10
|
attr_reader :webhooks, :includeHtml, :developerPayload, :sandbox, :expiration, :sensitivityLevel, :cheatDetection,
|
|
5
11
|
:action, :author, :filters, :scanning, :indexing, :exclude, :pdf, :sensitiveDataProtection, :scanMethodAlgorithm,
|
|
6
12
|
:aiGeneratedText, :customMetadata, :writingFeedback, :displayLanguage, :aiSourceMatch,
|
|
7
13
|
:overview, :internalAiSourceMatch, :references, :scanTimeZone, :course, :assignment, :institution
|
|
8
14
|
|
|
15
|
+
# The arguments that can also be passed by position, in their positional order.
|
|
16
|
+
POSITIONAL_ARGUMENTS = %i[
|
|
17
|
+
webhooks includeHtml developerPayload sandbox expiration sensitivityLevel cheatDetection action author filters
|
|
18
|
+
scanning indexing exclude pdf sensitiveDataProtection scanMethodAlgorithm aiGeneratedText customMetadata
|
|
19
|
+
writingFeedback displayLanguage aiSourceMatch
|
|
20
|
+
].freeze
|
|
21
|
+
private_constant :POSITIONAL_ARGUMENTS
|
|
22
|
+
|
|
23
|
+
# @param [SubmissionWebhooks] webhooks Required.
|
|
9
24
|
# @param [String] developerPayload Echoed in the webhooks, at most 512 characters.
|
|
10
25
|
# @param [Boolean] sandbox Free mock results for testing the integration. Turn it off in production.
|
|
11
26
|
# @param [Integer] expiration Hours the scan is kept before it is deleted, 1 to 2880 (server default 2880).
|
|
@@ -16,14 +31,39 @@ module Copyleaks
|
|
|
16
31
|
# case-sensitive. Only applies when pdf.create is true (server default 'en').
|
|
17
32
|
# @param [String] scanTimeZone IANA time zone for the scan time on the PDF report, e.g. 'America/New_York'.
|
|
18
33
|
def initialize(
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
34
|
+
*positional,
|
|
35
|
+
webhooks: nil, includeHtml: nil, developerPayload: nil, sandbox: nil, expiration: nil,
|
|
36
|
+
sensitivityLevel: nil, cheatDetection: nil, action: nil, author: nil, filters: nil,
|
|
37
|
+
scanning: nil, indexing: nil, exclude: nil, pdf: nil, sensitiveDataProtection: nil,
|
|
38
|
+
scanMethodAlgorithm: nil, aiGeneratedText: nil, customMetadata: nil, writingFeedback: nil,
|
|
39
|
+
displayLanguage: nil, aiSourceMatch: nil,
|
|
24
40
|
overview: nil, internalAiSourceMatch: nil, references: nil, scanTimeZone: nil,
|
|
25
41
|
course: nil, assignment: nil, institution: nil
|
|
26
42
|
)
|
|
43
|
+
if positional.length > POSITIONAL_ARGUMENTS.length
|
|
44
|
+
raise ArgumentError, "wrong number of arguments (given #{positional.length}, expected 0..#{POSITIONAL_ARGUMENTS.length})"
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# As in 5.0.0, where webhooks was a required positional argument: calling without it is an ArgumentError
|
|
48
|
+
if positional.empty? && webhooks.nil?
|
|
49
|
+
raise ArgumentError, "wrong number of arguments (given 0, expected 1..#{POSITIONAL_ARGUMENTS.length}); " \
|
|
50
|
+
'pass webhooks first or as webhooks:'
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# Ruby can't declare one name as both a positional and a keyword parameter, so positional values are copied
|
|
54
|
+
# into the keyword locals of the same name. The validation below then reads one set of locals for both forms.
|
|
55
|
+
scope = binding
|
|
56
|
+
positional.each_with_index do |value, index|
|
|
57
|
+
next if value.nil? # a nil placeholder counts as not given, so it never overrides a keyword
|
|
58
|
+
|
|
59
|
+
name = POSITIONAL_ARGUMENTS[index]
|
|
60
|
+
unless scope.local_variable_get(name).nil?
|
|
61
|
+
raise ArgumentError, "Copyleaks::SubmissionProperties - #{name} - given both by position and as a keyword"
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
scope.local_variable_set(name, value)
|
|
65
|
+
end
|
|
66
|
+
|
|
27
67
|
unless webhooks.instance_of?(SubmissionWebhooks)
|
|
28
68
|
raise 'Copyleaks::SubmissionProperties - webhooks - webhooks must be of type SubmissionWebhooks'
|
|
29
69
|
end
|
data/lib/copyleaks/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: copyleaks
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 5.
|
|
4
|
+
version: 5.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Copyleaks ltd
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-11-
|
|
11
|
+
date: 2026-11-18 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: minitest
|
|
@@ -95,12 +95,14 @@ files:
|
|
|
95
95
|
- lib/copyleaks/models/constants/CopyleaksAiImageMaskTypes.rb
|
|
96
96
|
- lib/copyleaks/models/constants/CopyleaksAiVideoDetectionModels.rb
|
|
97
97
|
- lib/copyleaks/models/constants/CopyleaksAlertCodes.rb
|
|
98
|
+
- lib/copyleaks/models/constants/CopyleaksErrorTypes.rb
|
|
98
99
|
- lib/copyleaks/models/constants/CopyleaksTextModerationConstants.rb
|
|
99
100
|
- lib/copyleaks/models/constants/CopyleaksTextModerationLanguages.rb
|
|
100
101
|
- lib/copyleaks/models/constants/index.rb
|
|
101
102
|
- lib/copyleaks/models/delete_request_model.rb
|
|
102
103
|
- lib/copyleaks/models/exceptions/auth_expired_exception.rb
|
|
103
104
|
- lib/copyleaks/models/exceptions/command_exception.rb
|
|
105
|
+
- lib/copyleaks/models/exceptions/copyleaks_api_error_detail.rb
|
|
104
106
|
- lib/copyleaks/models/exceptions/copyleaks_api_exception.rb
|
|
105
107
|
- lib/copyleaks/models/exceptions/index.rb
|
|
106
108
|
- lib/copyleaks/models/exceptions/rate_limit_exception.rb
|