Class: Machinator::Obfuscator
- Inherits:
-
Object
- Object
- Machinator::Obfuscator
- Defined in:
- lib/machinator/obfuscator.rb
Instance Method Summary collapse
-
#initialize ⇒ Obfuscator
constructor
A new instance of Obfuscator.
- #neverspeak(source, schema = nil, &block) ⇒ Object
Constructor Details
#initialize ⇒ Obfuscator
Returns a new instance of Obfuscator.
6 7 8 |
# File 'lib/machinator/obfuscator.rb', line 6 def initialize @block, @source, @schema = nil end |
Instance Method Details
#neverspeak(source, schema = nil, &block) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/machinator/obfuscator.rb', line 10 def neverspeak(source, schema=nil, &block) @schema = schema @source = source @block = block if @schema.nil? config = File.join(File.directory?(@source) ? @source : File.dirname(@source), ".machinator") if !File.exists?(config) raise Room101, "no schema specified and no .machinator file was found." end @schema = YAML::load(File.open(config)) end if @source.is_a?(File) || File.exist?(@source) if !File.directory?(@source) if !@block || @block.call(source) obfuscate_file obfuscate_file_name end else obfuscate_dir end else @source = String.new(@source) obfuscate_string return @source end end |