yEnc 0.0.29 → 0.0.30
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 +24 -1
- metadata +2 -2
data/lib/y_enc.rb
CHANGED
@@ -40,6 +40,29 @@ class YEnc
|
|
40
40
|
outputfile.close
|
41
41
|
end
|
42
42
|
|
43
|
+
# method only encodes given file and returns yenc encoded string; nothing more, nothing less
|
44
|
+
# Author: Tadeus Dobrovolskij
|
45
|
+
def encode
|
46
|
+
sio = StringIO.new("","w:ASCII-8BIT")
|
47
|
+
File.open(@filepath,'rb') do |b|
|
48
|
+
until b.eof?
|
49
|
+
buffer = b.read(128)
|
50
|
+
buffer.each_byte do |byte|
|
51
|
+
char_to_write = (byte + 42) % 256
|
52
|
+
if [0, 10, 13, 61].include?(char_to_write)
|
53
|
+
sio.putc '='
|
54
|
+
char_to_write = (char_to_write + 64) % 256
|
55
|
+
end
|
56
|
+
sio.putc char_to_write
|
57
|
+
end
|
58
|
+
sio.puts "\n"
|
59
|
+
end
|
60
|
+
end
|
61
|
+
result = sio.string
|
62
|
+
sio.close
|
63
|
+
return result
|
64
|
+
end
|
65
|
+
|
43
66
|
def decode
|
44
67
|
if is_yenc?
|
45
68
|
#Continue decoding
|
@@ -122,4 +145,4 @@ class YEnc
|
|
122
145
|
@new_file = File.new(@outputpath + @filename, "wb")
|
123
146
|
end
|
124
147
|
|
125
|
-
end
|
148
|
+
end
|
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.30
|
5
5
|
prerelease:
|
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:
|
12
|
+
date: 2013-10-31 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: yEnc decoder written in Ruby
|
15
15
|
email: sam.contapay@gmail.com
|