plagscan 0.0.3 → 0.0.6

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: 23b89dfff549230388cfa7a7ce7036d144a634966772e6e7fe0b6c8047fba886
4
- data.tar.gz: c4c73b11f7fa5030bcdb882ac547681c7195942c99ff560041eef40a64c51a4a
3
+ metadata.gz: 433c2ec8955ae950941672d96480f29dcf884c30c8a005fe7a1f2fd342d9a784
4
+ data.tar.gz: fbcb73f1371aee03721d53df442c9504f7cea64f1a3df183812ccffffe427a74
5
5
  SHA512:
6
- metadata.gz: 7fee157eb54c279e2f28203f602eed415205633ba33e093ae892de78410ad3e76992e566d450be4ee91d0e7ed4fdcf42adfdf07f84219d9adf2f02a8a4a0c317
7
- data.tar.gz: b12160e32ab7cc6aa926b7f9b8a41f2e112eae2f4ff6da9354df03e33e83a280732da00b9a8f5ca4bb7cf914f4fe3cee6feea1ff1c425ad024aaaef81b4e38d7
6
+ metadata.gz: 9bed202c3a3ddfebc0cd2f66c199982e5b1b997cf1b8f295ded6fe28d66d47e3c3e1afae544576622245f2beb1440be709564975cea04c34c383c794a0a0b0fb
7
+ data.tar.gz: c0c3a13c1550be8fbe9b35accc7759b63c7e88bc9c8b4103489e768f8e0157291b13bc130691d204f6dfc8a27b7488d06c93b23addbe26fb76123ac0ca62e5f5
@@ -0,0 +1,34 @@
1
+ name: Test Plagscan Ruby gem
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ matrix:
14
+ ruby-version: ['2.6', '2.7', '3.0', '3.1']
15
+
16
+ steps:
17
+ - uses: actions/checkout@v2
18
+
19
+ - name: Set up Ruby
20
+ uses: ruby/setup-ruby@v1
21
+ with:
22
+ ruby-version: ${{ matrix.ruby-version }}
23
+ bundler-cache: true
24
+
25
+ - name: Lint code - Rubocop
26
+ run: bundle exec rubocop
27
+
28
+ - name: Run tests
29
+ run: bundle exec rake
30
+
31
+ - name: Test & publish code coverage
32
+ uses: paambaati/codeclimate-action@v3.0.0
33
+ env:
34
+ CC_TEST_REPORTER_ID: 1e550d84766c7d7d61b7fb36d672a9cf6834600715a798b90e6a66d48574f592
data/.gitignore CHANGED
@@ -1,2 +1,3 @@
1
1
  *.gem
2
2
  Gemfile.lock
3
+ coverage/
data/.rubocop.yml CHANGED
@@ -1,8 +1,30 @@
1
1
  require: rubocop-rspec
2
2
 
3
+ AllCops:
4
+ TargetRubyVersion: 2.5
5
+ NewCops: enable
6
+
3
7
  Layout/DotPosition:
4
8
  EnforcedStyle: trailing
5
9
 
10
+ Layout/EmptyLinesAroundAttributeAccessor:
11
+ Enabled: true
12
+
13
+ Layout/SpaceAroundMethodCallOperator:
14
+ Enabled: true
15
+
16
+ Lint/DeprecatedOpenSSLConstant:
17
+ Enabled: true
18
+
19
+ Lint/MixedRegexpCaptureTypes:
20
+ Enabled: true
21
+
22
+ Lint/RaiseException:
23
+ Enabled: true
24
+
25
+ Lint/StructNewOverride:
26
+ Enabled: true
27
+
6
28
  Metrics/BlockLength:
7
29
  Exclude:
8
30
  - "**/*_spec.rb"
@@ -21,3 +43,24 @@ RSpec/MessageSpies:
21
43
 
22
44
  RSpec/MultipleExpectations:
23
45
  Max: 2
46
+
47
+ Style/ExponentialNotation:
48
+ Enabled: true
49
+
50
+ Style/HashEachMethods:
51
+ Enabled: true
52
+
53
+ Style/HashTransformKeys:
54
+ Enabled: true
55
+
56
+ Style/HashTransformValues:
57
+ Enabled: true
58
+
59
+ Style/RedundantRegexpCharacterClass:
60
+ Enabled: true
61
+
62
+ Style/RedundantRegexpEscape:
63
+ Enabled: true
64
+
65
+ Style/SlicingWithRange:
66
+ Enabled: true
data/CHANGELOG.md CHANGED
@@ -1,6 +1,21 @@
1
1
  # Changelog
2
2
 
3
3
  ## Unreleased
4
+ - none
5
+
6
+ ## [0.0.6](releases/tag/v0.0.6) - 2022-07-25
7
+ ### Fixed
8
+ - [#3] Increase read timeout for Documents#create to 2 minutes
9
+
10
+ ## [0.0.5](releases/tag/v0.0.5) - 2020-03-01
11
+ ### Fixed
12
+ - Address CVE-2020-8130 - `rake` OS command injection vulnerability
13
+
14
+ ## [0.0.4](releases/tag/v0.0.4) - 2019-12-31
15
+ ### Added
16
+ - Support for some `users` APIs (list and get)
17
+
18
+ ## [0.0.3](releases/tag/v0.0.3) - 2019-08-16
4
19
  ### Updated
5
20
  - Support File params in body actions (multipart form)
6
21
  - Include response body in invalid http response error message
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- [![Travis Build Status](http://img.shields.io/travis/Studiosity/plagscan-ruby.svg?style=flat)](https://travis-ci.org/Studiosity/plagscan-ruby)
1
+ [![Github Build Status](https://github.com/Studiosity/plagscan-ruby/actions/workflows/test.yml/badge.svg)](https://github.com/Studiosity/plagscan-ruby/actions/workflows/test.yml)
2
2
  [![Maintainability](https://api.codeclimate.com/v1/badges/43ec9575fe4727b96adb/maintainability)](https://codeclimate.com/github/Studiosity/plagscan-ruby/maintainability)
3
3
  [![Test Coverage](https://api.codeclimate.com/v1/badges/43ec9575fe4727b96adb/test_coverage)](https://codeclimate.com/github/Studiosity/plagscan-ruby/test_coverage)
4
4
  [![Gem Version](http://img.shields.io/gem/v/plagscan.svg?style=flat)](http://rubygems.org/gems/plagscan)
@@ -23,6 +23,64 @@ Or install it yourself as:
23
23
 
24
24
  $ gem install plagscan
25
25
 
26
+ # Supported APIs
27
+
28
+ ## Ping
29
+ #### Check if the PlagScan API is available
30
+ ```ruby
31
+ Plagscan.ping
32
+ => true
33
+ ```
34
+
35
+ ## Token
36
+ #### Authenticate and fetch `access_token` to use with other APIs
37
+ ```ruby
38
+ Plagscan::Token.fetch client_id: '1234', client_secret: 'secret'
39
+ => { access_token: 'secret_token', expires_in: 86400 }
40
+ ```
41
+
42
+ ## Documents
43
+ #### Upload documents to be checked by PlagScan
44
+ ```ruby
45
+ Plagscan::Documents.create access_token: 'secret_token', file: file
46
+ => { documentID: '1234', .... }
47
+ ```
48
+
49
+ N.B. you can also pass through the document as raw text using the `text` parameter in place of the `file` parameter.
50
+
51
+ Optional parameters for `userID`, `textname`, `toRepository` and `saveOrig`.
52
+ See [document create documentation](https://api.plagscan.com/v3docs/#api-Document-SubmitDocument)
53
+ for further details
54
+
55
+ #### Begin check of document uploaded to PlagScan
56
+ ```ruby
57
+ Plagscan::Documents.check access_token: 'secret_token', document_id: 1234
58
+ => nil
59
+ ```
60
+
61
+ #### Retrieve results of document scan
62
+ ```ruby
63
+ Plagscan::Documents.retrieve access_token: 'secret_token', document_id: 1234, mode: 0
64
+ => { ... }
65
+ ```
66
+ See [document retrieve documentation](https://api.plagscan.com/v3docs/#api-Document-RetrieveDocumentReport)
67
+ for further details
68
+
69
+ ## Users
70
+ #### List user details
71
+ ```ruby
72
+ Plagscan::Users.list access_token: 'secret_token'
73
+ => [{ ... }, { ... }, ...]
74
+ ```
75
+ See [user list documentation](https://api.plagscan.com/v3docs/#api-User-ListUser) for further details
76
+
77
+ #### Get user details
78
+ ```ruby
79
+ Plagscan::Users.get access_token: 'secret_token', user_id: 123456
80
+ => { ... }
81
+ ```
82
+ See [user get documentation](https://api.plagscan.com/v3docs/#api-User-GetUser) for further details
83
+
26
84
 
27
85
  # Development
28
86
 
@@ -26,7 +26,8 @@ module Plagscan
26
26
  Plagscan::Request.json_request(
27
27
  'documents',
28
28
  method: :post, access_token: access_token, expected_result: Net::HTTPCreated,
29
- body: create_props.merge(file ? { fileUpload: file } : { textdata: text })
29
+ body: create_props.merge(file ? { fileUpload: file } : { textdata: text }),
30
+ read_timeout: 120
30
31
  )
31
32
  end
32
33
 
@@ -22,15 +22,15 @@ module Plagscan
22
22
  "PlagScan-Ruby/#{Plagscan::VERSION}"
23
23
  end
24
24
 
25
- def request(path, options = {})
25
+ def request(path, **options)
26
26
  options = DEFAULT_REQUEST_OPTIONS.merge(options)
27
27
  http = create_http(options)
28
28
  req = create_request(path, options)
29
29
  http.start { http.request(req) }
30
30
  end
31
31
 
32
- def json_request(path, options = {})
33
- response = Plagscan::Request.request(path, options)
32
+ def json_request(path, **options)
33
+ response = Plagscan::Request.request(path, **options)
34
34
 
35
35
  unless response.is_a?(options[:expected_result] || Net::HTTPSuccess)
36
36
  raise Plagscan::HTTPError, "Invalid http response: #{response.code} - #{response.body}"
@@ -43,7 +43,7 @@ module Plagscan
43
43
 
44
44
  private
45
45
 
46
- def create_http(options)
46
+ def create_http(options) # rubocop:disable Metrics/AbcSize
47
47
  uri = URI api_url
48
48
  http = Net::HTTP.new(uri.host, uri.port)
49
49
 
@@ -53,6 +53,10 @@ module Plagscan
53
53
  http.ca_file = options[:ssl_ca_file] if options[:ssl_ca_file]
54
54
  end
55
55
 
56
+ %i[open_timeout write_timeout read_timeout].each do |option|
57
+ http.__send__("#{option}=", options[option]) if options[option]
58
+ end
59
+
56
60
  http
57
61
  end
58
62
 
@@ -68,7 +72,7 @@ module Plagscan
68
72
  end
69
73
 
70
74
  def body_request(uri, headers, options)
71
- uri += '?access_token=' + options[:access_token] if options[:access_token]
75
+ uri += "?access_token=#{options[:access_token]}" if options[:access_token]
72
76
  req = http_method(options).new(uri, headers)
73
77
  add_body(req, options[:body]) if options[:body]
74
78
  req
@@ -77,7 +81,7 @@ module Plagscan
77
81
  def uri_request(uri, headers, options)
78
82
  body = options[:body] || {}
79
83
  body[:access_token] = options[:access_token] if options[:access_token]
80
- uri += '?' + body.map { |k, v| "#{k}=#{v}" }.join('&') unless body.empty?
84
+ uri += "?#{body.map { |k, v| "#{k}=#{v}" }.join('&')}" unless body.empty?
81
85
  http_method(options).new(uri, headers)
82
86
  end
83
87
 
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Plagscan
4
+ #
5
+ # PlagScan users API
6
+ #
7
+ class Users
8
+ #
9
+ # User get REST API
10
+ # @param [Number] start The start position of the list (optional)
11
+ # @param [Number] limit The limit of results returned (optional)
12
+ # @return [Array] containing array of data for Users
13
+ #
14
+ # For more details, see https://api.plagscan.com/v3docs/#api-User-ListUser
15
+ #
16
+ def self.list(access_token:, **options)
17
+ list_props = options.delete_if { |k, _| !%i[start limit].include? k }
18
+
19
+ Plagscan::Request.json_request(
20
+ 'users',
21
+ access_token: access_token, body: list_props
22
+ )&.[](:data)
23
+ end
24
+
25
+ #
26
+ # User get REST API
27
+ # @param [Number] user_id PlagScan user ID
28
+ # @return [Hash] containing data from a User
29
+ #
30
+ # For more details, see https://api.plagscan.com/v3docs/#api-User-GetUser
31
+ #
32
+ def self.get(access_token:, user_id:)
33
+ Plagscan::Request.json_request(
34
+ "users/#{user_id}",
35
+ access_token: access_token
36
+ )&.[](:data)
37
+ end
38
+ end
39
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Plagscan
4
- VERSION = '0.0.3'
4
+ VERSION = '0.0.6'
5
5
  end
data/lib/plagscan.rb CHANGED
@@ -15,6 +15,7 @@ require 'plagscan/request'
15
15
  require 'plagscan/ping'
16
16
  require 'plagscan/token'
17
17
  require 'plagscan/documents'
18
+ require 'plagscan/users'
18
19
 
19
20
  #
20
21
  # Basic configuration for PlagScan API
@@ -24,3 +25,8 @@ module Plagscan
24
25
  'https://api.plagscan.com/v3/'
25
26
  end
26
27
  end
28
+
29
+ #
30
+ # Alias `PlagScan` to `Plagscan`
31
+ #
32
+ PlagScan = Plagscan
data/plagscan.gemspec CHANGED
@@ -14,6 +14,7 @@ Gem::Specification.new do |spec|
14
14
  spec.description = 'Ruby gem for PlagScan (https://www.plagscan.com/) plagiarism checking APIs'
15
15
  spec.homepage = 'https://github.com/Studiosity/plagscan-ruby'
16
16
  spec.license = 'MIT'
17
+ spec.required_ruby_version = ['>= 2.5.0', '< 3.2.0']
17
18
 
18
19
  # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
19
20
  # delete this section to allow pushing this gem to any host.
@@ -22,15 +23,17 @@ Gem::Specification.new do |spec|
22
23
  end
23
24
 
24
25
  spec.metadata['allowed_push_host'] = 'https://rubygems.org'
26
+ spec.metadata['rubygems_mfa_required'] = 'true'
25
27
 
26
28
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
27
29
  spec.require_paths = ['lib']
28
30
 
29
31
  spec.add_development_dependency 'bundler', '~> 2.0'
30
- spec.add_development_dependency 'rake', '~> 10.0'
32
+ spec.add_development_dependency 'rake', '>= 12.3.3'
31
33
  spec.add_development_dependency 'rspec', '~> 3.0'
32
- spec.add_development_dependency 'rubocop', '~> 0.74'
33
- spec.add_development_dependency 'rubocop-rspec', '~> 1.35'
34
- spec.add_development_dependency 'simplecov', '~> 0.17'
34
+ spec.add_development_dependency 'rubocop', '~> 1.28'
35
+ spec.add_development_dependency 'rubocop-rake', '~> 0.6'
36
+ spec.add_development_dependency 'rubocop-rspec', '~> 2.10'
37
+ spec.add_development_dependency 'simplecov', '~> 0.17', '< 0.18'
35
38
  spec.add_development_dependency 'webmock', '~> 3.0'
36
39
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: plagscan
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Bromwich
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-08-16 00:00:00.000000000 Z
11
+ date: 2022-07-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -28,16 +28,16 @@ dependencies:
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '10.0'
33
+ version: 12.3.3
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '10.0'
40
+ version: 12.3.3
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -58,28 +58,42 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '0.74'
61
+ version: '1.28'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '0.74'
68
+ version: '1.28'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop-rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.6'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.6'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: rubocop-rspec
71
85
  requirement: !ruby/object:Gem::Requirement
72
86
  requirements:
73
87
  - - "~>"
74
88
  - !ruby/object:Gem::Version
75
- version: '1.35'
89
+ version: '2.10'
76
90
  type: :development
77
91
  prerelease: false
78
92
  version_requirements: !ruby/object:Gem::Requirement
79
93
  requirements:
80
94
  - - "~>"
81
95
  - !ruby/object:Gem::Version
82
- version: '1.35'
96
+ version: '2.10'
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: simplecov
85
99
  requirement: !ruby/object:Gem::Requirement
@@ -87,6 +101,9 @@ dependencies:
87
101
  - - "~>"
88
102
  - !ruby/object:Gem::Version
89
103
  version: '0.17'
104
+ - - "<"
105
+ - !ruby/object:Gem::Version
106
+ version: '0.18'
90
107
  type: :development
91
108
  prerelease: false
92
109
  version_requirements: !ruby/object:Gem::Requirement
@@ -94,6 +111,9 @@ dependencies:
94
111
  - - "~>"
95
112
  - !ruby/object:Gem::Version
96
113
  version: '0.17'
114
+ - - "<"
115
+ - !ruby/object:Gem::Version
116
+ version: '0.18'
97
117
  - !ruby/object:Gem::Dependency
98
118
  name: webmock
99
119
  requirement: !ruby/object:Gem::Requirement
@@ -116,9 +136,9 @@ executables: []
116
136
  extensions: []
117
137
  extra_rdoc_files: []
118
138
  files:
139
+ - ".github/workflows/test.yml"
119
140
  - ".gitignore"
120
141
  - ".rubocop.yml"
121
- - ".travis.yml"
122
142
  - CHANGELOG.md
123
143
  - Gemfile
124
144
  - LICENSE
@@ -131,6 +151,7 @@ files:
131
151
  - lib/plagscan/ping.rb
132
152
  - lib/plagscan/request.rb
133
153
  - lib/plagscan/token.rb
154
+ - lib/plagscan/users.rb
134
155
  - lib/plagscan/version.rb
135
156
  - plagscan.gemspec
136
157
  homepage: https://github.com/Studiosity/plagscan-ruby
@@ -138,7 +159,8 @@ licenses:
138
159
  - MIT
139
160
  metadata:
140
161
  allowed_push_host: https://rubygems.org
141
- post_install_message:
162
+ rubygems_mfa_required: 'true'
163
+ post_install_message:
142
164
  rdoc_options: []
143
165
  require_paths:
144
166
  - lib
@@ -146,16 +168,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
146
168
  requirements:
147
169
  - - ">="
148
170
  - !ruby/object:Gem::Version
149
- version: '0'
171
+ version: 2.5.0
172
+ - - "<"
173
+ - !ruby/object:Gem::Version
174
+ version: 3.2.0
150
175
  required_rubygems_version: !ruby/object:Gem::Requirement
151
176
  requirements:
152
177
  - - ">="
153
178
  - !ruby/object:Gem::Version
154
179
  version: '0'
155
180
  requirements: []
156
- rubyforge_project:
157
- rubygems_version: 2.7.6.2
158
- signing_key:
181
+ rubygems_version: 3.1.4
182
+ signing_key:
159
183
  specification_version: 4
160
184
  summary: Ruby gem for PlagScan plagiarism APIs
161
185
  test_files: []
data/.travis.yml DELETED
@@ -1,30 +0,0 @@
1
- language: ruby
2
-
3
- env:
4
- global:
5
- - CC_TEST_REPORTER_ID=1e550d84766c7d7d61b7fb36d672a9cf6834600715a798b90e6a66d48574f592
6
-
7
- rvm:
8
- - 2.3
9
- - 2.4
10
- - 2.5
11
- - 2.6
12
-
13
- before_install:
14
- - gem update bundler
15
-
16
- install:
17
- - bundle install --jobs=3 --retry=3
18
- - gem install rubocop
19
-
20
- before_script:
21
- - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
22
- - chmod +x ./cc-test-reporter
23
- - ./cc-test-reporter before-build
24
-
25
- script:
26
- - rubocop
27
- - bundle exec rake
28
-
29
- after_script:
30
- - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT