plagscan 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 7fd408fb011126a3928ec92df17a63b8bb6added05c2428f07b47eca598b96dd
4
+ data.tar.gz: fffe4c697ed70ba4b35be93a5d763345cfbf42c51e1a1903d6e86f723d45279b
5
+ SHA512:
6
+ metadata.gz: ce368219bb9309fc71a35d86c6f365c0ececf63e5aa919ccc28966a2b30ae6b8438f0fa27dfac59e957f4c5a8a1e9bd45cdbb665dfa24ff85f35fee9a0d38be8
7
+ data.tar.gz: ad6a98a358d21cfca119451cc30c83e5fecacf0cac60deb93e35f338b2c9ee578e8f6e09affb8712a5b3b9d44b429ca4e71eccbaacb3acae41dad42f02ac4f90
@@ -0,0 +1,2 @@
1
+ *.gem
2
+ Gemfile.lock
@@ -0,0 +1,5 @@
1
+ Metrics/LineLength:
2
+ Max: 100
3
+
4
+ Metrics/MethodLength:
5
+ Max: 12
@@ -0,0 +1,18 @@
1
+ language: ruby
2
+
3
+ rvm:
4
+ - 2.3
5
+ - 2.4
6
+ - 2.5
7
+ - 2.6
8
+
9
+ before_install:
10
+ - gem update bundler
11
+
12
+ install:
13
+ - bundle install --jobs=3 --retry=3
14
+ - gem install rubocop
15
+
16
+ script:
17
+ - rubocop
18
+ - bundle exec rake
@@ -0,0 +1,3 @@
1
+ ## [0.0.1](releases/tag/v0.0.1) - 2019-08-13
2
+ ### Added
3
+ - Base implementation of gem along with `ping` API
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ # Specify your gem's dependencies in plagscan.gemspec
6
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2019 Studiosity
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,47 @@
1
+ # PlagScan
2
+
3
+ Ruby wrapper for PlagScan plagiarism API
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'plagscan'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle install
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install plagscan
20
+
21
+
22
+ # Development
23
+
24
+ For details of the PlagScan API see documentation at https://api.plagscan.com/v3docs/
25
+
26
+
27
+ ## Contributing
28
+
29
+ Bug reports and pull requests are welcome on GitHub at https://github.com/Studiosity/plagscan-ruby.
30
+
31
+ Note that spec tests are appreciated to minimise regressions.
32
+ Before submitting a PR, please ensure that:
33
+
34
+ ```bash
35
+ $ rspec
36
+ ```
37
+ and
38
+
39
+ ```bash
40
+ $ rubocop
41
+ ```
42
+ both succeed
43
+
44
+
45
+ ## License
46
+
47
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env rake
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/gem_tasks'
5
+ require 'rspec/core/rake_task'
6
+
7
+ RSpec::Core::RakeTask.new(:spec)
8
+
9
+ task default: :spec
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup'
5
+ require 'plagscan'
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require 'irb'
15
+ IRB.start
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'plagscan/version'
4
+
5
+ require 'plagscan/error'
6
+ require 'plagscan/request'
7
+
8
+ # APIs
9
+ require 'plagscan/ping'
10
+
11
+ #
12
+ # Basic configuration for PlagScan API
13
+ #
14
+ module Plagscan
15
+ def self.api_base
16
+ 'https://api.plagscan.com/v3/'
17
+ end
18
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Plagscan
4
+ class Error < StandardError; end
5
+ class HTTPError < Error; end
6
+ class InvalidMethodError < HTTPError; end
7
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ #
4
+ # PlagScan module
5
+ #
6
+ module Plagscan
7
+ #
8
+ # PlagScan ping API
9
+ #
10
+ def self.ping
11
+ Plagscan::Request.request('ping').is_a? Net::HTTPOK
12
+ end
13
+ end
@@ -0,0 +1,92 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'uri'
4
+ require 'openssl'
5
+ require 'net/http'
6
+
7
+ module Plagscan
8
+ #
9
+ # PlagScan HTTP request service
10
+ #
11
+ class Request
12
+ DEFAULT_REQUEST_OPTIONS = {
13
+ method: :get,
14
+ body: nil,
15
+ headers: nil,
16
+ ssl_verify_mode: OpenSSL::SSL::VERIFY_PEER,
17
+ ssl_ca_file: nil
18
+ }.freeze
19
+
20
+ class << self
21
+ def api_url(path = '')
22
+ Plagscan.api_base + path
23
+ end
24
+
25
+ def request(path, options = {})
26
+ options = DEFAULT_REQUEST_OPTIONS.merge(options)
27
+
28
+ raise Plagscan::InvalidMethodError unless %i[get post].include? options[:method]
29
+
30
+ http = create_http(options)
31
+ req = create_request(path, options)
32
+ http.start { http.request(req) }
33
+ end
34
+
35
+ private
36
+
37
+ def create_http(options)
38
+ uri = URI api_url
39
+ http = Net::HTTP.new(uri.host, uri.port)
40
+
41
+ if uri.scheme == 'https'
42
+ http.use_ssl = true
43
+ http.verify_mode = options[:ssl_verify_mode]
44
+ http.ca_file = options[:ssl_ca_file] if options[:ssl_ca_file]
45
+ end
46
+
47
+ http
48
+ end
49
+
50
+ def create_request(path, options)
51
+ headers = extract_headers(options)
52
+ body = options[:body]
53
+
54
+ if options[:method] == :post
55
+ req = Net::HTTP::Post.new(path, headers)
56
+ add_body(req, body) if body
57
+ req
58
+ else
59
+ uri = api_url path
60
+ uri += '?' + body.map { |k, v| "#{k}=#{v}" }.join('&') if body
61
+ Net::HTTP::Get.new(uri, headers)
62
+ end
63
+ end
64
+
65
+ def extract_headers(options)
66
+ headers = options[:headers]
67
+
68
+ token = options.delete :token
69
+ if token
70
+ headers ||= {}
71
+
72
+ headers['X-Auth-Token'] = token.auth_token
73
+ headers['X-User-Id'] = token.user_id
74
+ end
75
+
76
+ return unless headers
77
+
78
+ headers = Util.stringify_hash_keys headers
79
+ headers.delete_if { |key, value| key.nil? || value.nil? }
80
+ end
81
+
82
+ def add_body(request, body)
83
+ if body.is_a? Hash
84
+ request.body = body.to_json
85
+ request.content_type = 'application/json'
86
+ else
87
+ request.body = body.to_s
88
+ end
89
+ end
90
+ end
91
+ end
92
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Plagscan
4
+ VERSION = '0.0.1'
5
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'plagscan/version'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = 'plagscan'
9
+ spec.version = Plagscan::VERSION
10
+ spec.authors = ['Andrew Bromwich']
11
+ spec.email = ['abromwich@studiosity.com']
12
+
13
+ spec.summary = 'Ruby gem for PlagScan plagiarism APIs'
14
+ spec.description = 'Ruby gem for PlagScan (https://www.plagscan.com/) plagiarism checking APIs'
15
+ spec.homepage = 'https://github.com/Studiosity/plagscan-ruby'
16
+ spec.license = 'MIT'
17
+
18
+ # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
19
+ # delete this section to allow pushing this gem to any host.
20
+ unless spec.respond_to?(:metadata)
21
+ raise 'RubyGems 2.0 or newer is required to protect against public gem pushes.'
22
+ end
23
+
24
+ spec.metadata['allowed_push_host'] = 'https://rubygems.org'
25
+
26
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
27
+ spec.require_paths = ['lib']
28
+
29
+ spec.add_runtime_dependency 'rest-client', '>= 1.4', '< 4.0'
30
+ spec.add_development_dependency 'bundler', '~> 2.0'
31
+ spec.add_development_dependency 'rake', '~> 10.0'
32
+ spec.add_development_dependency 'rspec', '~> 3.0'
33
+ spec.add_development_dependency 'rubocop', '~> 0.74'
34
+ spec.add_development_dependency 'webmock', '~> 3.0'
35
+ end
metadata ADDED
@@ -0,0 +1,151 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: plagscan
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Andrew Bromwich
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-08-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rest-client
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '1.4'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '4.0'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: '1.4'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '4.0'
33
+ - !ruby/object:Gem::Dependency
34
+ name: bundler
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '2.0'
40
+ type: :development
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '2.0'
47
+ - !ruby/object:Gem::Dependency
48
+ name: rake
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '10.0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '10.0'
61
+ - !ruby/object:Gem::Dependency
62
+ name: rspec
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '3.0'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: '3.0'
75
+ - !ruby/object:Gem::Dependency
76
+ name: rubocop
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '0.74'
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: '0.74'
89
+ - !ruby/object:Gem::Dependency
90
+ name: webmock
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - "~>"
94
+ - !ruby/object:Gem::Version
95
+ version: '3.0'
96
+ type: :development
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - "~>"
101
+ - !ruby/object:Gem::Version
102
+ version: '3.0'
103
+ description: Ruby gem for PlagScan (https://www.plagscan.com/) plagiarism checking
104
+ APIs
105
+ email:
106
+ - abromwich@studiosity.com
107
+ executables: []
108
+ extensions: []
109
+ extra_rdoc_files: []
110
+ files:
111
+ - ".gitignore"
112
+ - ".rubocop.yml"
113
+ - ".travis.yml"
114
+ - CHANGELOG.md
115
+ - Gemfile
116
+ - LICENSE
117
+ - README.md
118
+ - Rakefile
119
+ - bin/console
120
+ - lib/plagscan.rb
121
+ - lib/plagscan/error.rb
122
+ - lib/plagscan/ping.rb
123
+ - lib/plagscan/request.rb
124
+ - lib/plagscan/version.rb
125
+ - plagscan.gemspec
126
+ homepage: https://github.com/Studiosity/plagscan-ruby
127
+ licenses:
128
+ - MIT
129
+ metadata:
130
+ allowed_push_host: https://rubygems.org
131
+ post_install_message:
132
+ rdoc_options: []
133
+ require_paths:
134
+ - lib
135
+ required_ruby_version: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - ">="
138
+ - !ruby/object:Gem::Version
139
+ version: '0'
140
+ required_rubygems_version: !ruby/object:Gem::Requirement
141
+ requirements:
142
+ - - ">="
143
+ - !ruby/object:Gem::Version
144
+ version: '0'
145
+ requirements: []
146
+ rubyforge_project:
147
+ rubygems_version: 2.7.6.2
148
+ signing_key:
149
+ specification_version: 4
150
+ summary: Ruby gem for PlagScan plagiarism APIs
151
+ test_files: []