Class: EmacsOrgProtocolServer::Uglify
- Inherits:
-
Object
- Object
- EmacsOrgProtocolServer::Uglify
- Defined in:
- lib/emacs_org_protocol_server/uglify.rb
Constant Summary collapse
- DEFAULTS =
{ output: { preamble: 'javascript:' }, mangle: { toplevel: true } }
Instance Attribute Summary collapse
-
#input ⇒ Object
Returns the value of attribute input.
-
#options ⇒ Object
Returns the value of attribute options.
-
#output ⇒ Object
Returns the value of attribute output.
Instance Method Summary collapse
-
#initialize(input, output = nil, options = nil) ⇒ Uglify
constructor
A new instance of Uglify.
- #run! ⇒ Object
Constructor Details
#initialize(input, output = nil, options = nil) ⇒ Uglify
Returns a new instance of Uglify.
16 17 18 19 20 |
# File 'lib/emacs_org_protocol_server/uglify.rb', line 16 def initialize(input, output=nil, =nil) self.input = input self.output = output self. = DEFAULTS.merge( || {}) end |
Instance Attribute Details
#input ⇒ Object
Returns the value of attribute input.
14 15 16 |
# File 'lib/emacs_org_protocol_server/uglify.rb', line 14 def input @input end |
#options ⇒ Object
Returns the value of attribute options.
14 15 16 |
# File 'lib/emacs_org_protocol_server/uglify.rb', line 14 def end |
#output ⇒ Object
Returns the value of attribute output.
14 15 16 |
# File 'lib/emacs_org_protocol_server/uglify.rb', line 14 def output @output end |
Instance Method Details
#run! ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/emacs_org_protocol_server/uglify.rb', line 23 def run! ugli = Uglifier.new().compile(File.read(input)) ugli.gsub!(/\n/,'') if output File.write(output, ugli) else ugli end end |