Skip to content

Commit 183986c

Browse files
authored
Merge pull request #10 from Copyleaks/features/1203221642267913/update-properties
features/1203221642267913/update-properties
2 parents f00aa0d + 1804c1a commit 183986c

File tree

15 files changed

+419
-11
lines changed

15 files changed

+419
-11
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#
2+
# The MIT License(MIT)
3+
#
4+
# Copyright(c) 2016 Copyleaks LTD (https://copyleaks.com)
5+
#
6+
# Permission is hereby granted, free of charge, to any person obtaining a copy
7+
# of this software and associated documentation files (the "Software"), to deal
8+
# in the Software without restriction, including without limitation the rights
9+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
# copies of the Software, and to permit persons to whom the Software is
11+
# furnished to do so, subject to the following conditions:
12+
#
13+
# The above copyright notice and this permission notice shall be included in all
14+
# copies or substantial portions of the Software.
15+
#
16+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
# SOFTWARE.
23+
# =
24+
module Copyleaks
25+
class SubmissionCrossLanguages
26+
# @param [Language[]] languages - Languages to scan your content against.
27+
def initialize(languages = nil)
28+
if !languages.nil? && !(languages.is_a?(Array) && languages.all? { |element| element.is_a?(SubmissionLanguage) })
29+
raise 'Copyleaks::SubmissionCrossLanguages - languages - languages must be of type SubmissionLanguage[]'
30+
end
31+
@languages = languages
32+
end
33+
34+
def as_json(*_args)
35+
{
36+
languages: @languages,
37+
}.select { |_k, v| !v.nil? }
38+
end
39+
40+
def to_json(*options)
41+
as_json(*options).to_json(*options)
42+
end
43+
end
44+
end
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#
2+
# The MIT License(MIT)
3+
#
4+
# Copyright(c) 2016 Copyleaks LTD (https://copyleaks.com)
5+
#
6+
# Permission is hereby granted, free of charge, to any person obtaining a copy
7+
# of this software and associated documentation files (the "Software"), to deal
8+
# in the Software without restriction, including without limitation the rights
9+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
# copies of the Software, and to permit persons to whom the Software is
11+
# furnished to do so, subject to the following conditions:
12+
#
13+
# The above copyright notice and this permission notice shall be included in all
14+
# copies or substantial portions of the Software.
15+
#
16+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
# SOFTWARE.
23+
# =
24+
module Copyleaks
25+
class SubmissionCustomMetadata
26+
# @param [String] key.
27+
# @param [String] value.
28+
def initialize(key, value)
29+
@key = key
30+
@value = value
31+
end
32+
33+
def as_json(*_args)
34+
{
35+
key: @key,
36+
value: @value
37+
}.select { |_k, v| !v.nil? }
38+
end
39+
40+
def to_json(*options)
41+
as_json(*options).to_json(*options)
42+
end
43+
end
44+
end

lib/copyleaks/models/submissions/properties/exclude.rb

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,41 @@ class SubmissionExclude
2828
# @param [Boolean] tableOfContents Exclude table of contents from the scan.
2929
# @param [Boolean] titles Exclude titles from the scan.
3030
# @param [Boolean] htmlTemplate When the scanned document is an HTML document, exclude irrelevant text that appears across the site like the website footer or header.
31+
# @param [Boolean] citations - Exclude citations from the scan.
32+
# @param [String[]] documentTemplateIds - Exclude text based on text found within other documents.
33+
# @param [SubmissionExcludeCode] code - Exclude sections of source code
34+
3135
def initialize(
3236
quotes = false,
3337
references = false,
3438
tableOfContents = false,
3539
titles = false,
36-
htmlTemplate = false
40+
htmlTemplate = false,
41+
citations = nil,
42+
documentTemplateIds = nil,
43+
code = nil
3744
)
45+
if !citations.nil? && ![true, false].include?(citations)
46+
raise 'Copyleaks::SubmissionExclude - citations - citations must be of type Boolean'
47+
end
48+
49+
if !documentTemplateIds.nil? && !(documentTemplateIds.is_a?(Array) && documentTemplateIds.all? { |element| element.is_a?(String) })
50+
raise 'Copyleaks::SubmissionExclude - documentTemplateIds - documentTemplateIds must be of type String[]'
51+
end
52+
53+
if !code.nil? && !code.instance_of?(SubmissionExcludeCode)
54+
raise 'Copyleaks::SubmissionExclude - code - code must be of type SubmissionExcludeCode'
55+
end
56+
3857
@quotes = quotes
3958
@references = references
4059
@tableOfContents = tableOfContents
4160
@titles = titles
4261
@htmlTemplate = htmlTemplate
62+
@citations = citations
63+
@documentTemplateIds = documentTemplateIds
64+
@code = code
65+
4366
end
4467

4568
def as_json(*_args)
@@ -48,7 +71,10 @@ def as_json(*_args)
4871
references: @references,
4972
tableOfContents: @tableOfContents,
5073
titles: @titles,
51-
htmlTemplate: @htmlTemplate
74+
htmlTemplate: @htmlTemplate,
75+
citations: @citations,
76+
documentTemplateIds: @documentTemplateIds,
77+
code: @code
5278
}.select { |_k, v| !v.nil? }
5379
end
5480

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#
2+
# The MIT License(MIT)
3+
#
4+
# Copyright(c) 2016 Copyleaks LTD (https://copyleaks.com)
5+
#
6+
# Permission is hereby granted, free of charge, to any person obtaining a copy
7+
# of this software and associated documentation files (the "Software"), to deal
8+
# in the Software without restriction, including without limitation the rights
9+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
# copies of the Software, and to permit persons to whom the Software is
11+
# furnished to do so, subject to the following conditions:
12+
#
13+
# The above copyright notice and this permission notice shall be included in all
14+
# copies or substantial portions of the Software.
15+
#
16+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
# SOFTWARE.
23+
# =
24+
module Copyleaks
25+
class SubmissionExcludeCode
26+
# @param [Boolean] Exclude comments from the scan.
27+
28+
def initialize(
29+
comments = false
30+
)
31+
@comments = comments
32+
end
33+
34+
def as_json(*_args)
35+
{
36+
comments: @comments,
37+
}.select { |_k, v| !v.nil? }
38+
end
39+
40+
def to_json(*options)
41+
as_json(*options).to_json(*options)
42+
end
43+
end
44+
end

lib/copyleaks/models/submissions/properties/index.rb

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,24 @@
2323
# =
2424

2525
require_relative 'submission_properties.rb'
26-
2726
require_relative 'actions.rb'
2827
require_relative 'ai_generated_text.rb'
2928
require_relative 'author.rb'
3029
require_relative 'copyleaks_db.rb'
30+
require_relative 'cross_languages.rb'
31+
require_relative 'custom_metadata.rb'
3132
require_relative 'domains_mode.rb'
33+
require_relative 'exclude_code.rb'
3234
require_relative 'exclude.rb'
3335
require_relative 'filter.rb'
36+
require_relative 'indexing_repository.rb'
3437
require_relative 'scan_method_algorithm.rb'
3538
require_relative 'indexing.rb'
39+
require_relative 'language.rb'
40+
require_relative 'masking_policy.rb'
41+
require_relative 'pdf_colors.rb'
3642
require_relative 'pdf_properties.rb'
43+
require_relative 'pdf_version.rb'
3744
require_relative 'repository.rb'
3845
require_relative 'scanning.rb'
3946
require_relative 'scanning_exclude.rb'
@@ -42,5 +49,7 @@
4249
require_relative 'submission_properties.rb'
4350
require_relative 'webhooks.rb'
4451

52+
53+
4554
module Copyleaks
4655
end

lib/copyleaks/models/submissions/properties/indexing.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
# =
2424
module Copyleaks
2525
class SubmissionIndexing
26-
# @param [SubmissionRepository[]] repositories - Check inner properties of SubmissionRepository for more details.
26+
# @param [SubmissionIndexingRepository[]] repositories - Check inner properties of SubmissionRepository for more details.
2727
def initialize(repositories)
2828
@repositories = repositories
2929
end
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#
2+
# The MIT License(MIT)
3+
#
4+
# Copyright(c) 2016 Copyleaks LTD (https://copyleaks.com)
5+
#
6+
# Permission is hereby granted, free of charge, to any person obtaining a copy
7+
# of this software and associated documentation files (the "Software"), to deal
8+
# in the Software without restriction, including without limitation the rights
9+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
# copies of the Software, and to permit persons to whom the Software is
11+
# furnished to do so, subject to the following conditions:
12+
#
13+
# The above copyright notice and this permission notice shall be included in all
14+
# copies or substantial portions of the Software.
15+
#
16+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
# SOFTWARE.
23+
# =
24+
module Copyleaks
25+
class SubmissionIndexingRepository < SubmissionRepository
26+
# @param [String] ID of a repository to add the scanned document to.
27+
# @param [SubmissionMaskingPolicy] maskingPolicy specify the document maskig ploicy.
28+
def initialize(id, maskingPolicy = nil)
29+
super(id)
30+
if !maskingPolicy.nil? && ![0, 1, 2].include?(maskingPolicy)
31+
raise 'Copyleaks::SubmissionIndexingRepository - maskingPolicy - maskingPolicy must be of type SubmissionMaskingPolicy'
32+
end
33+
@maskingPolicy = maskingPolicy
34+
end
35+
36+
def as_json(*_args)
37+
{
38+
id: @id,
39+
maskingPolicy: @maskingPolicy,
40+
}.select { |_k, v| !v.nil? }
41+
end
42+
43+
def to_json(*options)
44+
as_json(*options).to_json(*options)
45+
end
46+
end
47+
end
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#
2+
# The MIT License(MIT)
3+
#
4+
# Copyright(c) 2016 Copyleaks LTD (https://copyleaks.com)
5+
#
6+
# Permission is hereby granted, free of charge, to any person obtaining a copy
7+
# of this software and associated documentation files (the "Software"), to deal
8+
# in the Software without restriction, including without limitation the rights
9+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
# copies of the Software, and to permit persons to whom the Software is
11+
# furnished to do so, subject to the following conditions:
12+
#
13+
# The above copyright notice and this permission notice shall be included in all
14+
# copies or substantial portions of the Software.
15+
#
16+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
# SOFTWARE.
23+
# =
24+
module Copyleaks
25+
class SubmissionLanguage
26+
# @param [String] code - Language code for cross language plagiarism detection.
27+
def initialize(code)
28+
@code = code
29+
end
30+
31+
def as_json(*_args)
32+
{
33+
code: @code,
34+
}.select { |_k, v| !v.nil? }
35+
end
36+
37+
def to_json(*options)
38+
as_json(*options).to_json(*options)
39+
end
40+
end
41+
end
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#
2+
# The MIT License(MIT)
3+
#
4+
# Copyright(c) 2016 Copyleaks LTD (https://copyleaks.com)
5+
#
6+
# Permission is hereby granted, free of charge, to any person obtaining a copy
7+
# of this software and associated documentation files (the "Software"), to deal
8+
# in the Software without restriction, including without limitation the rights
9+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
# copies of the Software, and to permit persons to whom the Software is
11+
# furnished to do so, subject to the following conditions:
12+
#
13+
# The above copyright notice and this permission notice shall be included in all
14+
# copies or substantial portions of the Software.
15+
#
16+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
# SOFTWARE.
23+
# =
24+
module Copyleaks
25+
class SubmissionMaskingPolicy
26+
27+
NO_MASK = 0
28+
29+
MASK_OTHER_USERS_FILES = 1
30+
31+
MASK_ALL_FILES = 2
32+
33+
end
34+
end

0 commit comments

Comments
 (0)