obfu_report 0.0.3.alpha → 0.0.4.alpha
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +6 -1
- data/lib/obfu_report/version.rb +1 -1
- data/lib/obfu_report.rb +44 -40
- metadata +2 -2
data/README.md
CHANGED
@@ -41,7 +41,12 @@ You can test this gem from the command line by copying the following code:
|
|
41
41
|
end
|
42
42
|
|
43
43
|
o = Obfu_report.new
|
44
|
-
o.
|
44
|
+
line1 = o.original(str,lst)
|
45
|
+
line2 = o.obfuscate(str,lst)
|
46
|
+
line3 = o.report(str,lst)
|
47
|
+
puts line1
|
48
|
+
puts line2
|
49
|
+
puts line3
|
45
50
|
|
46
51
|
END CUT HERE
|
47
52
|
|
data/lib/obfu_report/version.rb
CHANGED
data/lib/obfu_report.rb
CHANGED
@@ -2,51 +2,55 @@ require "obfu_report/version"
|
|
2
2
|
|
3
3
|
module ObfuReport
|
4
4
|
# Your code goes here...
|
5
|
-
def
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
5
|
+
def original(string, list)
|
6
|
+
|
7
|
+
osline = "Original string: #{string} \nOriginal list: #{list}"
|
8
|
+
return osline
|
9
|
+
|
10
|
+
end
|
11
|
+
# "obfuscate" returns the string with all words from the list obfuscated.
|
12
|
+
# obfuscate("big string of big words is bigger", ["big", "words"])
|
13
|
+
# ==> "*** string of *** ***** is bigger"
|
14
|
+
def obfuscate(string, list)
|
15
|
+
# check that input is a string and an array
|
16
|
+
if (string.is_a? String)&&(list.is_a? Array)
|
17
|
+
# iterate each item in the list
|
18
|
+
numb = 0
|
19
|
+
x = ""
|
20
|
+
list.each do |wrd|
|
21
|
+
# look for this word in the string
|
22
|
+
numb = wrd.length
|
23
|
+
numb.times do
|
24
|
+
x << "*"
|
25
|
+
end
|
26
|
+
string = string.gsub(/\b#{wrd}\b/, x)
|
14
27
|
x = ""
|
15
|
-
list.each do |wrd|
|
16
|
-
# look for this word in the string
|
17
|
-
numb = wrd.length
|
18
|
-
numb.times do
|
19
|
-
x << "*"
|
20
|
-
end
|
21
|
-
string = string.gsub(/\b#{wrd}\b/, x)
|
22
|
-
x = ""
|
23
|
-
end
|
24
|
-
puts "Obfuscated: #{string}"
|
25
|
-
else
|
26
|
-
puts "bad input, try again."
|
27
|
-
puts "#{string} #{list}"
|
28
28
|
end
|
29
|
+
obline = "Obfuscated: #{string}"
|
30
|
+
return obline
|
31
|
+
else
|
32
|
+
obline = "bad input, try again.\n #{string} #{list}"
|
33
|
+
return obline
|
29
34
|
end
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
puts "#{string} #{list}"
|
35
|
+
end
|
36
|
+
# "report" returns a hash containing the list of words and their associated frequency in the string.
|
37
|
+
# report("big string of big words is bigger", ["big", "words"])
|
38
|
+
# ==> {"big" => 2, "words" => 1}
|
39
|
+
def report(string,list)
|
40
|
+
if (string.is_a? String)&&(list.is_a? Array)
|
41
|
+
# wcline = "Word count: "
|
42
|
+
line = ""
|
43
|
+
# return wcline
|
44
|
+
list.each do |word|
|
45
|
+
test = string.split.count(word)
|
46
|
+
line << (word + " => " + test.to_s + " ")
|
43
47
|
end
|
48
|
+
string = ("Word count: " + line)
|
49
|
+
return string
|
50
|
+
else
|
51
|
+
line = "bad input, try again. \n #{string} #{list}"
|
52
|
+
return line
|
44
53
|
end
|
45
|
-
|
46
|
-
puts "Original string: #{string}"
|
47
|
-
puts "Original list: #{list}"
|
48
|
-
obfuscate(string, list)
|
49
|
-
report(string, list)
|
50
54
|
end
|
51
55
|
end
|
52
56
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: obfu_report
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4.alpha
|
5
5
|
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-06-
|
12
|
+
date: 2012-06-20 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: gem receives a string and an array then obfuscates the string based on
|
15
15
|
the array values and counts the frequency of array words in string
|