Class: JavascriptLoader
- Includes:
- Singleton
- Defined in:
- bin/rip-comments,
bin/rip-comments~
Instance Method Summary collapse
-
#initialize ⇒ JavascriptLoader
constructor
A new instance of JavascriptLoader.
- #load(filename, options = {}) ⇒ Object
Constructor Details
#initialize ⇒ JavascriptLoader
Returns a new instance of JavascriptLoader.
37 38 39 40 |
# File 'bin/rip-comments', line 37 def initialize require 'javascript/comment_stripper' @parser = CommentRipper::Javascript.new end |
Instance Method Details
#load(filename, options = {}) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'bin/rip-comments', line 42 def load(filename, ={}) File.open(filename) do |file| input = file.read output = @parser.strip(input) if(!.nil? && .has_key?(:outfile)) outfile = [:outfile] if(outfile != filename) File.open(outfile, 'w') {|f| f.write(output) } else $stderr.puts("Infile and outfile are the same (#{outfile}), and won't overwrite without force flag.") end else puts output end end end |