Class: Obfusc::Encryptor
- Inherits:
-
Object
- Object
- Obfusc::Encryptor
- Defined in:
- lib/obfusc/encryptor.rb
Overview
Recursive find files from origin or pattern
Constant Summary collapse
- SEP_FROM =
'/'.freeze
- SEP_TO =
'___|___'.freeze
Instance Method Summary collapse
- #decrypt(path) ⇒ Object
- #encrypt(path) ⇒ Object
-
#initialize(config) ⇒ Encryptor
constructor
A new instance of Encryptor.
- #obfuscated?(file) ⇒ Boolean
Constructor Details
#initialize(config) ⇒ Encryptor
Returns a new instance of Encryptor.
9 10 11 12 13 |
# File 'lib/obfusc/encryptor.rb', line 9 def initialize(config) @config = config @prefix = "#{config.prefix}__" @suffix = ".#{config.extension}" end |
Instance Method Details
#decrypt(path) ⇒ Object
23 24 25 |
# File 'lib/obfusc/encryptor.rb', line 23 def decrypt(path) (path).join(SEP_FROM) end |
#encrypt(path) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/obfusc/encryptor.rb', line 15 def encrypt(path) crypted_filename = (path).map do |step| step.chars.map { |char| charlist[char] || char }.join end.join(SEP_TO) [@prefix, crypted_filename, @suffix].join end |
#obfuscated?(file) ⇒ Boolean
27 28 29 |
# File 'lib/obfusc/encryptor.rb', line 27 def (file) !!(file =~ ) end |