class JsShuffle::Methods::Method
Wraps up a Method
to obfuscate / shuffle the JS.
When subclassing Method
define one or more of the three processing hooks:
preprocess
-
called in the first pass, this hook shouldn't modify the AST
process
-
called as the second pass. Modify the AST here
postprocess
-
called last. This method gets passed the js in string form and is expected to return a string itself
Public Class Methods
Make sure #respond_to?
works like expected, even though this class provides the hooks
# File lib/jsshuffle/methods/method.rb, line 49 def self.inherited( subclass ) undef_method :preprocess rescue "" undef_method :process rescue "" undef_method :postprocess rescue "" super end
Public Instance Methods
Configures the Method
instance given the option hash
Parameters:
options
-
The options hash
# File lib/jsshuffle/methods/method.rb, line 19 def configure( options ) @options = options end
Returns the hash of default options the Method
accepts in the configure method
# File lib/jsshuffle/methods/method.rb, line 11 def default_config return {} end
Called last of the three hooks. Return the js!
Parameters:
js
-
The JS in string form
- +shuffler
-
The Shuffler calling the hook
# File lib/jsshuffle/methods/method.rb, line 44 def postprocess( js, shuffler ) js end
Called in the first pass. Don't modify the AST in here!
Parameters:
ast
-
The JS AST
- +shuffler
-
The Shuffler calling the hook
# File lib/jsshuffle/methods/method.rb, line 28 def preprocess( ast, shuffler ) end
Called in the second pass. Modify the AST here
Parameters:
js
-
The JS AST
- +shuffler
-
The Shuffler calling the hook
# File lib/jsshuffle/methods/method.rb, line 36 def process( ast, shuffler ) end