moss_ruby 1.1.2 → 1.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/moss_ruby.rb +15 -17
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ede898a27039418a249e377bbefcb25b31dfc8c5
|
4
|
+
data.tar.gz: ff6da3353d78254d07b39bdb28a1cc3f976e7f49
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2e44f5f1cefa7a02abf4935da2101ee1ca2d3e53875b4f8cfdb902cfbc6d8994f43562b47b2ff856ad23561e9134536030c87d3f5aa3785a64b92f26f021a9df
|
7
|
+
data.tar.gz: d1d3173ace55411467830c4b9f0bd560e96e0d6928b0ab8efc8cb67c5b18a750fdd5018e29defccd3ac39f067793ba4e2d3a6610f632d948490acd741ccae9a1
|
data/lib/moss_ruby.rb
CHANGED
@@ -61,15 +61,13 @@ class MossRuby
|
|
61
61
|
end
|
62
62
|
|
63
63
|
def upload_file (moss_server, file, id = 0)
|
64
|
-
filename = file.strip.
|
65
|
-
name.gsub! /[^\w\-\/.]/, '_'
|
66
|
-
end
|
64
|
+
filename = file.strip.encode('UTF-8', invalid: :replace, undef: :replace, replace: '').gsub /[^\w\-\/.]/, '_'
|
67
65
|
|
68
|
-
content = IO.read(
|
66
|
+
content = IO.read(file)
|
69
67
|
size = content.bytes.length
|
70
68
|
|
71
|
-
if size > 0
|
72
|
-
moss_server.write "file #{id} #{@options[:language]} #{size} #{
|
69
|
+
if size > 0
|
70
|
+
moss_server.write "file #{id} #{@options[:language]} #{size} #{filename}\n"
|
73
71
|
moss_server.write content
|
74
72
|
end
|
75
73
|
end
|
@@ -77,7 +75,7 @@ class MossRuby
|
|
77
75
|
def check(files_dict, callback=nil)
|
78
76
|
# Chech that the files_dict contains valid filenames
|
79
77
|
files_dict[:base_files].each do |file_search|
|
80
|
-
if Dir.glob(file_search
|
78
|
+
if Dir.glob(file_search).length == 0
|
81
79
|
raise "Unable to locate base file(s) matching #{file_search}"
|
82
80
|
end
|
83
81
|
end
|
@@ -87,7 +85,7 @@ class MossRuby
|
|
87
85
|
end
|
88
86
|
|
89
87
|
files_dict[:files].each do |file_search|
|
90
|
-
if Dir.glob(file_search
|
88
|
+
if Dir.glob(file_search).length == 0
|
91
89
|
raise "Unable to locate base file(s) matching #{file_search}"
|
92
90
|
end
|
93
91
|
end
|
@@ -118,7 +116,7 @@ class MossRuby
|
|
118
116
|
processing = files_dict[:base_files]
|
119
117
|
processing.each do |file_search|
|
120
118
|
callback.call(" - Sending base files #{count} of #{processing.count} - #{file_search}") unless callback.nil?
|
121
|
-
files = Dir.glob(file_search
|
119
|
+
files = Dir.glob(file_search)
|
122
120
|
file_count = 1
|
123
121
|
files.each do |file|
|
124
122
|
callback.call(" - Base file #{file_count} of #{files.count} - #{file}") unless callback.nil?
|
@@ -133,7 +131,7 @@ class MossRuby
|
|
133
131
|
processing = files_dict[:files]
|
134
132
|
processing.each do |file_search|
|
135
133
|
callback.call(" - Sending files #{count} of #{processing.count} - #{file_search}") unless callback.nil?
|
136
|
-
files = Dir.glob(file_search
|
134
|
+
files = Dir.glob(file_search)
|
137
135
|
file_count = 1
|
138
136
|
files.each do |file|
|
139
137
|
callback.call(" - File #{idx} = #{file_count} of #{files.count} - #{file}") unless callback.nil?
|
@@ -190,22 +188,22 @@ class MossRuby
|
|
190
188
|
|
191
189
|
data[0] = read_data match_file[0]
|
192
190
|
data[1] = read_data match_file[1]
|
193
|
-
|
191
|
+
|
194
192
|
callback.call(" - adding #{match} result") unless callback.nil?
|
195
|
-
result << [
|
193
|
+
result << [
|
196
194
|
{
|
197
|
-
filename: data[0][:filename],
|
195
|
+
filename: data[0][:filename],
|
198
196
|
html: strip_a("<PRE>#{data[0][:html]}</PRE>"),
|
199
197
|
pct: Integer(top[:pct0]),
|
200
198
|
url: match_url,
|
201
199
|
part_url: "#{uri}/match#{id}-0.html"
|
202
200
|
},
|
203
201
|
{
|
204
|
-
filename: data[1][:filename],
|
202
|
+
filename: data[1][:filename],
|
205
203
|
html: strip_a("<PRE>#{data[1][:html]}</PRE>"),
|
206
204
|
pct: Integer(top[:pct1]),
|
207
205
|
url: match_url,
|
208
|
-
part_url: "#{uri}/match#{id}-1.html"
|
206
|
+
part_url: "#{uri}/match#{id}-1.html"
|
209
207
|
}
|
210
208
|
]
|
211
209
|
end
|
@@ -225,7 +223,7 @@ class MossRuby
|
|
225
223
|
page = open("#{uri}").read().encode('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '?')
|
226
224
|
regex = /<TR><TD><A HREF=".*?match(?<match_id>\d+).html">.*\((?<pct0>\d+)%\)<\/A>\n.*?<TD><A.*?((?<pct0>\d+)%\))/i
|
227
225
|
# puts "scanning page"
|
228
|
-
page.scan(regex).each do | match |
|
226
|
+
page.scan(regex).each do | match |
|
229
227
|
id, pct0, pct1 = match
|
230
228
|
# puts "#{id}, #{pct0}, #{pct1}"
|
231
229
|
if Integer(pct0) >= min_pct || Integer(pct1) >= min_pct
|
@@ -251,4 +249,4 @@ class MossRuby
|
|
251
249
|
regex = /<TH>(?<filename0>\S+)\s\((?<pct0>\d+)%\).*<TH>(?<filename1>\S+)\s\((?<pct1>\d+)%\)/xm
|
252
250
|
top_file.match(regex)
|
253
251
|
end
|
254
|
-
end
|
252
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Cain
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-07-07 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Moss-ruby is an unofficial ruby gem for the Moss system for Detecting
|
14
14
|
Software Plagiarism (http://theory.stanford.edu/~aiken/moss/)
|