yEnc 0.0.20 → 0.0.25
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.
- data/lib/y_enc.rb +47 -7
- metadata +3 -3
data/lib/y_enc.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
class YEnc
|
2
2
|
|
3
|
-
def initialize filepath
|
3
|
+
def initialize filepath, outputpath
|
4
4
|
@filepath = filepath
|
5
|
+
@outputpath = outputpath
|
5
6
|
puts "Searching for file: #{@filepath}"
|
6
7
|
end
|
7
8
|
|
@@ -9,21 +10,55 @@ class YEnc
|
|
9
10
|
if is_yenc?
|
10
11
|
#Continue decoding
|
11
12
|
puts "File is verified as yEncoded file. Beginning decoding."
|
12
|
-
|
13
|
-
|
13
|
+
begin_read = false
|
14
|
+
|
15
|
+
File.open(@filepath, 'r').each_line do |line|
|
16
|
+
|
14
17
|
if line.include?("=ybegin") #This is the begin size
|
15
18
|
breakdown_header line
|
19
|
+
begin_read = true
|
20
|
+
next
|
21
|
+
end
|
22
|
+
if line.include?("=yend")
|
23
|
+
puts "Reached the end of file"
|
24
|
+
begin_read=false
|
25
|
+
break #stop looking through the file we are done
|
16
26
|
end
|
17
27
|
#end of reading lines
|
18
|
-
|
19
|
-
|
28
|
+
|
29
|
+
if begin_read
|
30
|
+
#puts "LINE COUNT: #{line.length}"
|
31
|
+
#Decode and write to binary file
|
32
|
+
esc = false
|
33
|
+
line.each_byte do |c|
|
34
|
+
next if c == 13 or c == 10
|
35
|
+
|
36
|
+
if c == 61 and not esc #escape character hit goto the next one
|
37
|
+
esc = true
|
38
|
+
next
|
39
|
+
else
|
40
|
+
if esc
|
41
|
+
esc = false
|
42
|
+
c = c - 64
|
43
|
+
end
|
44
|
+
|
45
|
+
if c.between?(0,41)
|
46
|
+
decoded = c + 214
|
47
|
+
else
|
48
|
+
decoded = c - 42
|
49
|
+
end
|
50
|
+
end
|
51
|
+
@new_file.putc decoded
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
20
55
|
end
|
56
|
+
@new_file.close
|
21
57
|
else
|
22
58
|
puts "This is not a yEncoded file."
|
23
59
|
end
|
24
60
|
end
|
25
61
|
|
26
|
-
#EVERYTHING AFTER THIS IS PRIVATE
|
27
62
|
private
|
28
63
|
|
29
64
|
def is_yenc?
|
@@ -36,6 +71,11 @@ class YEnc
|
|
36
71
|
@line=line[/line=([^\s]+)/,1] if @line.nil?
|
37
72
|
puts "File Name: #{@filename}"
|
38
73
|
puts "Size: #{@filesize} Length: #{@line}"
|
74
|
+
puts "Creating file: #{@outputpath}#{@filename}"
|
75
|
+
@new_file = File.new(@outputpath + @filename, "wb")
|
39
76
|
end
|
40
77
|
|
41
|
-
end
|
78
|
+
end
|
79
|
+
|
80
|
+
y = YEnc.new("/Users/scontapay/yenc.txt", "/Users/scontapay/")
|
81
|
+
y.decode
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yEnc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.25
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,9 +9,9 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-07-
|
12
|
+
date: 2012-07-07 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
|
-
description: yEnc decoder
|
14
|
+
description: yEnc decoder written in Ruby
|
15
15
|
email: sam.contapay@gmail.com
|
16
16
|
executables: []
|
17
17
|
extensions: []
|