Class: JsShuffle::Methods::Method
- Inherits:
-
Object
- Object
- JsShuffle::Methods::Method
- Defined in:
- lib/jsshuffle/methods/method.rb
Overview
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
Direct Known Subclasses
Class Method Summary collapse
-
.inherited(subclass) ⇒ Object
Make sure
#respond_to?works like expected, even though this class provides the hooks.
Instance Method Summary collapse
-
#configure(options) ⇒ Object
Configures the
Methodinstance given the option hash. -
#default_config ⇒ Object
Returns the hash of default options the
Methodaccepts in the configure method. -
#postprocess(js, shuffler) ⇒ Object
Called last of the three hooks.
-
#preprocess(ast, shuffler) ⇒ Object
Called in the first pass.
-
#process(ast, shuffler) ⇒ Object
Called in the second pass.
Class Method Details
.inherited(subclass) ⇒ Object
Make sure #respond_to? works like expected, even though this class provides the hooks
49 50 51 52 53 54 |
# 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 |
Instance Method Details
#configure(options) ⇒ Object
Configures the Method instance given the option hash
Parameters:
options-
The options hash
19 20 21 |
# File 'lib/jsshuffle/methods/method.rb', line 19 def configure( ) @options = end |
#default_config ⇒ Object
Returns the hash of default options the Method accepts in the configure method
11 12 13 |
# File 'lib/jsshuffle/methods/method.rb', line 11 def default_config return {} end |
#postprocess(js, shuffler) ⇒ Object
Called last of the three hooks. Return the js!
Parameters:
js-
The JS in string form
- +shuffler
-
The Shuffler calling the hook
44 45 46 |
# File 'lib/jsshuffle/methods/method.rb', line 44 def postprocess( js, shuffler ) js end |
#preprocess(ast, shuffler) ⇒ Object
Called in the first pass. Don’t modify the AST in here!
Parameters:
ast-
The JS AST
- +shuffler
-
The Shuffler calling the hook
28 29 |
# File 'lib/jsshuffle/methods/method.rb', line 28 def preprocess( ast, shuffler ) end |
#process(ast, shuffler) ⇒ Object
Called in the second pass. Modify the AST here
Parameters:
js-
The JS AST
- +shuffler
-
The Shuffler calling the hook
36 37 |
# File 'lib/jsshuffle/methods/method.rb', line 36 def process( ast, shuffler ) end |