Class: BrowserifyRb::Browserify
- Inherits:
-
Object
- Object
- BrowserifyRb::Browserify
- Defined in:
- lib/browserify_rb/browserify.rb
Constant Summary collapse
- LOG =
Logger.new(STDERR)
Class Method Summary collapse
Instance Method Summary collapse
- #compile(source) ⇒ Object
-
#initialize(command: "browserify -", suppress_stderr: false) ⇒ Browserify
constructor
A new instance of Browserify.
Constructor Details
#initialize(command: "browserify -", suppress_stderr: false) ⇒ Browserify
Returns a new instance of Browserify.
11 12 13 14 |
# File 'lib/browserify_rb/browserify.rb', line 11 def initialize command: "browserify -", suppress_stderr: false @command = command @suppress_stderr = suppress_stderr end |
Class Method Details
.compile(source, command: "browserify -", suppress_stderr: false) ⇒ Object
33 34 35 |
# File 'lib/browserify_rb/browserify.rb', line 33 def self.compile source, command: "browserify -", suppress_stderr: false new(command: command, suppress_stderr: suppress_stderr).compile(source) end |
Instance Method Details
#compile(source) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/browserify_rb/browserify.rb', line 16 def compile source out_buf = StringIO.new stdout_handler = proc {|d| out_buf << d } stderr_handler = @suppress_stderr ? proc { } : proc {|d| STDERR.print d } LOG.debug "run: #{@command}" status = BrowserifyRb::Popen3.async_exec( @command, input: source, stdout_handler: stdout_handler, stderr_handler: stderr_handler, ).value raise "non-zero exit status: #{status.to_i}" unless status.success? out_buf.string end |