yEnc 0.0.20
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/y_enc.rb +41 -0
- metadata +45 -0
data/lib/y_enc.rb
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
class YEnc
|
2
|
+
|
3
|
+
def initialize filepath
|
4
|
+
@filepath = filepath
|
5
|
+
puts "Searching for file: #{@filepath}"
|
6
|
+
end
|
7
|
+
|
8
|
+
def decode
|
9
|
+
if is_yenc?
|
10
|
+
#Continue decoding
|
11
|
+
puts "File is verified as yEncoded file. Beginning decoding."
|
12
|
+
File.open(@filepath, 'r') do |f|
|
13
|
+
f.any? do |line|
|
14
|
+
if line.include?("=ybegin") #This is the begin size
|
15
|
+
breakdown_header line
|
16
|
+
end
|
17
|
+
#end of reading lines
|
18
|
+
#Decode and write to binary file
|
19
|
+
end
|
20
|
+
end
|
21
|
+
else
|
22
|
+
puts "This is not a yEncoded file."
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
#EVERYTHING AFTER THIS IS PRIVATE
|
27
|
+
private
|
28
|
+
|
29
|
+
def is_yenc?
|
30
|
+
File.read(@filepath).include?("=ybegin")
|
31
|
+
end
|
32
|
+
|
33
|
+
def breakdown_header line
|
34
|
+
@filename=line[/name=(.*)/,1] if @filename.nil?
|
35
|
+
@filesize =line[/size=([^\s]+)/,1] if @filesize.nil?
|
36
|
+
@line=line[/line=([^\s]+)/,1] if @line.nil?
|
37
|
+
puts "File Name: #{@filename}"
|
38
|
+
puts "Size: #{@filesize} Length: #{@line}"
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
metadata
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: yEnc
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.20
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Sam Contapay
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-07-06 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: yEnc decoder and encoder written in pure Ruby
|
15
|
+
email: sam.contapay@gmail.com
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- lib/y_enc.rb
|
21
|
+
homepage: https://github.com/madgeekfiend/yenc
|
22
|
+
licenses: []
|
23
|
+
post_install_message:
|
24
|
+
rdoc_options: []
|
25
|
+
require_paths:
|
26
|
+
- lib
|
27
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
34
|
+
none: false
|
35
|
+
requirements:
|
36
|
+
- - ! '>='
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
requirements: []
|
40
|
+
rubyforge_project:
|
41
|
+
rubygems_version: 1.8.24
|
42
|
+
signing_key:
|
43
|
+
specification_version: 3
|
44
|
+
summary: yEnc
|
45
|
+
test_files: []
|