moss_ruby 1.1.3 → 1.1.4
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 +5 -5
- data/lib/moss_ruby.rb +27 -8
- metadata +68 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 78627675df04c3b8c8a178e690f2c64f3f8588f451541dfd348b9fc0d4377ab5
|
4
|
+
data.tar.gz: 6f6c14edc678829dcf1a8b28ed1494ae64bfc0f5be0902ac9976b84ddc201e92
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9e46b7f5ca7d20c833a6e3d8729a53611392f86379ac71c1de9c9695088f870ba7a651169ac9d5bb5a85a71500382404c0467babad16be7da32292c2a99d78d9
|
7
|
+
data.tar.gz: cb30039ddb1641f4b2c860021402497846e1e2dcd713417794a3987c9cf495a6079d45f442c33662770ca5de4d7638b95cf2015778ec56124bc19a6f21543e2b
|
data/lib/moss_ruby.rb
CHANGED
@@ -20,7 +20,7 @@
|
|
20
20
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
21
|
# SOFTWARE.
|
22
22
|
|
23
|
-
require '
|
23
|
+
require 'tcp_timeout'
|
24
24
|
require 'open-uri'
|
25
25
|
|
26
26
|
#
|
@@ -92,7 +92,7 @@ class MossRuby
|
|
92
92
|
|
93
93
|
# Connect to the server
|
94
94
|
callback.call('Connecting to MOSS') unless callback.nil?
|
95
|
-
moss_server = TCPSocket.new @server, @port
|
95
|
+
moss_server = TCPTimeout::TCPSocket.new @server, @port, connect_timeout: 10, write_timeout: 9, read_timeout: 300
|
96
96
|
begin
|
97
97
|
# Send header details
|
98
98
|
callback.call(' - Sending configuration details') unless callback.nil?
|
@@ -106,7 +106,7 @@ class MossRuby
|
|
106
106
|
moss_server.write "language #{@options[:language]}\n"
|
107
107
|
|
108
108
|
callback.call(' - Checking language') unless callback.nil?
|
109
|
-
line = moss_server
|
109
|
+
line = gets(moss_server)
|
110
110
|
if line.strip() != "yes"
|
111
111
|
moss_server.write "end\n"
|
112
112
|
raise "Invalid language option."
|
@@ -144,7 +144,7 @@ class MossRuby
|
|
144
144
|
callback.call(" - Waiting for server response") unless callback.nil?
|
145
145
|
moss_server.write "query 0 #{@options[:comment]}\n"
|
146
146
|
|
147
|
-
result = moss_server
|
147
|
+
result = gets(moss_server)
|
148
148
|
|
149
149
|
moss_server.write "end\n"
|
150
150
|
return result.strip()
|
@@ -166,7 +166,7 @@ class MossRuby
|
|
166
166
|
|
167
167
|
# read the two match files
|
168
168
|
match_url = "#{uri}/match#{id}-top.html"
|
169
|
-
match_top = open(match_url).read().encode('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '?')
|
169
|
+
match_top = URI.open(match_url).read().encode('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '?')
|
170
170
|
|
171
171
|
callback.call(" - checking match #{match} percents") unless callback.nil?
|
172
172
|
top = read_pcts match_top
|
@@ -175,8 +175,8 @@ class MossRuby
|
|
175
175
|
|
176
176
|
callback.call(" - fetching #{match} html") unless callback.nil?
|
177
177
|
|
178
|
-
match_file[0] = open("#{uri}/match#{id}-0.html").read().encode('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '?')
|
179
|
-
match_file[1] = open("#{uri}/match#{id}-1.html").read().encode('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '?')
|
178
|
+
match_file[0] = URI.open("#{uri}/match#{id}-0.html").read().encode('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '?')
|
179
|
+
match_file[1] = URI.open("#{uri}/match#{id}-1.html").read().encode('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '?')
|
180
180
|
|
181
181
|
# puts match_top
|
182
182
|
# puts "---FILE0\n\n"
|
@@ -220,7 +220,7 @@ class MossRuby
|
|
220
220
|
result = Array.new
|
221
221
|
begin
|
222
222
|
callback.call(" - Reading match data") unless callback.nil?
|
223
|
-
page = open("#{uri}").read().encode('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '?')
|
223
|
+
page = URI.open("#{uri}").read().encode('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '?')
|
224
224
|
regex = /<TR><TD><A HREF=".*?match(?<match_id>\d+).html">.*\((?<pct0>\d+)%\)<\/A>\n.*?<TD><A.*?((?<pct0>\d+)%\))/i
|
225
225
|
# puts "scanning page"
|
226
226
|
page.scan(regex).each do | match |
|
@@ -249,4 +249,23 @@ class MossRuby
|
|
249
249
|
regex = /<TH>(?<filename0>\S+)\s\((?<pct0>\d+)%\).*<TH>(?<filename1>\S+)\s\((?<pct1>\d+)%\)/xm
|
250
250
|
top_file.match(regex)
|
251
251
|
end
|
252
|
+
|
253
|
+
##
|
254
|
+
# Reads a line from the server.
|
255
|
+
def gets moss_server
|
256
|
+
buffer = ""
|
257
|
+
|
258
|
+
loop do
|
259
|
+
tmp = moss_server.read(1)
|
260
|
+
|
261
|
+
if !tmp.nil?
|
262
|
+
buffer += tmp
|
263
|
+
end
|
264
|
+
|
265
|
+
break if tmp.nil? || tmp.include?("\n")
|
266
|
+
tmp = ''
|
267
|
+
end
|
268
|
+
|
269
|
+
return buffer.gsub(/\n/, '')
|
270
|
+
end
|
252
271
|
end
|
metadata
CHANGED
@@ -1,45 +1,101 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: moss_ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Cain
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
12
|
-
dependencies:
|
11
|
+
date: 2022-05-25 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: tcp_timeout
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.1.1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.1.1
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.3'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '13.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '13.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.11'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.11'
|
13
69
|
description: Moss-ruby is an unofficial ruby gem for the Moss system for Detecting
|
14
70
|
Software Plagiarism (http://theory.stanford.edu/~aiken/moss/)
|
15
|
-
email:
|
71
|
+
email:
|
72
|
+
- macite@gmail.com
|
16
73
|
executables: []
|
17
74
|
extensions: []
|
18
75
|
extra_rdoc_files: []
|
19
76
|
files:
|
20
77
|
- lib/moss_ruby.rb
|
21
|
-
homepage: https://
|
78
|
+
homepage: https://github.com/doubtfire-lms/moss-ruby
|
22
79
|
licenses:
|
23
80
|
- MIT
|
24
81
|
metadata: {}
|
25
|
-
post_install_message:
|
82
|
+
post_install_message:
|
26
83
|
rdoc_options: []
|
27
84
|
require_paths:
|
28
85
|
- lib
|
29
86
|
required_ruby_version: !ruby/object:Gem::Requirement
|
30
87
|
requirements:
|
31
|
-
- -
|
88
|
+
- - ">="
|
32
89
|
- !ruby/object:Gem::Version
|
33
90
|
version: '0'
|
34
91
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
35
92
|
requirements:
|
36
|
-
- -
|
93
|
+
- - ">="
|
37
94
|
- !ruby/object:Gem::Version
|
38
95
|
version: '0'
|
39
96
|
requirements: []
|
40
|
-
|
41
|
-
|
42
|
-
signing_key:
|
97
|
+
rubygems_version: 3.3.7
|
98
|
+
signing_key:
|
43
99
|
specification_version: 4
|
44
100
|
summary: Moss gem to access system for Detecting Software Plagiarism
|
45
101
|
test_files: []
|